3 ms·
Not 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 y
by jashkenas 13y ago
Not 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.