On Saturday, 7 December 2013 at 20:23:29 UTC, Timon Gehr wrote:
On 12/07/2013 07:13 PM, bearophile wrote:
Currently in D you can write:
enum move = (in int dx, in int dy) pure nothrow => Point(X +
dx, Y + dy);
I didn't know you could do that, neat.
It also means you can do it for implicit template, I suppose. You
can't do it for declaring a function, but I suppose it works for
declaring a lambda, and storing it in a enum:
enum moveRight(int DX) = (in int dx) pure nothrow => dx + DX;
IIRC Don said this shouldn't work since the context is not
actually known at compile time.
I only see this being a problem if the lambda actually needs
access to the context.