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

Implement meta-object trap(s) to make an object's [[Prototype]] immutable #538

Open
jswalden opened this Issue Apr 12, 2016 · 4 comments

Comments

Projects
None yet
4 participants
@jswalden
Contributor

jswalden commented Apr 12, 2016

This is followup on making the global object's [[Prototype]] chain immutable. It was agreed that a proposal to extend this to be a full proxy trap, so that ordinary objects and arrays and so on could have immutable [[Prototype]], would be entertained, and I'd write up the spec-proposal for it. Said spec-proposal isn't complete yet, but I have an approximate start on it thus far.

Right now the gist of the idea is to add a [[SetImmutablePrototype]] trap and (on most objects) a [[MutablePrototype]] Boolean internal slot indicating mutability (initially true). I have this completed, generally sensibly enough, except for a few issues still. I'll post my current, un-landable progress after filing this issue and figuring out how to attach that progress.

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Apr 12, 2016

Member

Yay!

on most objects) a [[MutablePrototype]] Boolean internal slot indicating mutability (initially true).

I think this woudl be better integrated into [[Extensible]]. So instead of being a boolean, [[Extensible]] becomes a tri-state "extensible", "immutable prototype", "non-extensible". It isn't possible to have an object that is non-existensible but with a mutable prototype, so a two-boolean design gives too many degrees of freedom.

Member

domenic commented Apr 12, 2016

Yay!

on most objects) a [[MutablePrototype]] Boolean internal slot indicating mutability (initially true).

I think this woudl be better integrated into [[Extensible]]. So instead of being a boolean, [[Extensible]] becomes a tri-state "extensible", "immutable prototype", "non-extensible". It isn't possible to have an object that is non-existensible but with a mutable prototype, so a two-boolean design gives too many degrees of freedom.

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Apr 12, 2016

Member

In order to add a proxy trap, a corresponding Reflect method would need to be added. I suspect this would need to be part of a full proposal and maybe wouldn't be able to be just a PR.

Member

ljharb commented Apr 12, 2016

In order to add a proxy trap, a corresponding Reflect method would need to be added. I suspect this would need to be part of a full proposal and maybe wouldn't be able to be just a PR.

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Apr 12, 2016

Member

Agree with @domenic, s/[[Extensible]]/[[Extensibility]] and tri-state seems good.

Member

bterlson commented Apr 12, 2016

Agree with @domenic, s/[[Extensible]]/[[Extensibility]] and tri-state seems good.

jswalden added a commit to jswalden/ecma262 that referenced this issue Apr 12, 2016

Add a way to make the [[Prototype]] of an object immutable, without h…
…aving to have a [[SetPrototypeOf]] trap enforcing such behavior. Fixes tc39#538.
@jswalden

This comment has been minimized.

Show comment
Hide comment
@jswalden

jswalden Apr 12, 2016

Contributor

https://github.com/jswalden/ecma262/tree/setimmutableprototype is the current quasi-state of what I have. It adds the extra [[MutablePrototype]] thing, rather than the [[Extensibility]] thing mooted already. The issue is that it only adds one trap, [[SetImmutablePrototype]], right now. But another is needed (or so it seems) to expose whether the [[Prototype]] is immutable. See the XXX bits in the branch above (and tell me how to attach its current state here, rather than literally just linking it). Does it seem like two additional traps are required here, or is there some other better approach for this?

Contributor

jswalden commented Apr 12, 2016

https://github.com/jswalden/ecma262/tree/setimmutableprototype is the current quasi-state of what I have. It adds the extra [[MutablePrototype]] thing, rather than the [[Extensibility]] thing mooted already. The issue is that it only adds one trap, [[SetImmutablePrototype]], right now. But another is needed (or so it seems) to expose whether the [[Prototype]] is immutable. See the XXX bits in the branch above (and tell me how to attach its current state here, rather than literally just linking it). Does it seem like two additional traps are required here, or is there some other better approach for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment