[Dlang-internal] DIP1000 discussion and testing
Martin Nowak via Dlang-internal
dlang-internal at puremagic.com
Tue Oct 25 17:39:27 PDT 2016
On Sunday, 23 October 2016 at 07:36:39 UTC, Walter Bright wrote:
> I can't, because I'm waiting for Andrei to make available what
> he considers a correct ref counted design.
>
> But you are correct in that the 'return' rules can be used to
> transfer the lifetime from an argument to the return value,
> even if the return value is not derived from the argument.
Glad to hear that. Even after 1 hour thinking in circles we
couldn't figure out where scope could be used without this.
From my still limited understanding, the lifetime of the return
value should be bound to the minimum (shortest) lifetime of all
arguments that could potentially be aliased.
So if the return value is a struct containing an int* and a S*,
it might alias any argument containing/or being an int or S (and
maybe untyped memory).
This seems to be essential for any wrapper using malloced memory
to safely return sth. (e.g. a range) with a pointer into that
memory.
More information about the Dlang-internal
mailing list