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
Consistent way to represent name, length, and "is a subclass" for constructors #3053
Comments
The derivation of both of these properties is described at ECMAScript Standard Buillt-in Objects. It does seem inconsistent that %AsyncFunction% The “is a subclass of Function” stuff looks odd to me. Usually in the spec, “subclass” is used to refer to ES code functions where [[ClassKind]] = "derived". GeneratorFunction etc doesn’t fit that description. |
Named and lengths should only be mentioned when they don’t match the implicit rules in the spec. |
To be clear, I'm not saying every function should mention its name/length, just that those that do should do it consistently, and those whose name can be inferred should probably not mention it. |
I think the spec is pretty consistent in 'declaring' a However, you're correct that these declarations take multiple forms. I'll propose a PR to make these consistent unless someone else is already working on one. "is a subclass": The spec has 3 statements that "X is a subclass of Y", namely that
is each a subclass of It's unclear what this phrase means. If it just means that each of these 3 constructors has a If it means something else, then we should probably define it. |
I'm trying to parse the ES spec for the prototype/length of constructors, and I found some annoying inconsistencies.
AsyncFunction
AsyncFunction.length
under "Properties of the AsyncFunction Constructor"Date
RegExp
AggregateError
As summarized above, only Function subclasses explicitly say that they are subclasses. Furthermore, they are the only ones that have a separate entry for
length
instead of either being omitted (since they can be inferred anyway) or as a bullet under "The X Constructor". Maybe this is to highlight that thislength
andname
are unrelated to the same-named properties on their instances, but this can be done in an editorial note as well.As a bonus, I wonder if the mention of "length" can be moved to the "Properties of the X Constructor" section, since "length" and "name" are both, well, properties of the constructor.
Lastly, I hope that all subclasses (errors, functions, typed arrays) can mention that they are subclasses.
The text was updated successfully, but these errors were encountered: