[D2] How to not full closure?

Bruno Medeiros brunodomedeiros+spam at com.gmail
Sun Jul 27 10:37:54 PDT 2008


Jarrett Billingsley wrote:
> "Koroskin Denis" <2korden at gmail.com> wrote in message 
> news:op.ueaoscr8enyajd at proton.creatstudio.intranet...
>> Shouldn't it be heap-allocated by default? I prefer scope keywork reuse :)
> 
> You have a point there.  And I think you may have something with using 
> 'scope' to indicate nested functions whose stack frames are not to be 
> heap-allocated.  It goes along with scope classes nicely.  You wouldn't be 
> able to return a scope delegate, and it makes sense -- "this delegate only 
> works in this scope.  When the scope leaves, the delegate is no longer 
> valid."
> 
> Adding "scope" also makes it possible for the compiler to check that you 
> don't do stupid things statically, at least in many cases. 
> 
> 

I think Walter's solution ("using 'scope' to tag function parameters 
that do not escape") may be even better. It doesn't add new syntax to 
literals, is statically verifiable more "locally", and may have other 
uses other than for delegates.

-- 
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list