d future or plans for d3
    Froglegs 
    lugtug at gmail.com
       
    Tue Dec 20 03:56:41 PST 2011
    
    
  
> C++ "closures" do not allow you to maintain a reference to the 
> context after the function containing said context returns. 
> Instead, C++ allows you to choose between copying the variables 
> into the lambda instance, or referencing them (the references 
> may not "escape"). The compiler may or may not enforce correct 
> uses of reference captures. In contrast, D's approach is both 
> intuitive (does not copy variables) and safe (conservatively 
> allocates on the heap), with the downside of requiring the 
> context to be garbage-collected.
Ah, makes sense now, thanks.
Still it seems like a case of "you pay for what you don't use", 
and seems like a real downer for adopting D since you loose the 
ability to use lambda's without having the GC shoved down your 
throat(wouldn't be so bad if the D GC was known for performance, 
but everything I've read indicates it is quite slow).
    
    
More information about the Digitalmars-d
mailing list