Full closures for D

Jarrett Billingsley kb3ctd2 at yahoo.com
Fri Nov 2 17:38:50 PDT 2007


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:fggfqq$sh5$1 at digitalmars.com...
> How do D closures work?
>
> 1) The compiler makes a distinction between a nested function that 
> 'escapes' the scope, and one that does not. It uses a very simple, but 
> conservative, heuristic - did someone take the address of the function? If 
> yes, it assumes the function escapes.
>
> It's not an optimal solution because the "does the function escape" 
> heuristic captures too many functions.

Indeed.. of course there might not be any other way to really check it..

One source of false positives is the @#*(%@# restriction where you can't 
forward reference nested functions, and instead have to put their addresses 
in local delegates.  Get rid of that, and there's one problem gone.. 





More information about the Digitalmars-d mailing list