Delegate is left with a destroyed stack object

Peter Alexander peter.alexander.au at gmail.com
Thu Oct 31 13:56:09 PDT 2013


On Thursday, 31 October 2013 at 07:41:30 UTC, Jacob Carlborg 
wrote:
> On 2013-10-30 21:35, Peter Alexander wrote:
>
>> I think not running the destructor is the best option 
>> (although to be
>> honest, I'm not a huge fan of closures to begin with, for 
>> exactly these
>> sorts of reasons -- they only really work well in a pure 
>> functional
>> setting).
>
> I use Ruby all day with a lot of blocks (closures) and I never 
> had any problem. In Ruby everything is an object and passed 
> around by reference. I guess that's help.
>
> BTW, the default iteration pattern in Ruby is to use blocks:
>
> [1, 2, 3].each { |e| puts e }
>
> Closest translation in D:
>
> [1, 2, 3].each!(e => writeln(e));
>
> But in D one would of course use a foreach loop instead.

Those aren't closures, it captures none of the environment. Those 
are just simple lambda functions.


More information about the Digitalmars-d mailing list