DIP1000: The return of 'Extend Return Scope Semantics'
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Sat Jun 12 19:12:27 UTC 2021
On Saturday, 12 June 2021 at 18:35:02 UTC, Dennis wrote:
> If you give public access to the `Node* next` member, then you
> can freely escape `node.next.next` indeed. If you encapsulate
> it and only allow accessing nodes through `return scope` member
> functions, then you can make a fully `scope` linked list with
> e.g. all the nodes allocated on the stack.
There should be some way for an ADT to state that objects they
produce have the same lifetime as themselves.
So if I had a linked list wrapper. And you call
```wrapper.find_node(…)``` then the wrapper object should be able
to signal that the returned node has the same lifetime.
More information about the Digitalmars-d
mailing list