-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional curlies around objects as method parameters #30
Comments
Right, that's the problem -- it's already valid CoffeeScript. Aspects of this have been addressed in: The problem with having things look like named arguments is that they're not, really. Instead of getting them as optional local variables within the function, you have to look inside of the options hash. I think that this is an important distinction to have, especially because there's no reason why CoffeeScript couldn't support real named arguments (if the ambiguity with the assignment syntax can be worked out). |
TBH - I think it's best to avoid thing like this as it makes the model harder to understand. One of the nice things about Javascript is that there aren't too many rules about it's syntax. |
You're both right, I'll close this issue. Missed the closed issue, sorry. BTW: holy crap! splats! That's so awesome, CoffeeScript rocks! |
It's all good. It's great to have this stuff on record, so people can read through the discussion. If you're looking to see what the limits of the syntax are, I'd recommend reading through the scripts in tests/fixtures/execution. That's the bulk of the current test suite -- each test should only compile lintlessly, and only ever print "true". |
I really like Ruby's way of making the curlies optional when passing a hash as the last argument to a function:
It makes it look like named arguments. Is it possible to do the same in CoffeeScript?
Currently, this compiles to:
So the second example is valid Coffee, and compiles into an assignment. My suggestion is to make the second one compile to the same code as the first one.
Seems to me like this would be pretty hard on the parser and potentially introduce some confusion, so I'm not sure this is worth it at all, what do you think?
The text was updated successfully, but these errors were encountered: