-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Editorial: consolidate each SDO's definition #2271
Conversation
7e0adbd
to
241c9c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We went through this on the editor call, and it seems like a great improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great.
Per the editor call I skipped/skimmed most of the "consolidate" commits as they were script-generated.
@@ -14017,7 +14017,7 @@ <h1>Rules of Automatic Semicolon Insertion</h1> | |||
`throw` [no LineTerminator here] Expression[+In, ?Yield, ?Await] `;` | |||
|
|||
ArrowFunction[In, Yield, Await] : | |||
ArrowParameters[?Yield, ?Await] [no LineTerminator here] `=>` ConciseBody[?In] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're inconsistent between using =>
and =>
. Are there any =>
s left after this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should always write >
as >
when not part of an HTML tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any
=>
s left after this PR?
One, in OtherPunctuator
, which uses >
consistently for all punctuators.
I think we should always write
>
as>
when not part of an HTML tag.
Strong disagree. It's less readable for no benefit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @bakkot on not using >
. I prefer =>
.
As a followup, the new SDO clauses could use more prose in addition to the clause names briefly saying what SDOs are, what each clause is grouping by at a high-level. See existing prose in the Abstract Operations section, for example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice that you put type="sdo"
only on 'single-clause' SDOs. Wouldn't it also make sense on the remaining multi-clause SDOs?
Or is the 'type' attribute deemed to be an attribute of the aoid, not of the clause?
<h1>CreateImmutableBinding ( _N_, _S_ )</h1> | ||
<p>The CreateImmutableBinding concrete method of an object Environment Record is never used within this specification.</p> | ||
</emu-clause> | ||
<emu-clause id="sec-static-semantics-declarationpart" type="sdo" aoid="DeclarationPart"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, when a clause defines an aoid, the id
attribute is just "sec-" + lowercase(aoid).
(This is just the first occurrence of many.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with this particular inconsistency, I think.
|
||
<emu-clause id="sec-syntax-directed-operations-function-name-inference"> | ||
<h1>Function Name Inference</h1> | ||
<emu-clause id="sec-static-semantics-hasname" oldids="sec-semantics-static-semantics-hasname,sec-function-definitions-static-semantics-hasname,sec-arrow-function-definitions-static-semantics-hasname,sec-generator-function-definitions-static-semantics-hasname,sec-async-generator-function-definitions-static-semantics-hasname,sec-class-definitions-static-semantics-hasname,sec-async-function-definitions-static-semantics-HasName,sec-async-arrow-function-definitions-static-semantics-HasName" type="sdo" aoid="HasName"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insert blank line before <emu-clause>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make a lint rule for this and address in a followup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
Oh, I forgot one: this PR moves up the defining productions for parameter-related nonterminals, so it should probably move the corresponding emu-prodrefs in Annex A. |
Ah, nice catch. Done. |
Copying from IRC for posterity: the remaining such SDOs are Early Errors, Evaluation, MV, TV, TRV, and the evaluation semantics for RegExp patterns. I and ecmarkup are treating these as being unlike normal SDOs for one reason or another, so I'm not adding the |
…nDefinition to Function Name Inference section (#2271)
Fixes #1950. Fixes #2251.
This ensures every SDO is defined in a single place (modulo tweaks in Annex B, and excepting Early Errors and Evaluation). That way usages of SDOs can be automatically linked to their definition site, as is done for other abstract operations. This makes the spec much easier to navigate, I think.
That was generally just a matter of moving things around and some minor tweaking or renaming. Most SDOs had a natural place to live:
ExportEntries
can go in theExports
section, say. We introduced a new top-level "Syntax-Directed Operations" clause to hold some more broadly applicable operations.However, in a few cases @michaelficarra and I judged that the result would have separated sections which logically ought to be grouped, which we resolved by introducing new SDOs. For example,
InstantiateFunctionObject
has the semantics for setting up all four kinds of function declaration, and we wanted each those semantics to be together with their respective declaration kind. So we introducedInstantiateOrdinaryFunctionObject
,InstantiateGeneratorFunctionObject
,InstantiateAsyncGeneratorFunctionObject
, andInstantiateAsyncFunctionObject
, and made the originalInstantiateFunctionObject
dispatch the appropriate one.This is marked as a draft because there's still a few cases to do (specificallyEdit: ready to go! Needs tc39/ecmarkup#285 upstreamed, though.IsIdentifierRef
,NamedEvaluation
, andStringValue
), as well as some necessary cleanup (for example, the while statement clause is now entirely empty).This does not yet allow you to trivially answer the question "what SDOs are defined over this production?", which will come as part of tc39/ecmarkup#276.
Commits should be individually reviewable.