Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upWhy allow BindingPattern for BindingRestParameter #915
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
saambarati
May 12, 2017
An example of JS that expresses why I think this is crazy:
Object.prototype[Symbol.iterator] = function() { console.log('foo'); return {next: function() { console.log('baz'); return {done:true}}}}
let {...[baz]} = {foo:20}
saambarati
commented
May 12, 2017
|
An example of JS that expresses why I think this is crazy:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@anba has raised a similar point here: tc39/proposal-object-rest-spread#43 |
saambarati
referenced this issue
May 12, 2017
Open
Should we forbid array patterns for rest-properties? #43
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
caiolima
May 15, 2017
I don't think it's a good idea since we will not be consistent with Array Rest spec that allows recursively rest operations. IMHO it could bring confusion against intuitive usage of rest operations.
BTW, I think it's a good idea discuss this topic into tc39/proposal-object-rest-spread#43 since it is not part of spec yet.
caiolima
commented
May 15, 2017
|
I don't think it's a good idea since we will not be consistent with Array Rest spec that allows recursively rest operations. IMHO it could bring confusion against intuitive usage of rest operations. BTW, I think it's a good idea discuss this topic into tc39/proposal-object-rest-spread#43 since it is not part of spec yet. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
peey
May 31, 2017
Do note the functional differences between let {...{a}} = expr and let {a} = expr
The first example would only set a only if a is expr's own property, but the second example is equivalent to a = expr.a.
Though it does get redundant after one level of nesting, I don't see much point in let {...{...{a}}} = expr
peey
commented
May 31, 2017
|
Do note the functional differences between The first example would only set a only if a is expr's own property, but the second example is equivalent to Though it does get redundant after one level of nesting, I don't see much point in |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
saambarati
May 31, 2017
What do you mean by “only set a”? “a” will end up as not TDZ after both statements execute.
(FWIW, I understand there are other semantic differences in other ways to. Performing GetOwnPropertyNames is observable.)
Having a semantic difference isn’t a good enough reason to be in the language.
saambarati
commented
May 31, 2017
|
What do you mean by “only set a”? “a” will end up as not TDZ after both statements execute. (FWIW, I understand there are other semantic differences in other ways to. Performing GetOwnPropertyNames is observable.) Having a semantic difference isn’t a good enough reason to be in the language. |
saambarati commentedMay 12, 2017
I'm looking at this spec text:
https://tc39.github.io/proposal-object-rest-spread/#Rest
and
https://tc39.github.io/proposal-object-rest-spread/#Rest-RuntimeSemantics-RestBindingInitialization
Why not only allow an identifier for rest?
For example, I think this code is too difficult to understand (and has little real world value):
What does this even do? Not what I would've expected it to.
I think I finally understand that it's something like this (with a lot of hand waiving):