-
Notifications
You must be signed in to change notification settings - Fork 10
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
Recommend explicit extends null
for shared structs
#5
Comments
Agreed that we eventually want to have something like a prototype chain that's shareable. I definitely see the desirability of having a syntactic marker calling out the current [[Prototype]] semantics, but I have two questions:
|
Making accessing If you define unique behavior such that So, for shared struct class C extends null {}
const c = new C(); the following would be true:
This would allow us to eventually slot-in a default prototype at a later date. It might eventually allow We might be able to get away with this instead:
Although introducing a Alternatively, these objects never have a
Possibly. Structs, as you've proposed, are essentially plain objects with some restrictions, so I would assume having a non-shared side note: Its very frustrating that the spec explicitly calls out |
While it may be a little early for in depth syntax debates, if shared functions is something we may consider in the future then we might want to ensure that shared structs can eventually have something like a
[[Prototype]]
chain of other shared structs with shared methods/accessors (unless we essentially just flatten those as well). It would be nice to be able to haveinstanceof
andconstructor
and to be able to share the shared struct constructor function.As such, I would recommend that if we continue to use class-like syntax, that we might want to consider enforcing that shared structs have an explicit
extends null
to enforce the current[[Prototype]]
semantics, otherwise we might not be able to change that in the future.Example (based on current explainer):
The text was updated successfully, but these errors were encountered: