-
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
Chain method calls omitting parentheses #3398
Comments
+1 On Thu, Mar 6, 2014 at 1:27 PM, Tom Wieland notifications@github.comwrote:
|
Nice idea, but...
Because then it reads poorly, as you've demonstrated. |
No way! Coco and LiveScript have this, and I love the improved consistency. |
I, too, like it a lot in Coco/LS. |
I'd say myMethod(1, 2, 3).otherMethod 4, 5, 6 looks worse. |
Reopened for discussion, but... The original notion with Thus:
... would chain tightly against the immediately preceding token. We've now stepped away from that original design with the 1.7.0 syntax change (which I'm iffy on, for that reason). But continuing further seems quite unwise — and massively backwards incompatible to boot. |
I really think |
Good idea but it a poor style so maybe it would be a better idea to use another character than a dot for calling functions at the same object multiple times. For example, if I use myMethod 1, 2, 3
:anotherMethod 2, 3
:yetAnotherMethod 4, 5 instead of myMethod 1, 2, 3
.anotherMethod 2, 3
myMethod 1, 2, 3
.yetAnotherMethod 4, 5 EDIT: Add code examples |
This is a duplicate of still open #1495, with a lot of argumentation for and against (I'd move it there so we don't repeat ourselves). I am with @jashkenas on this one, at least until the current change has been proven and tested. I think it crosses the boundary to LS land with |
+1 whitespace is very significant in coffee and the inline option should be available to those who like it. not making it work seems to overstretch the I-don't-like-it-argument |
If someone wants to submit a PR for this, it would be considered. However there are many open issues with chaining/leading periods, so those would need to be fixed first. |
Hi.
I often stumble over scenario's where I have some code that calls a method with more then one argument and need to chain a call after it;
With the 1.7.0 syntax changes, this means I could write it as;
Why not also allow the syntax to live on one line?
With the current syntax, it means I should add a lot of parentheses or restructure the code vertically, which is not that nice if the arguments and method names are small and there's several invocations and I'd argue that this:
looks way better then this:
and I'd argue that the space before the dot makes the meaning unambiguous (not belonging to the last argument of the previous method but the return of that call).
gr,
Tom
The text was updated successfully, but these errors were encountered: