-
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: Make Evaluation
more like regular SDOs
#2744
Conversation
Thanks! I'll give this a detailed review soon.
That might be warranted, but either way ecmarkup probably shouldn't apply that rule to algorithms marked |
Oh, I checked the downstream specs: they don't have any occurrences of "the result of evaluating". |
Can the new "home" section for Evaluation link to all the other piecewise definitions? I don't really care whether this is manually maintained or generated by ecmarkup (for now). Just a big |
@bakkot, let me know if ecmarkup might do this in the foreseeable future. |
I think probably not? It's too specific to this one SDO. Also I'm less convinced of the utility of that than Michael, vs just C-f'ing for "runtime semantics: evaluation". |
If you're in single-page mode, that gets 70 matches. And when you land on a match, you might have to scroll a bit to establish whether this section has the definition you're looking for. If you're in multi-page mode, there are 4 separate pages with matches. It's probably faster to go to the defining occurrence of the nonterminal in question, then go to the next "Evaluation" section. |
I've added a commit that adds that index. There are 7 nonterminals whose Evaluation semantics are defined over more than one section:
|
Hm. Now that I see this rendered, I feel like it's actually inverted: the thing you want is to go from a nonterminal to its clause number, not from a clause number to its nonterminals. Would it be better to instead list, for each of the relevant nonterminals, the clause or clauses which define its Evaluation semantics? Possibly combining items where there's multiple nonterminals defined in a single clause and no others. So like
Though either way I guess it's probably going to be easier to navigate by search rather than actually reading, so perhaps it doesn't matter much. Thoughts? |
@bakkot I'm okay with either but I think I slightly prefer the current organisation. |
Yeah, I wondered about that too. With the current format, it isn't always obvious that there are multiple sections for a given nonterminal. So if you find one occurrence of the nonterminal in the index (either by control-F or visually), click on the section number, and don't find what you're looking for, it isn't clear that you need to go back, look for another occurrence of that nonterminal in the index, and repeat. With ones like UnaryExpression, where all the occurrences are together, you can see at a glance that there are multiples, but with ones like PrimaryExpression, CallExpression, and MemberExpression, you probably can't. Readers might find that frustrating. If we do 'invert' the index, I'd suggest putting the nonterminals in alphabetical order (for people who want to scroll rather than control-F). |
It strikes me that the current formulation of the index is not very useful. As a reader I'd be using the index if I had a piece of code in mind and I want to jump to the definition of Evaluation for it. If I'm not already an expert in the grammar and know what non-terminal covers that case, I wouldn't know how to use the index anyway. So, I'd prefer the index to list the productions themselves, as well as be organized by production instead of by section number. |
It's unclear what "organized by production" means. I'm guessing that the alternatives for a given nonterminal would appear together, but there are a couple ways that the nonterminals could be ordered:
(There's also Annex A order, but I think that's the same as spec-definition order for the nonterminals that appear in this index.) I can imagine us iterating a few more times on the format of this index, so maybe it should be a separate PR (since it isn't part of the point of this PR). |
We discussed this at the editor call today. We're fine with landing without the index for now and doing it in a followup. We did discuss details of exactly how it should look, eventually, and came away with
so the first few lines would be like
|
cbfea3d
to
f8a37c6
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.
LGTM otherwise. This is great!
@jmdyck want to clean up these commits, or should i? |
@ljharb: I need to think about how to do it. |
I decided to preserve them here: commit 5fff77832417f2e6f2e10930f05a817bc3bd2c33
commit d45660a1b3a159f161e7fb9e5aa8fc91e8e928fc
commit 0a75518a942b8be5398a33f67055edc0987fd078
commit a604df0b1bb5a8c16d2bd6c530e2af020f4eac80
commit 7a9038b23bd13923e5283001845f2e98785b1552
|
Note: Since Evaluation is now declared to return a Completion Record, it doesn't need to be special-cased in the first para of Implicit Normal Completion.
…ion (tc39#2744) Formerly, in the Evaluation semantics for `Block`, the return of `_blockValue_` was subject to implicit NormalCompletion, but this wasn't valid when it was an abrupt completion.
@ljharb: Okay, it's ready to go. (I'm getting an "x" on requiring "Allow Edits" because somehow it got unchecked. I re-checked it, but that doesn't make the "x" go away.) |
Still LGTM, thanks!
Yeah, that job needs to be manually re-run, which I've done. |
Note: Since Evaluation is now declared to return a Completion Record, it doesn't need to be special-cased in the first para of Implicit Normal Completion.
…ion (tc39#2744) Formerly, in the Evaluation semantics for `Block`, the return of `_blockValue_` was subject to implicit NormalCompletion, but this wasn't valid when it was an abrupt completion.
The
Evaluation
SDO is different from most SDOs in several ways, which this PR tries to reduce.Each commit is a logically separate refactoring, but they should probably be squashed before merging.
The "spec bug" label is not to imply that treating
Evaluation
differently was a bug, but rather that this PR fixes some bugs along the way.(1) The definitions of
Evaluation
are distributed over the "ECMAScript Language" sections of the spec rather than being gathered into one place (as established in PR #2271).This PR does not consolidate the definitions of
Evaluation
.However, the distributed definition has also meant that this SDO doesn't have a "home" section, so the first commit of this PR adds such a section. Now there will be a place to link to for "Evaluation", and a place (in the rendered spec) where you can find links to invocations of it. There could also be some prose that talks about Evaluation in general; suggestions welcome.
(The placement of the section, making it the new 8.1, was suggested by bakkot. To me, it seems odd to put a Runtime Semantics section before a Static Semantics section. I'd be inclined to reorganize section 8 into SS and RS, but I don't care too much.)
Note: Since Evaluation is now declared to return a Completion Record, it doesn't need to be special-cased in the first para of Implicit Normal Completion.
(Another aspect of Evaluation's distributed definition is that the multiple headings for its definitions don't conform to the 'structured header' conventions of PRs #2512 and #2547. I didn't try to change this, as bakkot thought that might confuse ecmarkup.)
(2) Currently, the invocations of Evaluation don't refer to it by that name, but are instead of the form "the result of evaluating X".
The second commit of this PR changes all such to "Evaluation of X".
Note that I left a few occurrences of the old form:
the result of evaluating _F_
isn't a reference to the Evaluation SDO. (For one thing, the 'operand' is a function object, not a Parse Node.)(3) Although Evaluation returns Completion Records, its invocations aren't currently marked with
!
,?
, orCompletion()
.To remove this difference, commit 3 starts by surrounding every invocation of Evaluation with
Completion()
, and then commits 4-8 gradually replace most of those with?
.(Commit 3 skips the two invocations of
Evaluation
in the chain rule example at the bottom of 5.2.2 Syntax-Directed Operations, because injecting "Completion()" would just confuse the reader. [Unfortunately, this omission causes ecmarkup to fail.] Perhaps the example should be rewritten to use an SDO that doesn't return a CR.)Note: In commit 3, Implicit Normal Completion can drop the exception:
because all of those cases are now covered by the exception:
Commits 4-8 have detailed commit messages; I'm not sure what I'll do with those if/when they get squashed.
Commit 9 is just a bonus bugfix.