Re: Using .require for struct types

2022-09-11 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 10 September 2022 at 16:33:03 UTC, Erdem Demir wrote: I wish I could use ref DListOfA returnVal = but we can't in D. Can you please suggest alternatives? I think you should try advanced update. Your flexibility and what you can do are limited by your dreams. A couple

Re: Why I get delegate when passing address of function?

2022-09-11 Thread Injeckt via Digitalmars-d-learn
On Sunday, 11 September 2022 at 16:26:10 UTC, Ali Çehreli wrote: On 9/11/22 02:54, Injeckt wrote: > [...] You can combine your class object with other arguments and your thread function will know how to unwrap your class object to call its member function: [...] Thank you for help,

Re: Why I get delegate when passing address of function?

2022-09-11 Thread Ali Çehreli via Digitalmars-d-learn
On 9/11/22 09:26, Ali Çehreli wrote: // This combines a class instance (which is a pointer behind the scene)     // Combine with the class object In both places I meant "class variable". Ali

Re: Why I get delegate when passing address of function?

2022-09-11 Thread Ali Çehreli via Digitalmars-d-learn
On 9/11/22 02:54, Injeckt wrote: > And what I should do to pass non-static function? You can combine your class object with other arguments and your thread function will know how to unwrap your class object to call its member function: import std.stdio; // I am not on Windows, so I am

Re: Is it valid in D to write an opSlice overload that takes no arguments?

2022-09-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 September 2022 at 09:47:34 UTC, solidstate1991 wrote: Here's this code: This should be allowed, but also the way you're supposed to write it now is a no-argument opIndex.

Re: Why I get delegate when passing address of function?

2022-09-11 Thread Injeckt via Digitalmars-d-learn
On Sunday, 11 September 2022 at 09:29:23 UTC, Mike Parker wrote: On Sunday, 11 September 2022 at 09:15:11 UTC, Mike Parker wrote: Pointers to non-static member functions always produce a delegate. Otherwise, you wouldn't be able to access the class instance's members. Reference:

Is it valid in D to write an opSlice overload that takes no arguments?

2022-09-11 Thread solidstate1991 via Digitalmars-d-learn
Here's this code: ```d auto opSlice() { struct Range { Attr currentAttr; auto front() { return currentAttr; } void popFront() { currentAttr = currentAttr._nextAttr; } bool empty() { return currentAttr is null; } } return Range(firstAttr); } ```

Re: Why I get delegate when passing address of function?

2022-09-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 11 September 2022 at 09:15:11 UTC, Mike Parker wrote: Pointers to non-static member functions always produce a delegate. Otherwise, you wouldn't be able to access the class instance's members. Reference: https://dlang.org/spec/function.html#closures

Re: Why I get delegate when passing address of function?

2022-09-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 11 September 2022 at 09:02:31 UTC, Injeckt wrote: I have a one class and two modificators, where in "public" function I'm calling CreateThread with address of the ClientThread function which stored in same class, but in "private" modificator. And i get this error: Error: cannot

Why I get delegate when passing address of function?

2022-09-11 Thread Injeckt via Digitalmars-d-learn
I have a one class and two modificators, where in "public" function I'm calling CreateThread with address of the ClientThread function which stored in same class, but in "private" modificator. And i get this error: Error: cannot pass argument `` of type `extern (Windows) uint delegate(void*