-
Notifications
You must be signed in to change notification settings - Fork 2k
Destructuring assignment of function-call results #3655
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
this would open up temptations like but then you have a variable named Is it perhaps a bad practice to have a function that returns something and they are both named the same thing? something like this is confusing so the first is the output of a timer and the 2nd is a function that outputs the same named variable? However, it could be useful in this case:
great, but if i know anything about the responses to tickets here its that they don't change coffeescript for much. look into coco or some language that's willing to play fast and loose, which is probably the reason why coffeescript was originally created, but it doesn't seem to innovate much anymore, probably because so many people depend on it and they are sick of hearing flack when changes get made. i've seen good, simple, obvious suggestions that are basically already built into the language and are more bugfixes get rejected. so when this gets rejected don't take it personally, its just a very stagnant front in changing conventions here. I'm trying to be respectful by the way, but, I'm not wrong, this has almost no chance of going into coffeescript. |
There's a substantial difference between a property/getter on an object, and a local variable. In your example, it comes across as fairly obvious, to me, that However, if that's not immediately obvious to everyone else, then … that's a serious problem with my proposal, yes. /= I guess it comes down to whether anybody else reading this finds it equally confusing? I definitely see things like |
@danschumann as for that last paragraph, I'm very aware: #3467, #3033, #3004, #1378 … Doesn't mean I won't keep trying! Takes genitals of steel to participate in open-source projects and deal with universally either egotistical, or exhausted, maintainers. ;) |
This seems to follow the decision to remove dynamic keys. |
@Nami-Doc Huh? Confused, I don't think we're talking about dynamic keys? in i.e. given that,
… I propose,
|
As your humble maintainer that got plenty of sleep last night ... aside from further drifting towards "dynamic keys", which we don't want to do, this proposal is already inconsistent with how destructuring assignment works. The simple version you'd try to write is:
But that doesn't compile, because that means, create a variable named The reverse notation:
... is obviously syntactically invalid. The point of destructuring assignment is to allow you to have a complex JSON structure on both the left and right sides of an assignment. Not to expand the syntax beyond that. The left hand side is supposed to be valid simple CoffeeScript. |
Ah, I never understood that the LHS of destructuring-assignment statements was intended to be JSON-ish. I'll throw in one last hurrah, in that I really don't think adding function-call syntax to that is much more of an extensive change than allowing the omission of the ‘keys’ in the syntax ( That said, I understand the argument against complicating the LHS syntactically. (= |
To riposte your last hurrah — the shorthand for |
{a, b} = c
is excellent when@a
and@b
are static properties; but it'd be very useful to be able to use a similar shorthand with dynamic values implemented as functions.Something of the form:
{a(), b()} = c
, expanding toa
andb
being set in the local scope as the result of calls toc.a()
andc.b()
.Just a thought. ~<3
The text was updated successfully, but these errors were encountered: