-
Notifications
You must be signed in to change notification settings - Fork 2k
Alternative return this #1919
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
Comments
I don't see anything wrong with have an This idea has good intentions, just I have a hard time thinking that it will actually get in. |
Just a simple convenience thing. @arguments got in, which is a similar kind of convenience, so I think this could have a chance. Not really a big deal though. It'd just be a little easier to follow when you have a ton of chainable stuff. |
That's a good point. The biggest reason I think this won't make it is the other "special syntax to make functions always return x" issues I've seen get brutally thrown down. I guess we'll find out soon. |
@tylermwashburn: I'd be happy to be the first to fulfill that prophecy. Huge -1 from me for obvious reasons. |
Yeah, 👎 really. The only special function syntax I really favour is the one using |
|
I would change the function name to returns, but we. |
@michaelficarra That doesn't work to well in object definitions. This edited version works okay, if you only need to support return this;
It's also not especially convenient if your code is split across a whole bunch of files. You have to add the r definition to the top of every file. Not very DRY. >.> |
If you want the sweetest syntactic sugar don't be afraid to extend
Similar to Michael's example:
I don't think we need CoffeeScript to add syntax for things that uninhibited JavaScript already does well. |
I don't know if I'd call that "well", looks pretty janky to me. Not to mention tha'd require setting the context on the calling end, which is super fragile. |
I think I misread the issue. I thought it was about being able to chain functions that may or may not have been written with chaining in mind. You're right that my comment won't be a more elegant form of a dangling |
As you should, since standalone |
Yes, I've seen that before. I still think it's kind of a weird justification. Trying to make this and prototype behave similar seems odd to me, since they are two very different things in the first place. |
If there's no syntax for functions that return nothing (#899), there certainly shouldn't be a syntax for functions that return @michaelficarra I'm still hoping standalone |
@TrevorBurnham You took the words right out of my mouth. Standalone |
+1 on keeping the |
Here's the party line on some of the things mentioned here:
We're not going to add a special function glyph to predetermine the return value of a function -- whether that return value is |
My code has lots of dangling @ symbols to make stuff chainable, I've been wondering if there is perhaps a more elegant way to represent that.
How about rather than this;
we do something like this;
That way you can see right at the start of the definition that it is chainable.
The text was updated successfully, but these errors were encountered: