How to use map?

Lemonfiend via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 11 11:24:29 PST 2014


On Tuesday, 11 November 2014 at 15:53:37 UTC, Marc Schütz wrote:
> Don't know whether it's documented, but it's a consequence of 
> using string mixins.
>
> unaryFun (which is used internally by map) is implemented this 
> way:
>
>     auto unaryFun(ElementType)(auto ref ElementType __a)
>     {
>         mixin("alias " ~ parmName ~ " = __a ;");
>         return mixin(fun);
>     }
>
> where `fun` is `Foo(a)`. Of course, `Foo` is not visible in 
> std.functional. When you pass in a symbol, the lookup work 
> because it takes place at the point of instantiation.

That makes sense, thanks.


More information about the Digitalmars-d-learn mailing list