Re: Can you access the same classes from C++ and D and vise versa, or do the classes have to not form dependency cycle?

2022-09-10 Thread zjh via Digitalmars-d-learn
On Saturday, 10 September 2022 at 22:07:32 UTC, Ali Çehreli wrote: On 9/10/22 13:04, Daniel Donnell wrote: > https://dlang.org/spec/cpp_interface.html At DConf, Manu indicated that that page is outdated and that D's C++ support is actually a lot better. Update it quickly, This is a big selli

Re: Is there a way to

2022-09-10 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 September 2022 at 00:32:18 UTC, Kyle Ingraham wrote: I can't use default parameters because I want to be able to call the delegate with arguments extracted from a URL path at runtime Some kind of wrapper might not only be your best option, it might be your only option. Your de

Re: Is there a way to

2022-09-10 Thread Kyle Ingraham via Digitalmars-d-learn
On Sunday, 11 September 2022 at 00:04:55 UTC, Adam D Ruppe wrote: On Saturday, 10 September 2022 at 23:37:30 UTC, Kyle Ingraham wrote: How can I write a type that is strict for the first two parameters but tolerant of any other parameter following those? That's not a type per se, but you can a

Re: Is there a way to

2022-09-10 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 10 September 2022 at 23:37:30 UTC, Kyle Ingraham wrote: How can I write a type that is strict for the first two parameters but tolerant of any other parameter following those? That's not a type per se, but you can assign wrapper at the assignment thing. Like your_delegate = (a,

Is there a way to

2022-09-10 Thread Kyle Ingraham via Digitalmars-d-learn
Is there a way to write a delegate type as being specific for some parameters and tolerant of anything for others? For example, I can specify this type: ```d alias MyDelegateType = void delegate(string name, int age); ``` It would be compatible with a pointer to this function converted to a d

Re: Dictionary of Templated Functions

2022-09-10 Thread Ali Çehreli via Digitalmars-d-learn
On 9/10/22 15:35, jwatson-CO-edu wrote: > So, my solution > will be to construct a catch-all struct `Payload` and have that be my > argument type from which various functions can draw the data of their > choice. Two Phobos features may be helpful there: https://dlang.org/phobos/std_sumtype.ht

Re: Dictionary of Templated Functions

2022-09-10 Thread jwatson-CO-edu via Digitalmars-d-learn
On Saturday, 10 September 2022 at 22:13:01 UTC, frame wrote: On Saturday, 10 September 2022 at 00:24:11 UTC, jwatson-CO-edu wrote: Hello, I'm trying to create a dictionary of templated function pointers. The functions should return `bool` and take a differently-typed dynamics arrays `T[]` as

Re: Dictionary of Templated Functions

2022-09-10 Thread frame via Digitalmars-d-learn
On Saturday, 10 September 2022 at 00:24:11 UTC, jwatson-CO-edu wrote: Hello, I'm trying to create a dictionary of templated function pointers. The functions should return `bool` and take a differently-typed dynamics arrays `T[]` as an argument. This won't work as you might expect. Your conta

Re: Can you access the same classes from C++ and D and vise versa, or do the classes have to not form dependency cycle?

2022-09-10 Thread Ali Çehreli via Digitalmars-d-learn
On 9/10/22 13:04, Daniel Donnell wrote: > https://dlang.org/spec/cpp_interface.html At DConf, Manu indicated that that page is outdated and that D's C++ support is actually a lot better. He kind-of-promised to update that page but I doubt it happened yet if ever. :) > one has to be compiled b

Re: neovim dcd-server error : ncm2_yarp dcd-server didn't cache any symbols ! Double check dcd include paths -I flag!

2022-09-10 Thread Alain De Vos via Digitalmars-d-learn
I seem to have found a solution. Before starting neovim i do a, dcd-server -I/usr/lib/ldc2/1.29/include/d Automatic would be better.

neovim dcd-server error : ncm2_yarp dcd-server didn't cache any symbols ! Double check dcd include paths -I flag!

2022-09-10 Thread Alain De Vos via Digitalmars-d-learn
I try neovim editor with the language server DCD but it seems no symbols our found. Could you guide me to solution ?

Can you access the same classes from C++ and D and vise versa, or do the classes have to not form dependency cycle?

2022-09-10 Thread Daniel via Digitalmars-d-learn
https://dlang.org/spec/cpp_interface.html According to that C++ / D .object files can interoperate both ways, but one has to be compiled before the other, order depending on direction. My question is, can you have a class C (C++) use a class D (Dlang) in such a way that D can also use C as i

Re: Using .require for struct types

2022-09-10 Thread Ali Çehreli via Digitalmars-d-learn
On 9/10/22 09:33, Erdem Demir wrote: > DListOfA returnVal = temp.require("a", DListOfA());--> I wish I > could use ref DListOfA here But keeping a reference to a temporary would not work because the life of that temporary ends by the end of that expression (practically, at the semicol

Re: Using .require for struct types

2022-09-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/10/22 12:33 PM, Erdem Demir wrote: Can you please suggest alternatives? Use a pointer. ```d DListOfA *returnVal = &temp.require(...); returnVal.insert(a); ``` -Steve

Re: import `Class` is used as a type

2022-09-10 Thread Injeckt via Digitalmars-d-learn
On Saturday, 10 September 2022 at 17:20:29 UTC, H. S. Teoh wrote: On Sat, Sep 10, 2022 at 04:59:50PM +, Injeckt via Digitalmars-d-learn wrote: I'm trying use classes in my project, but when i'm try inherit class, I get error: Error: import `Server.Console` is used as a type [...]

Re: import `Class` is used as a type

2022-09-10 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Sep 10, 2022 at 04:59:50PM +, Injeckt via Digitalmars-d-learn wrote: > I'm trying use classes in my project, but when i'm try inherit class, > I get error: > > Error: import `Server.Console` is used as a type [...] Don't name the module the same thing as the class. Rename it

import `Class` is used as a type

2022-09-10 Thread Injeckt via Digitalmars-d-learn
I'm trying use classes in my project, but when i'm try inherit class, I get error: Error: import `Server.Console` is used as a type Server.d: module Server; import std.string; import core.sys.windows.windows; import Console; class Server : Con

Using .require for struct types

2022-09-10 Thread Erdem Demir via Digitalmars-d-learn
import std; struct A { double val; bool isBig; } void main() { alias DListOfA = DList!A; DListOfA[string] temp; A a = {2.0, true}; DListOfA returnVal = temp.require("a", DListOfA());--> I wish I could use ref DListOfA here

Re: OpenXR library bindings etc

2022-09-10 Thread Sergey via Digitalmars-d-learn
On Friday, 9 September 2022 at 06:13:07 UTC, brian wrote: I'd like to use D for some visualisation in XR, but without OpenXR, I'm stuck before I even start. I have tried before to write the library bindings (https://github.com/infinityplusb/OpenXR-D), but got stuck and honestly don't know eno

Re: How I can pass the WndProc as a parameter?

2022-09-10 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 10 September 2022 at 10:39:12 UTC, Injeckt wrote: To elaborate on why you need the above... But I get these bugs: WndProc is a function, and you can't pass a function as a runtime function parameter, only pointers to functions. The first two errors tell you exactly what the pro

Re: How I can pass the WndProc as a parameter?

2022-09-10 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 10 September 2022 at 10:39:12 UTC, Injeckt wrote: And after all, I call it: KK_CreateWindowClass(WndProc); `KK_CreateWindowClass(&WndProc);`

Re: How I can pass the WndProc as a parameter?

2022-09-10 Thread Andrey Zherikov via Digitalmars-d-learn
On Saturday, 10 September 2022 at 10:39:12 UTC, Injeckt wrote: server.d(29): Error: function `server.WndProc(void* hwnd, uint message, uint wParam, int lParam)` is not callable using argument types `()` I think you need to get address of a function: ```d wndclass.lpfnWndProc = &WndProc; ```

Re: How I can pass the WndProc as a parameter?

2022-09-10 Thread Injeckt via Digitalmars-d-learn
On Saturday, 10 September 2022 at 10:39:12 UTC, Injeckt wrote: utils.d(52): Error: cannot implicitly convert expression `*WndProc` of type `nothrow @system extern (Windows) int(void*, uint, uint, int)` to `extern (Windows) int function(void*, uint, uint, int) nothrow @system`

How I can pass the WndProc as a parameter?

2022-09-10 Thread Injeckt via Digitalmars-d-learn
I define this function: extern(Windows) static LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) nothrow { return 0; } Then I define in another .d file: void KK_CreateWindowClass(WNDPROC WndProc) { WNDCLASSEX wndclass; wndclass.lpfn

Re: chain of exceptions, next method

2022-09-10 Thread Andrej Mitrovic via Digitalmars-d-learn
On Sunday, 14 August 2022 at 02:30:43 UTC, Paul Backus wrote: On Sunday, 14 August 2022 at 02:07:05 UTC, Ali Çehreli wrote: This automatic "combining" of exceptions happens for cleanup code like scope(exit). (I remember bug(s) for scope(failure).): To be precise, an exception thrown inside a