[D2] How to not full closure?

davidl davidl at 126.com
Sun Jul 13 19:39:58 PDT 2008


在 Mon, 14 Jul 2008 01:15:26 +0800,Frank Benoit  
<keinfarbton at googlemail.com> 写道:

> On Nov 27 2007 in this NG, there was this thread "How to not full  
> closure?"
> See:  
> http://www.digitalmars.com/d/archives/digitalmars/D/Howto_not_Full_closure_62508.html#N62542
>
> For me, this is still a problem i see in using D2.
> E.g. when i pass a delegate as a search criteria to a containers find  
> function, the triggered heap allocation can destroy all of the  
> performance. Even worse, i cannot manually delete the stack frame.
> Imagine this function is called in a loop!
>
> So this still is a D2 show stopper for me. Delegates are a very  
> important D feature. Full closures remove delegates for performance  
> critical code, without giving an alternative.
>
> Please give this a high priority.
>
>

it's better to introduce a new keyword, closure.

there

on heap:
closure t = {
   // my closure
   return 3;
}

on stack:
delegate t = {
   retirm 3;
}






-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list