Skip to content
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

Reform operator spread #863

Merged
merged 4 commits into from Mar 15, 2016
Merged

Reform operator spread #863

merged 4 commits into from Mar 15, 2016

Conversation

@rhendric
Copy link
Collaborator

@rhendric rhendric commented Feb 27, 2016

Per conversation in #831, these commits make breaking changes to operator spreading.

  • Operator spreading now requires a splat: typeof ...[0] => [typeof 0]
  • Operator spreading now supports objects: typeof ...{a: 0} => {a: typeof 0}
  • The LHS of assignment operators can also be spread: ++...a{b, c} can be written as ...a{b, c} += 1

foo ...+...a<[b c]> => foo.apply(null, [+a['b'], +a['c']]) works.
(...a=b) -> never really worked (an array, even empty, will never be nullish) but is now an explicit error.

Close #831

rhendric added 4 commits Feb 27, 2016
Prior to this commit, unary operator spreading happened implicitly,
leading to surprises like typeof [] != typeof [0] (== [typeof 0]).

With this commit, a splat is required prior to the array being spread
over: typeof ...[0] == [typeof 0]. Implicit operator spreading is no
longer handled; typeof [0] is just typeof [0].
This enables ...[a, b] += 1 to have the same meaning as ++..[a, b].
@vendethiel
Copy link
Contributor

@vendethiel vendethiel commented Feb 27, 2016

That looks good! It might take me a few days before I can actually review it though.
I'd gladly hear anyone's opinions on this PR. Especially if someone happens to find a case where syntaxes conflict :).

I might also want to add a few more tests. It's a pretty big change.

When merged, I'll also create an issue to track the docs state about this.

@vendethiel vendethiel mentioned this pull request Mar 2, 2016
0 of 8 tasks complete
@isiahmeadows
Copy link
Contributor

@isiahmeadows isiahmeadows commented Mar 3, 2016

I like the DRY aspect of this. And I can't think of any way this could currently conflict with standard argument spreading. And +1 for making odd edge cases explicit errors.

vendethiel added a commit that referenced this pull request Mar 15, 2016
Reform operator spread
@vendethiel vendethiel merged commit 18e3e72 into gkz:master Mar 15, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@vendethiel
Copy link
Contributor

@vendethiel vendethiel commented Mar 15, 2016

Seems like no one objected, so I'm just gonna merge it :). Thanks.

@rhendric rhendric mentioned this pull request May 17, 2017
This was referenced Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants