-
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
syntax to allow optional parentheses for no-argument functions #1412
Comments
You mean like |
Similar, but not the same. For example: Basically, the colon syntax would allow for easy chaining without parentheses: |
Okay, re-opening for discussion. |
hmm, interesting. I like/love the ability to ditch the parens, but if consistency is important, I dunno if this accomplishes that.
|
@sstephenson
|
I agree with the conclusion to that ticket, too -- just wanted to point out the prior discussion. |
@arbales True, although your example could be rewritten this way:
etc. I guess my point here was more that you could write code with an internally consistent style if you wanted to, rather than enforcing a style across the entire language. If you want to keep using the parens, you could. The inconsistency of the current parens-less style is really the only thing that bothers me about Coffeescript at this point -- other than that, it feels perfect for my needs. Right now it just feels like switching from curly-braces-on-the-right to curly-braces-below every third function call, depending on whether the function takes an argument. |
Yep -- I think that this one is a re-hash of #514 (and more) with different syntax. The same arguments still apply in the same way. If you value consistency above being able to write:
... please feel free to always use parentheses.
|
I love that we can get rid of parentheses for functions with arguments -- but it feels a little inconsistent to write things like:
barista.prepare cup.coffee
...And then follow it up with:
`````` barista.frown()```
Ruby manages to have optional parentheses for everything by using special characters for instance variables (@, @@, $) to differentiate them from method calls. It'd be awkward/terrible to do the same in CoffeeScript for like a million reasons, but what about other syntactical ways to distinguish between function invocation and variable access? For example:
barista:prepare cup.coffee
barista:smile
Variables here are accessed via dot syntax; functions get called via colons. To access a function as a variable, you could write it in the regular way:
prepare = barista.prepare
The calling notation could work similarly for standalone function calls:
:prepare cup.coffee
:drink_all_cups
The text was updated successfully, but these errors were encountered: