Skip to content

[CS2] Spread syntax triple dots on either right or left #4606

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

Merged
merged 2 commits into from
Jul 9, 2017

Conversation

zdenko
Copy link
Collaborator

@zdenko zdenko commented Jul 7, 2017

See #85.

{a, b, r...} = {a:1, b:2}
{a, b, ...r} = {a:1, b:2}

o = {obj1..., a:1, ...obj2}
a = [a, b, arr1..., c, d, ...arr2]

f args...
f ...args

({a, r...}) ->
({a, ...r}) ->

@GeoffreyBooth
Copy link
Collaborator

Very clean. Looks good to me. @lydell? @connec?

@GeoffreyBooth GeoffreyBooth added this to the 2.0.0 milestone Jul 7, 2017
@lydell
Copy link
Collaborator

lydell commented Jul 7, 2017

LGTM

if (tag in IMPLICIT_FUNC and token.spaced or
tag is '?' and i > 0 and not tokens[i - 1].spaced) and
(nextTag in IMPLICIT_CALL or
(nextTag in [IMPLICIT_CALL..., '...'] or
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a nitpick but... this could be nextTag in IMPLICIT_CALL or nextTag is '...' and would probably be a bit cheaper and, I think, more readable (assuming we can't simply add ... to IMPLICIT_CALL).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, looks like it’s much cheaper: https://jsperf.com/in-spread-array-vs-two-comparisons/1

@connec
Copy link
Collaborator

connec commented Jul 7, 2017

I'm still not entirely convinced it's a good idea 😛 but apart from a small nitpick it LGTM.

What's our strategy going to be for documenting this?

@GeoffreyBooth
Copy link
Collaborator

What’s our strategy going to be for documenting this?

Tiny note in the changelog, and nothing else 😉

@GeoffreyBooth GeoffreyBooth merged commit 3be9038 into jashkenas:2 Jul 9, 2017
@GeoffreyBooth GeoffreyBooth changed the title Spread syntax triple dots on either right or left [CS2] Spread syntax triple dots on either right or left Jul 9, 2017
@GeoffreyBooth GeoffreyBooth deleted the spread-dots-both-sides branch July 9, 2017 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants