Normative: Use own properties for privateName objects#124
Conversation
|
When writing this patch, I noticed that we were missing some more basic logic: #125 . There's a conflict between these two patches, but it's easily resolvable. |
spec.html
Outdated
|
|
||
| <emu-clause id="sec-private-name-type-and-objects"> | ||
| <h1>PrivateName Objects</h1> | ||
| <h1>privateName Objects</h1> |
There was a problem hiding this comment.
i think this can probably stay capitalized, since they still could have been the result of a constructor (see also, Descriptor objects and Iteration Result objects, and Symbol)
There was a problem hiding this comment.
Yeah, that's a good point. Will capitalize.
|
We discussed this patch in the decorators call; a few people had reviewed it and were in favor of it. I plan to land the patch once I make the capitalization change @ljharb suggests and update the related documentation; I am still interested in any critical feedback you all may have. @nicolo-ribaudo does this patch seem plausible from a Babel implementation perspective? |
Yes, it doesn't add much complexity. |
|
I imagine you'd capture the get and set methods elsewhere, and check that this object had |
|
Two possibilities for detecting private names:
|
This patch changes PrivateName objects to have a null prototype and own methods, as described in #68 (comment) I'm not sure whether we want to do the change, but I'm writing it up so that we can think more carefully about whether we want to go in this direction. This patch is the most concrete, reasonable thing I can imagine in the direction of more integrity. It's also a relatively small change vs the previous proposal. Some results of the change: - It's not possible to effectively monkey-patch anything in particular to intercept private name accesses; you can only change one in particular which you already have access to. - There may be slightly more memory consuption due to the privateName objects having more own properties, but not that much, as the methods remain not bound to the receiver. Closes #68
912f98a to
4fb75d1
Compare
|
Rebased (with conflicts) and fixed capitalization. Landing this PR now, but I'm still happy to hear further comments about it on this thread. |
|
This PR makes |
|
@nicolo-ribaudo I didn't really think about it; we could make it non-writable. The |
This patch changes PrivateName objects to have a null prototype
and own methods, as described in
#68 (comment)
I'm not sure whether we want to do the change, but I'm writing it up
so that we can think more carefully about whether we want to go in
this direction. This patch is the most concrete, reasonable thing
I can imagine in the direction of more integrity. It's also a relatively
small change vs the previous proposal.
Some results of the change:
to intercept private name accesses; you can only change one in
particular which you already have access to.
objects having more own properties, but not that much, as the methods
remain not bound to the receiver.
Closes #68