Short list with things to finish for D2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Nov 19 15:56:02 PST 2009


Walter Bright wrote:
> Andrei Alexandrescu wrote:
>> If we use @safe and @trusted to indicate unequivocally "no escape", 
>> then there is no analysis to be done - the hard part of the analysis 
>> has already been done manually by the user.
> 
> The problem then becomes:
> 
> T[] foo(T[] t) { return t; }
> 
> T[] bar()
> {
>    T[3] a;
>    return foo(a);
> }

The "no escape" rule only applies to pointers, not arrays. Translating 
your example to pointers:

T* foo(T* t) { return t; }

T* bar() {
     T[] a;
     return foo(a.ptr);
}

Steve Schweighoffer has pointed out a while ago that the compiler cannot 
assume a scope of a returned value to be any larger than the scopes of 
its parameters. Your example and the example above are canonical and the 
most complicated analysis I know of in SafeD. It is admittedly a huge 
complication, but just something that you'll need to pay attention to 
when implementing.


Andrei



More information about the Digitalmars-d mailing list