I've heard there is going to be a new syntax in DMD 2.058 for anonymous functions, but I can't find any information on it. What is the new syntax, and is the old syntax going to be deprecated?
I believe it's like C#'s.
The following are equivalent:
delegate(i, j) { return i + j; }
(i, j) => i + j
as are:
delegate(i) { return i; }
(i) => i
i => i // Can leave off parentheses
as are:
delegate(int i) { return i; }
(int i) => i
though I'm not sure whether explicit return types are also supported in the new syntax.
No current lambda functionality is being removed. It's just that a new, terser syntax is being introduced for those who want it. As Merhdad says, it's essentially C#'s syntax, though I don't know if it's 100% identical.
So instead of doing something like
auto found = find!((a){return func(a) == value;})(range);
you do something like
auto found = find!(a => func(a) == value)(range);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With