-
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
Add a function syntax which does not return the value of last expression #1855
Comments
Just wondering, why do you care about return values that are unused? Performance of implicit comprehensions? And what's so hard about appending a |
I should have searched first, sorry about that. I guess my reasons are mostly of esthetic kind (and I use coffeescript because of its beautiful syntax):
|
But that doesn't answer my first question. What's wrong with the implicit return? Why must you return |
Because sometimes I need to send the compiled js file to someone who doesn't know coffeescript. For example, if it were unit testing code, which has many assertions in each test. Each last assertion will be appended with A jasmine example:
which gets compiled to
|
Ah, okay. Thanks. |
I feel like it's kind of a rough spot in the syntax. The syntax is 'just pay attention to indents to see where functions are ending'. Except when you don't want to return anything, you have to put this 'return' at the end. But many functions don't do anything, especially in the web world where most functions are click handlers that aren't returning anything. So it's non intuitive to me, could be because I'm coming from c#. I'm just saying the majority of functions that I write don't return anything so adding in the return is awkward. The alternative is to return something (often a function like $('#theDiv').click etc) that doesn't have any meaning to the function calling it. Really it looks like a style thing to me. I see the argument for both sides but the C# in my history makes me want returns to be explicit. |
Can we have something like this:
Which will compile into:
Having to put a standalone
null
orundefined
at the bottom of a function if it doesn't need to return anything doesn't look quite good.I choose "-|>" and "=|>" because the pipe looks like being "blocking" the function from returning, but the actual tokens are not important. They can be anything you like.
The text was updated successfully, but these errors were encountered: