I disagree. The rule that implicit parentheses (generally) follow, is that they extend to the end of the line, or to the end of the block that ends the line. To riff on your examples, it allows for uses like this:
print message or defaultMessage
bank.deposit currentBalance + incomingCheck
... and if you need tighter binding, you simply write the parens:
total = bank.lookup("checking") + bank.lookup("savings")
This is not possible now in CoffeeScript
Oh, but it is ;) If you don't mind the new line, block strings gobble-up all of the left-hand indentation for you: http://coffeescript.org/#strings
The thing I sometimes run into in CS is that defining a lambda as the first argument of a function when there are more than one argument does only work if you put the thing in brackets:
The rule that implicit parentheses (generally) follow, is that they extend to the end of the line, or to the end of the block that ends the line.
Hmm, good point. However, that encourages what I see as 'floating arguments'. Extending to the end of the line is a good idea if it doesn't meet an operator, like the example on the front page:
console.log sys.inspect object
Furthermore, I think it would be good to encourage wrapping a long argument with operators in parenthesis.
If you don't mind the new line
That's the problem :)
A common example is a long URL which are sensitive to new lines, extra spaces, etc. I think the current implementation of double quoted, multiline strings is very limited as it only works properly in the outermost scope, otherwise it doesn't respect indentation, making the code look out of place (and interfering with Vim's folding ;) ).
Is there a way to disable implicit parenthese entirely? I like a lot of what's in CoffeeScript but that class of behaviour has lead to bugs, usually subtle, in every language where I've encountered it.
View all comments
Show parent comment
5
u/jashkenas Jul 26 '13
I disagree. The rule that implicit parentheses (generally) follow, is that they extend to the end of the line, or to the end of the block that ends the line. To riff on your examples, it allows for uses like this:
... and if you need tighter binding, you simply write the parens:
Oh, but it is ;) If you don't mind the new line, block strings gobble-up all of the left-hand indentation for you: http://coffeescript.org/#strings