dlist for phobos
Michel Fortin
michel.fortin at michelf.com
Thu Jan 27 15:04:57 PST 2011
On 2011-01-27 17:52:27 -0500, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> said:
> On 1/27/11 4:48 PM, Tomek Sowiński wrote:
>> Andrei Alexandrescu napisał:
>>
>>> ref returns should be guaranteed to never escape.
>>
>> Should meaning they're not guaranteed now? I'm curious in what
>> scenarios they escape.
>
> Any function can take the address of a reference (either a ref
> parameter or the result of another function) and squirrel it away.
Even in @safe mode? Being able to take the address of a ref in non-safe
code seems normal to me.
That said, you don't need to take the address of anything to escape a ref:
ref int test() {
int i;
return pass(i);
}
ref int pass(ref int i) {
return i;
}
Now, consider that instead of 'int i' you have a container with
deterministic destruction:
ref int test() {
Container!int a;
return a[0];
}
Same problem.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list