Re: DIP1000

2022-06-24 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Friday, 24 June 2022 at 17:53:07 UTC, Loara wrote: Why you should use `scope` here? I probably shouldn't. That is why I asked in the «learn» forum… A `scope` pointer variable may refer to a stack allocated object that may be destroyed once the function returns. The objects are in the cal

Re: DIP1000

2022-06-24 Thread Loara via Digitalmars-d-learn
On Thursday, 23 June 2022 at 16:08:01 UTC, Ola Fosheim Grøstad wrote: How am I supposed to write this: ```d import std; @safe: struct node { node* next; } auto connect(scope node* a, scope node* b) { a.next = b; } void main() { node x; node y; connect(&x,&y); } ``` Erro

Re: How to use templates in a separate library?

2022-06-24 Thread frame via Digitalmars-d-learn
On Thursday, 23 June 2022 at 23:50:42 UTC, monkyyy wrote: On Thursday, 23 June 2022 at 08:12:32 UTC, CrazyMan wrote: linking make sure you use the -i flag when compiling But note, that would be the opposite of using a library.

Re: DIP1000

2022-06-24 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Friday, 24 June 2022 at 09:08:25 UTC, Dukc wrote: On Friday, 24 June 2022 at 05:11:13 UTC, Ola Fosheim Grøstad wrote: No, the lifetime is the same if there is no destructor. Being counter intuitive is poor usability. It depends on whether you expect the rules to be smart or simple. Smart

Re: DIP1000

2022-06-24 Thread Dukc via Digitalmars-d-learn
On Friday, 24 June 2022 at 05:11:13 UTC, Ola Fosheim Grøstad wrote: No, the lifetime is the same if there is no destructor. Being counter intuitive is poor usability. It depends on whether you expect the rules to be smart or simple. Smart is not necessarily better, as the Unix philosophy tel