Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Rewrite in terms of internal slots #42

Closed
littledan opened this issue Aug 3, 2016 · 8 comments
Closed

Rewrite in terms of internal slots #42

littledan opened this issue Aug 3, 2016 · 8 comments

Comments

@littledan
Copy link
Member

@allenwb and Waldemar expressed concern that the WeakMap semantics had poor layering properties and implied unexpected GC semantics. One way to repair that would be to use internal slots to track private fields, rather than WeakMaps. Kevin actually did this in an earlier version of the spec. GC and layering aside, I believe there aren't any observable differences with this formalism. This bug tracks making that spec change. cc @erights

@allenwb
Copy link
Member

allenwb commented Aug 4, 2016

I also sketched this out in the proposal that Yehuda and I developed.

Be sure to look at the semantics sketch section.

Fill free to borrow...

@littledan
Copy link
Member Author

Hi @allenwb @erights, I've modified the draft specification in terms of slot keys and an [[instanceSlot]] internal slot, along the lines of @allenwb's proposal (though with slightly different naming). You can find the modified specification at https://tc39.github.io/proposal-private-fields/ . Aside from implied garbage collection semantics, this should not have observable differences from the previous WeakMap-based semantics. I'd be really interested in your feedback in this change.

@chicoxyzzy
Copy link
Member

README.md still mentions WeakMaps

@ljharb
Copy link
Member

ljharb commented Nov 23, 2016

WeakMaps is how this feature will be polyfilled, regardless of how it's worded in the spec, and some members of the committee do indeed prefer using them to explain the concept more clearly than the concept of "internal slots". I think it should be fine to mention it in the readme.

@littledan
Copy link
Member Author

@chicoxyzzy Thanks for pointing this out. I've rewritten that part of the README to be in terms of the current spec mechanics, while pointing out the analogy to WeakMaps.

@diervo
Copy link
Member

diervo commented Dec 10, 2016

I talked to @littledan this week to clarify a couple of things, and I will take a stab at it over the weekend, specially to modify the grammar from babylon.
The implementation details still TBD.

@bakkot
Copy link
Contributor

bakkot commented Dec 10, 2016

@diervo, make sure you check babel/babylon#158 - babylon's grammar for class fields is currently rather far from spec.

@diervo
Copy link
Member

diervo commented Dec 10, 2016

@bakkot thanks! Yeah I was digging into babylon first to understand how some of the current implementations were done (like decorators and public fields) and it looks less "spec formal" as I expected. Will hopefully send something soon to gather feedback.

I'm fortunate that @littledan will help me in the nuances to make sure is spec compliant :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants