-
Notifications
You must be signed in to change notification settings - Fork 11
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
Currently no way to define structs? #37
Comments
Oops, good catch on the omission. I was intending to add Edit: and also Also cc @rbuckton who works with the spec grammar much more than I do. |
You'll also have to resolve collisions between struct declarations and expressions. |
For shared structs at least, there is no expression version as they must be top level declarations. I can't recall if we wanted to enforce that rule for non-shared structs as well, however. |
So you'd just drop the expression versions? That would take care of the declaration-vs-expression conflict, as well as some other conflicts such as a struct expression whose name happens to be |
The expressions were added to the spec text more because I was copying class expression stuff from the main spec as a starting point than anything else. I think the utility of struct expressions is pretty low, so I've opened #38. |
Was just chatting with @jridgewell who mentioned AMP (? if memory correct) has a transform to convert class declarations into class expressions to avoid TDZ checks. Do structs follow suite, or maybe a chance to avoid TDZ checks? |
Interesting. I guess we'd have to weigh that against the grammar complexities for supporting expressions and declarations at the same time. The correlation problem strongly favors restricting shared struct declarations to top-level only, which also implies no expressions. As much as I hate TDZ it seems like a smaller issue here. |
The proposed spec does not currently provide any way to define structs or struct expressions — there's nothing I can find that references those productions from elsewhere in the grammar other than
export
.I'm curious how syntactic collisions will be resolved once such expressions are defined.
The text was updated successfully, but these errors were encountered: