[Dlang-study] [lifetime] Initial thoughts on lifetime management
Timon Gehr
timon.gehr at gmx.ch
Wed Oct 28 17:50:43 PDT 2015
On 10/29/2015 12:26 AM, Andrei Alexandrescu wrote:
> On 10/28/2015 07:22 PM, Timon Gehr wrote:
>> The question that remains is how the escape analysis should work. (This
>> is roughly the reason why Rust introduces lifetime annotations: it makes
>> modular a simple form of conservative escape analysis.)
>
> If it becomes clear we need to add an annotation, we will. But with RC
> we have an easier task than Rust because we start from the conservative
> side (add an incref for each reference used, named or not) and then we
> work our way backward. -- Andrei
The post this is a reply to seems to have been lost. I'm sending it
again below.
On 10/28/2015 11:42 PM, Andrei Alexandrescu wrote:
>
> Fantastic. That's why you're paid the big bucks! :o)
:)
Michel's post touches very related points.
scope arguments would be implicitly non-consuming, but it still makes
sense to have non-consuming arguments that may still be escaped. The
point here is that a method with a non-consuming argument can elide even
the initial and final opInc/opDec in the described transformation,
because the caller guarantees to keep alive the reference until after
the method returns. (OTOH, there are also cases where consumption is
exactly what you want, e.g. when constructing objects that contain rc
references.)
The question that remains is how the escape analysis should work. (This
is roughly the reason why Rust introduces lifetime annotations: it makes
modular a simple form of conservative escape analysis.)
More information about the Dlang-study
mailing list