== Quote from Andrei Alexandrescu ([email protected])'s
> Lest a misunderstanding arises, the code:
> auto r = map!((float a) { return fabs(a); })(a);
> does *not* involve a delegate; it's still a direct call. This code
> doesn't currently compile because of a bug in the compiler, but this
> equivalent code does:
> float fun(float a) { return fabs(a); }
> auto r = map!(fun)(a);
> and again it does not involve a delegate.

But, for the truly performance obsessed, it's still a non-static nested function
that doesn't access any local variables in the outer scope.  Isn't it still 
taking
a pointer to the outer scope as an implicit argument, kind of like a this 
pointer,
or are real-world compilers sufficiently smart to optimize that out if you never
use any of the variables in the outer scope?

Yes, I know this is nitpicking, but I'm asking primarily out of curiosity rather
than out of practical concern.  I also realize that, if you really care that 
much,
you can declare fun() as static and get rid of the implicit pointer to the outer
scope.  This is kind of ugly, but I guess code that's this micro-optimized is
going to be ugly any way you cut it.

Reply via email to