[D2] How to not full closure?
Sean Kelly
sean at invisibleduck.org
Sun Jul 27 11:51:55 PDT 2008
== Quote from Bruno Medeiros (brunodomedeiros+spam at com.gmail)'s article
> 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.
Tagging the stuff that doesn't escape isn't backwards-compatible with
D 1.0, where non-escaping is the default. Not that we don't already
have some pointless portability issues from D 1.0 to D 2.0, but I'd
think it would be desirable to not add more.
Sean
More information about the Digitalmars-d
mailing list