Skip to content
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: Correct variable terminology #1326

Merged
merged 1 commit into from
Apr 29, 2020

Conversation

TimothyGu
Copy link
Member

@TimothyGu TimothyGu commented Oct 11, 2018

The spec "variables" are not variables, but aliases as defined in 5.2 Algorithm Conventions.

@zenparsing
Copy link
Member

The only other such usage of "variable" occurs in reference to InputLength at https://tc39.github.io/ecma262/#sec-pattern.

Should that usage be fixed as well?

@TimothyGu TimothyGu changed the title Editorial: Correct variable terminology in Await Editorial: Correct variable terminology Oct 11, 2018
@TimothyGu
Copy link
Member Author

@zenparsing Should be fixed.

spec.html Outdated
@@ -29434,7 +29434,7 @@ <h1>Notation</h1>
A <em>MatchResult</em> is either a State or the special token ~failure~ that indicates that the match failed.
</li>
<li>
A <em>Continuation</em> procedure is an internal closure (i.e. an internal procedure with some arguments already bound to values) that takes one State argument and returns a MatchResult result. If an internal closure references variables which are bound in the function that creates the closure, the closure uses the values that these variables had at the time the closure was created. The Continuation attempts to match the remaining portion (specified by the closure's already-bound arguments) of the pattern against _Input_, starting at the intermediate state given by its State argument. If the match succeeds, the Continuation returns the final State that it reached; if the match fails, the Continuation returns ~failure~.
A <em>Continuation</em> procedure is an internal closure (i.e. an internal procedure with some arguments already bound to values) that takes one State argument and returns a MatchResult result. If an internal closure references aliases which are bound in the function that creates the closure, the closure uses the values that these aliases had at the time the closure was created. The Continuation attempts to match the remaining portion (specified by the closure's already-bound arguments) of the pattern against _Input_, starting at the intermediate state given by its State argument. If the match succeeds, the Continuation returns the final State that it reached; if the match fails, the Continuation returns ~failure~.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm confused; closures reference variables, how can they reference aliases?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that the "continuations" in that section aren't JS closures, and the bindings that they capture aren't JS variables. They are the EcmaSpeak "aliases" instead (e.g. Disjunction). Does that sound right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Precisely as @zenparsing said. See https://tc39.github.io/ecma262/#sec-algorithm-conventions, where “alias” is defined.

@allenwb do you have any insights?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph dates back to the 3rd edition. At the time, the spec used the word "closure" only to denote a spec artifact (what we might now think of as a dynamic abstract operation), used to describe the semantics of RegExps, and not to describe the behavior of ES functions. (The spec started to use the term more generally in the 5th edition, but it still has that specific meaning within the RegExp semantics.)

The phrase "the function that creates the closure" compounds the confusion. It would probably help to change that occurrence of "function" to "algorithm".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1889 defined abstract closures formally, resolving this issue.

@ljharb ljharb requested review from bmeck, bterlson, crookedneighbor and a team October 12, 2018 03:09
@ljharb ljharb removed the request for review from bterlson February 28, 2019 19:56
@ljharb ljharb assigned ljharb and unassigned bterlson Feb 28, 2019
@ljharb ljharb removed their assignment Apr 12, 2019
@ljharb ljharb requested a review from allenwb April 12, 2019 21:54
@ljharb
Copy link
Member

ljharb commented Apr 12, 2019

Still hoping for some clarification re #1326 (comment)

@ljharb ljharb requested review from syg and bakkot February 13, 2020 21:25
@ljharb ljharb force-pushed the await-explanation branch from 95d4da9 to 9165688 Compare April 29, 2020 22:24
@ljharb ljharb self-assigned this Apr 29, 2020
@ljharb ljharb merged commit 9165688 into tc39:master Apr 29, 2020
@TimothyGu TimothyGu deleted the await-explanation branch May 1, 2020 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants