r/programming • • Jul 25 '13

CoffeeScript's Scoping is Madness

http://donatstudios.com/CoffeeScript-Madness
207 Upvotes

315 comments sorted by

View all comments

Show parent comment

1

u/didroe Jul 26 '13 edited Jul 26 '13

What you're saying is orthogonal to whether return is implicit. I think the point is that with your example, the intent is clear and is specified solely in that line of code. Where as with return, there's no syntactic difference in the line of code, it's done entirely by position. So it's not obvious which version of a language construct you're asking for. This is even worse when you consider that commenting out a line of code can change the meaning of a seemingly unrelated line of code (commenting out the last line of a function potentially changes the line before's meaning).

Variable scoping seems like a similar issue. With both things, you need to consider a larger scope of code to understand the meaning of something. Whereas other languages could encode that meaning in a more local way. What I find odd (and quite interesting) is that this complexity of understanding comes from the pursuit of simplicity in the syntax. I think it shows that simple syntax does not mean simple semantics, and the two may even be opposed in some situations.