Idea: Ownership & lifetime escape analysis by variables in reference to
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Sun May 29 07:42:29 UTC 2022
On Sunday, 29 May 2022 at 00:22:03 UTC, Rikki Cattermole wrote:
> Walter suggested that I create a thread for an idea I've had
> for memory ownership & lifetimes.
>
> The basic explanation is that every variable (including
> temporaries and returns) are always in reference to other
> variables. So that the order of destruction is correct and
> nothing escapes its owner (they can be bundled unless scope is
> involved).
Maybe look at the basic ideas for static analysis? Then you will
know the limitations.
How do you deal with conditionals?
How do you deal with mutable arrays of pointers?
Simple stuff like a queue of size two? How do you know what it
contains?
With lifetimes you can be pessimitic: max lifetime of anything
that could in theory be put into it unless I am able to prove
otherwise. Then you dont have to try to prove something unless it
is needed.
Better to just add ARC and do all these things as optimizations.
More information about the Digitalmars-d
mailing list