-
Notifications
You must be signed in to change notification settings - Fork 62
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
Holes in Tuples #84
Comments
I'd suggest that we not support holes in tuples, but we permit this syntax, with the interpretation that this is syntax sugar for making the element |
I heavily lean towards not allowing holes at all (but would be fine with the syntax sugar for |
Not per se, but I didn't recall seeing it in README.md and wasn't sure how it was planned to be modeled. It sounds like there's a lot of concensus around "allow the syntax, but don't allow holes". Would you be interested in taking it a step further and saying that element access never traverses the prototype for records (even if accessing an element beyond the length of the tuple)? |
Any element access on a non nullish primitive boxes to an object first, so that would also mean the object form had that behavior. |
@ljharb yes, that's what we are talking about. Clearly Record and Tuple wrappers are exotic objects, just like String wrappers. I don't see how this is relevant to the discussion. |
It wasn't clear to me that that was clear in the thread, so I was confirming/clarifying. |
I think holes should be forbidden and also syntactically prevented. I don't see a good reason to allow the syntax but give it semantics which are extremely subtly different; holes are confusing enough already. Note that the most relevant difference between holes and explicit Better that |
I disagree — I would rather have the consistency of the undefined shorthand working for both, than consistency with fiddly |
It is not a shorthand for |
It’s a very closely related, mostly the same, horrifying thing. It’s horrifying in its nearly-sameness. |
I know we have had some people ask about if the prototype should be |
I think the [[Prototype]] of Record.prototype and Tuple.prototype could certainly be |
This comment has been minimized.
This comment has been minimized.
@bakkot gave some pretty convincing arguments above for banning holes in Tuple literals. Can we conclude on his proposal and prohibit these syntactically (as an "early error" I imagine)? |
@littledan I do not believe my comment was off topic as it does have a position on how this specific issue could be avoided. Discussing if this issue is something that needs to be addressed is intertwined with other issues and removing the ability to cross reference issues seems a bit much. |
@bmeck OK, I un-hid them. I do want to be careful about repeating arguments across different threads, though; we have a tendency to do that. |
I agree with @bakkot/@littledan that allowing the syntax as a shorthand for undefined introduces a sharp edge (imo) around things like |
As happened with arrays, this syntax could be added on later if folks want to push it separately, right? If so then I'm fine with that. |
Yes I believe that making it a syntax error now would allow us to add the shorthand in the future if so desired. |
I started drafting spec text. The current grammar being drafted will not even allow holes so it will yield a syntax error |
Will it allow for trailing commas though? |
Current grammar allows trailing commas |
Thank you for the clarification |
Obviously, |
Yes, you're still using the same destructuring syntax, there is no special-casing here because of the tuple |
I'm wondering if Holes, in the sense of
#[ , , , ]
would be allowed in Tuples or forbidden, and if a Hole is allowed, does loading from a hole always evaluate to undefined, or does it result in loading elements from higher up in the prototype?The text was updated successfully, but these errors were encountered: