gkz / LiveScript

LiveScript is a language which compiles to JavaScript. It has a straightforward mapping to JavaScript and allows you to write expressive code devoid of repetitive boilerplate. While LiveScript adds many features to assist in functional style programming, it also has many improvements for object oriented and imperative programming.
http://livescript.net
MIT License
2.32k stars 155 forks source link

Make parenthesis optional on lambdas #1056

Closed danielo515 closed 6 years ago

danielo515 commented 6 years ago

There was a time when lambda on livescript were much more succinct than on javascript. That is no longer the case :

(A, B) => A+B
(a, b) -> a + b

In the case of curried functions javascript is even shorter

A => B  => A+B
(a) - > (b) -> a + b

I was wondering how hard would be to make parentheses optional on function declarations, at the end you must add an equals sign before and am arow after

rhendric commented 6 years ago

Sorry, I don't think removing the parameter parentheses can work in LiveScript, because a -> b is already an expression that means a(function () { return b; }). Changing that would break a lot of code.

danielo515 commented 6 years ago

What if you do only for function declarations ?

rhendric commented 6 years ago

f = a -> b has the same problem; it already means f = a(function () { return b; }). For named function declarations, the parentheses are already optional.