DIP1000

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Fri Jun 24 18:31:14 UTC 2022


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 calling function, not in the connect() 
function. So they are not destroyed when the connect() function 
returns.

> Since a linked list should not contain pointers to stack 
> allocated data you should avoid entirely the `scope` attribute 
> and use instead `const`.

It was only an example. There is nothing wrong with connecting 
objects on the stack.



More information about the Digitalmars-d-learn mailing list