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

Conversation

Projects
None yet
3 participants
@rhendric
Collaborator

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 some commits Feb 27, 2016

change unary operator spread syntax
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].
support spreading with assignment operators
This enables ...[a, b] += 1 to have the same meaning as ++..[a, b].
@vendethiel

This comment has been minimized.

Contributor

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 referenced this pull request Mar 2, 2016

Closed

So-called "next big version" #811

0 of 8 tasks complete
@isiahmeadows

This comment has been minimized.

Contributor

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

@vendethiel vendethiel merged commit 18e3e72 into gkz:master Mar 15, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@vendethiel

This comment has been minimized.

Contributor

vendethiel commented Mar 15, 2016

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

@rhendric rhendric referenced this pull request May 17, 2017

Closed

Idea: Improve typeof #178

This was referenced Jan 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment