-
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
adding ? and ! to methods #48
Comments
in a sense, it might not clash. You could argue that
and
Are pretty consistent. They both ask the same type of question, only the latter is more specified. The one problem I have with this, though, is what is the value of the expression
If exists isn't a function? Lastly, I personally find ! to be more useful semantically than ?, so ! could be incorporated by NOT ?; that might be an option. |
I think it would be least confusing to have a separate operator, my vote goes with |
I use ! and ? quite alot in ruby, as I find it useful semantically. I.e. potentially unsafe operations can be tagged with ! and questions with? It would be entirely an opt in feature - if you don't like the style, don't use it. On the other point converting my_var? to myvar_question_mark is hardly name mangling. |
This feature request has the same problem as symbols: there is no direct mapping to JS. The direct mapping to JS is what makes Coffee so great, and as soon as you have to start mapping to alternative names, you end up with annoying behavior. e.g., if a library uses lowerCamelCase, the method name foo? should be renamed to something like isFoo. If, however, Coffee makes the assumption of lower_underscored, you end up with naming clashes in the generated code. Not pretty. In my opinion, not worth the loss of clean JS portability. |
Yep. What noonat says is absolutely right. We can't start fiddling with identifiers. Documentation for CoffeeScript libraries should be usable by JavaScript developers and vice-versa. No translation required. If we step away from that, we take a major step away from being a viable alternative way to write solid JavaScript libraries. Closing the ticket... |
It's incredibly useful in Ruby to be able to end methods with ? and ! We could rewrite the variable names to include these as text. E.g.
compiles to
I realize that there's a clash with the existence operator here -- but it would be really useful and we could come up with another operator for existence e.g.
if ?obj
orif obj??
The text was updated successfully, but these errors were encountered: