-
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
Chaining functions using operator #1251
Comments
resembles piping and doesn't clash bitwise shift |
@dvv: though, it clashes with the even more common bitwise OR |
@werg: I don't like it. $("#something") .height(144) .children() .addClass("something-else") .animate width: 40 What's wrong with this? |
@michaelficarra: ... it clashes with the even more common bitwise OR which could be consistently ( |
@dvv: Gross. Also, CS doesn't drop |
Any reason for that? |
@dvv: Yeah, some people like using those operators. They're familiar from (pretty much all) other languages. And it helps smooth out the CS learning curve. We don't force people to use |
Very well. Any new thoughts on sugaring callback-style chaining? Whether it's considered feasible to have such in CS at all? |
Yes -- this is a duplicate of an old ticket / branch of CoffeeScript ... never merged to mainline because piped operators are strictly speaking less powerful than both regular function calls, and method chaining style -- being only able to pass a single argument. |
I must have failed to pose the question, or can't parse the answer -- I don't mean sugaring chaining style for vanilla sync case which is pretty sweet already. What do you think? |
How hard would it be to ad another operator like I just had the idea that including a directional operator would make long chains with an assigned result value more clear in some situations, as in:
|
Never meant to pretend it's brand new idea -- just asked what's new in this field. Thanks for retrospective analysis. I guess nothing new since then. |
Here's another idea for how to make function call chains more beautiful:
would compile to:
Now that was my initial idea, obviously it would conflict with the bitwise shift operator. I personally would gladly sacrifice bitwise shift (or give it a different operator), but not sure how popular that would be. Alternatively can somebody think of another operator that could unambiguously be used for this task?
Ideally one could continue in a new line as in the example above, but as far as I know this only works if the operator is in the preceding line?
The text was updated successfully, but these errors were encountered: