Escape analysis (full scope analysis proposal)

Robert Jacques sandford at jhu.edu
Fri Oct 31 08:02:31 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);
>
> ?
>

Another option is for the default to be escape. i.e. a contract is  
required for an escape to happen

Object o;
void foo(Object a, Object b)
    if(b.scope <= o.scope) {
       o = b; // Okay
       o = a; // Error
}




More information about the Digitalmars-d mailing list