Has anyone ever considered adding support for the => shorthand lambda operator to Pike?
It's available in several languages. The docs for C# are here: https://msdn.microsoft.com/en-us/library/bb397687(v=vs.110).aspx
Might conflict with casts (which are also expressions starting with "(" followed by a a type), but I think they should be possible to distinguish in LR1. Allowing the parenthesis to be removed when there is exactly one parameter doesn't really sound that useful, so I suggest not adopting that part.
Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum wrote:
distinguish in LR1. Allowing the parenthesis to be removed when there is exactly one parameter doesn't really sound that useful, so I suggest not adopting that part.
I think I agree with that. Since we need types, it would get cluttered anyway, so making the parenthesis mandatory helps maintain easy visibilty.
Do we need types always ? I'm fine with "x=>x*x" and "lambda(mixed x) { return x*x; }" equality.
If you want x to be mixed, you should declare it as such. That is the rule everywhere else.
Excerpts from Stephen R. van den Berg's message of 2015-03-14 10:45:22 +0100:
Has anyone ever considered adding support for the => shorthand lambda operator to Pike?
It's available in several languages. The docs for C# are here: https://msdn.microsoft.com/en-us/library/bb397687(v=vs.110).aspx
there is also the block syntax from smalltalk and ruby: [ mixed arguments | code; ] { mixed arguments | code; }
i am not sure if there is really a big advantage of using (mixed arguments) => { code; } over lambda(mixed arguments){ code; }
how does it help with readability?
greetings, martin.
pike-devel@lists.lysator.liu.se