|
|
|
|
|
by ulrikrasmussen
1739 days ago
|
|
I agree, but lambdas do not really have a canonical syntax in the same way that braces have become synonymous with delimiters for statement blocks. This particular syntax comes from Haskell, where e.g. \x -> f x
denotes an anonymous function that applies its first argument to `f`.But I have seen at least these forms in other languages of varying popularity: [x] f x
|x| f x
{ f(it) }
{ x -> f(x) }
fn x => f x
function(x) { return f(x); }
x -> f(x)
(x: A) => f(x)
In other words, I think it is really hard to pick a syntax for this construct that every programmer is going to feel familiar with, especially if your language is supposed to cater both to programmers coming from FP and more traditional languages.Edit: Fixed error in JS example; added Java and Scala. |
|
Imagine if i wrote a conditional like that:
as It completely erases the usefulness of {}, and is cursed, cursed I say! And I’m looking at you, rust, swift, ruby, etc.