-
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
Editorial: make record objects non exotic (alternative) #359
Conversation
…onal [[RecordData]] slot
Aw :( the other PR was a lot simpler, and people seemed enthusiastic about it in committee. Can you say more about why you went with this more complex design? |
Hey @bakkot ! In terms of more complexity. Compared to #357, the difference is:
Comparing this to existing primitive types, e.g.
So the only major difference between record objects and boolean objects is the one line in In terms of why this PR was merged. Primarily because it was editorial while still benefiting from the spec simplification demonstrated by #357. Secondarily, because @ljharb was keen for us to retain the implicit type coercion when people use |
To my mind the major difference between this PR and #357 is that this PR includes an additional kind of object, "boxed records", which are observably different from normal objects. I don't think it's worth having an additional kind of object just to make |
This is an alternative PR to #357. They both change the spec so that the object returned by
ToObject(recordPrimitive)
is ordinary.The difference in this PR is the object retains the additional
[[RecordData]]
slot, so thatToPrimitive
andObject.prototype.toString
can detect this branding and have bespoke behavior. This PR also retains theRecord.recordValue
API as a way to infallibly check for the presence of this slot. This makes this change editorial, we keep all the same observable outcomes of the current spec, but reduce the amount of spectext required to express it. This should also make it clearer that interacting with records via their object-methods is exactly the same as working withObject.freeze({__proto__: null})
objects.