Escape Analysis on reddit

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Nov 1 09:15:28 PDT 2008


Steven Schveighoffer wrote:
> "Andrei Alexandrescu" wrote
>>> scope T[] findFirst(scope T[] buf, scope T target);
>>>
>>> scope T[] findFirst5(scope T[] buf)
>>> {
>>>    scope t5 = new T(5);
>>>    return findFirst(buf, t5);
>>> }
>> Same thing, won't compile. This is a clear example where conservative 
>> doesn't cut it.
> 
> OK, so then your proposed solution won't work for valid code like this. 
> Will there be a way to force this to compile?

That's an excellent point. Casts won't work because scope is not really 
a type constructor. I think we need to explore more Walter's idea in a 
post of his: to be able to attach the scope of the returned value to a 
specific parameter.


Andrei



More information about the Digitalmars-d mailing list