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.31k stars 156 forks source link

document operator precedence #1094

Open punund opened 4 years ago

punund commented 4 years ago

I understand that tweaking operator precedence now means breaking legacy code.

But I still wish there were a table in the docs with operator precedence and associativity. Certain things, such as that precedence of >> is different from |> and <| regarding function appllication, are not obvious at all.

f a <| b    # f(a)(b)
f a >> b    # f(a >> b)
rhendric commented 4 years ago

There is a partial table of operator precedence here: https://github.com/gkz/LiveScript/blob/bc1c188f01298567bc689c979147829c6ac57213/src/grammar.ls#L460-L487

But it doesn't explain the logic for inserting implicit parentheses, which treats some tokens like <| specially: https://github.com/gkz/LiveScript/blob/bc1c188f01298567bc689c979147829c6ac57213/src/lexer.ls#L1153

I agree, it would be better if all of this were actually in one place in the documentation.