Escape analysis (full scope analysis proposal)

Robert Jacques sandford at jhu.edu
Fri Oct 31 06:17:05 PDT 2008


On Thu, 30 Oct 2008 21:01:28 -0400, Michel Fortin  
<michel.fortin at michelf.com> wrote:

> On 2008-10-30 14:07:42 -0400, "Robert Jacques" <sandford at jhu.edu> said:
>
>> On Wed, 29 Oct 2008 07:28:55 -0400, Michel Fortin   
>> <michel.fortin at michelf.com> wrote:
>>
>>> P.P.S.: This syntax doesn't fit very well with the current   
>>> scope(success/failure/exit) feature.
>> How about o.scope instead of scope(o)? Also, this would allow   
>> contract-like syntax:
>> void foo (myObject o, int* i)
>>   if (o.scope <= i.scope) {
>> ...
>> }
>
> Hum, but can that syntax guarenty a reference to o or i won't escape the  
> current function's scope, like
>
> 	void foo(scope Object o);
>
> ?

No, the syntax was meant to address the more complex problem of specifying  
the concept of scope(o). It also add some flexibility for other  
relationships. As for do not escape, I'm assuming a no_escape type (it  
would behave as a transitive version of final). I dislike reusing the  
scope keyword for this as

void foo(scope Object a) {
     scope Object b = new Object();
     scope Object c = b; // Okay
     scope Object d = a; // Error
}




More information about the Digitalmars-d mailing list