weird behavior returning delegate

Bruno Medeiros brunodomedeirosATgmail at SPAM.com
Mon Jul 3 03:16:31 PDT 2006


Chris Nicholson-Sauls wrote:
> 
> If in delegate literals we could declare static variables initialized 
> from the local frame, then it could even have simply been this:
> 
> # T delegate (T) foo (T) (T n) {
> #   return (T i) {
> #     static T x  = n ;
> #     return   x += i ;
> #   };
> # }
> 
> Alas.
> 
> -- Chris Nicholson-Sauls

Nope, even if the static variable were to be initialized at delegate 
literal evaluation time, instead of delegate run time, it wouldn't work 
as there is only one delegate "body instance", so each accumulator would 
share the same static var.

-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list