-
Notifications
You must be signed in to change notification settings - Fork 156
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
Support unary operator spread over object literals #831
Conversation
Works exactly like unary spread over list literals. As written, only a subset of unary operators are supported, but this is easily amended.
At that point, I think I'd prefer if there were an operator to trigger it. |
For object literals/slices only (inconsistent) or for list literals/slices also (breaking)? FWIW, Do we really want to live in a world where |
The breaking one. |
Hmm. How about if we marked the literal/slice to spread over with a splat?
Extend to assignment operators? |
I'd say it looks consistent with what spread does -- but not sure how to parse it OTTOMH |
The parsing doesn't appear to be a problem; I bashed out a quick proof-of-concept. Is this proposal baked enough for me to harden the implementation into a new PR? Should I leave support for existing spread syntax intact, add a deprecation warning, or just remove it? |
Well, that's where I'd have liked @gkz's input. I guess we can start to consider master to be LS2's head (maybe I'll create an actual LS2 dev branch later), so what I'd like to do before merging is just... Ask people! If you could please post a message with a note of such a change in the LS2 threads. I hope we won't find any place where that's ambiguous (shouldn't be) |
@vendethiel I see a branch prime for a push. The readme can be updated and posted on the new, replaced README. It only has one commit. |
No, not that branch. If anything, it should be deleted and recreated from current master. |
@rhendric I'm gonna go ahead and say "let's go for the explicit spread syntax". So long |
Works almost exactly like unary spread over list literals/slices, but with that tasty object flavor.
I was originally going to support all unary operators, but then had a crisis of conscience when I looked at
^^{foo, bar}
and asked whether that ought to be equivalent tox = {foo, bar}; ^^x
or{^^foo, ^^bar}
, or whether someone would freak out iftypeof {} != typeof {foo:1}
(although both of these issues exist with list spreads right now, so...). The somewhat arbitrary list of operators I decided to support is~
!
/not
new
do
delete
/delete!
++
--
, but I'm not terribly attached to most of those decisions. The two examples demonstrated above are the ones I want to use.Feedback please!