5 ms·
The syntax is broken. Things like operator precedence and associativity are the exact opposite of math conventions: f x + f y // is f(x + f(y)) f g
by throwaway_yy2Di 13y ago
The syntax is broken. Things like operator precedence and associativity are the exact opposite of math conventions:
f x + f y // is f(x + f(y))
f g x // is f(g(x))
- omni 13y agoI don't understand what's wrong with the second example. What do you think it should do?
- throwaway_yy2Di 13y agoIn ML-family languages like OCaml and Haskell, function application is left-associative: f g x = (f g)(x).
- jashkenas 13y agoNot quite -- the rule is pretty simple: Implicit function calls associate to the right, to the end of the line (or the end of the trailing block). This allows you to write code like this: console.log inspect value model.save(attrs).then -> ui.update attrs rect.scale height * factor ... and have all of the results come out correctly, while leaving the code readable. If the rules were "more math-like" as you say, then none of that would work. Perhaps it would harmonize with special libraries that used functions (automatic-partial-application a-la Haskell) in a different way than JavaScript does ... but that's not the world we live in. It's gotta harmonize with JS functions as they exist.
- throwaway_yy2Di 13y agoMy brain isn't plastic enough to make this switch. :( For me, those code examples are uncomfortable to look at. backwards read to trying like It's
- jashkenas 13y agoRight-o. The trick is to "read" it like pseudocode, or like English-ish. Log the inspected value. Save the model, then Update the UI with the attributes. Scale the rectangle by (the height times the factor). The big syntactic difference still being the "model.save" vs "save the model" ordering of dot-notation. But them's the breaks.
- deleted 13y ago[deleted]
- aaronem 13y agoI'm not sure where the idea originated that readability scales inversely with the number of parentheses, but I wish it would hurry up and die.