Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

Commit 9ea691b

Browse files
committed
Spec: Update cross-references to main spec
See tc39/ecma262#1697. Also improve cross-references to |PipelineTopicBody|.
1 parent e5a46f4 commit 9ea691b

1 file changed

Lines changed: 45 additions & 44 deletions

File tree

spec.html

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,14 @@ <h1>Introduction</h1>
1919
<emu-clause id=executable-code-and-execution-contexts>
2020
<h1>Executable Code and Execution Contexts</h1>
2121

22-
<emu-clause id=sec-lexical-environments>
23-
<h1>Lexical Environments</h1>
24-
25-
<emu-clause id=sec-lexical-topics>
26-
<h1><ins>Lexical Topics</ins></h1>
27-
28-
<emu-note type=editor>
29-
<p>This section is a wholly new sub-clause of the <a href=https://tc39.github.io/ecma262/#sec-lexical-environments>original Lexical Environments clause</a>.</p>
30-
</emu-note>
31-
32-
<p>The <dfn>topic binding</dfn> of a Lexical Environment immutably binds the topic reference `&quest;` to one value of any ECMAScript language type (called the <dfn>topic value</dfn> or simply the <dfn>topic</dfn>), within that Lexical Environment, at the time of the Lexical Environment's instantiation. The topic of a Lexical Environment conceptually serves as the value that the lexical context is "about".</p>
33-
34-
<p>A <dfn>topic-binding environment</dfn> is a Lexical Environment that establishes a topic binding. The <dfn>topic environment</dfn> of the running execution context is its Lexical Environment's nearest outer environment that is a topic-binding environment, as defined by the abstract operator GetTopicEnvironment.</p>
35-
36-
<emu-note>
37-
<p>The <strong>only</strong> Lexical Environments that are topic-binding environments are declarative environments that are associated with <strong>|PipelineTopicBody|</strong> and which were created with the <strong>TopicEnvironmentInstantiation</strong> abstract operation.</p>
38-
39-
<p>In addition, |PipelineTopicBody| <strong>hides</strong> its own inner topic references from the static semantic rule Contains. Within the scope of <emu-grammar>PipelineTopicBody : ConditionalExpression</emu-grammar>, such topic references would <strong>not</strong> trigger early error rules during program compilation. Instead, they would be evaluated at runtime into the values of the <strong>newly instantiated</strong> topic-binding environments' topic bindings.</p>
40-
41-
<p>No other Lexical Environments do not establish any topic bindings; in particular, object and global environments are never topic-binding environments.</p>
42-
43-
<p>In addition, |ScriptBody| and |ModuleBody| are associated with early error rules that <strong>forbid</strong> their containing the topic reference `&quest;`, <strong>except</strong> where the topic reference is within |PipelineTopicBody|. These early error rules are defined using the static semantic rule Contains, from which |PipelineTopicBody| hides the topic reference.</p>
44-
</emu-note>
45-
46-
</emu-clause>
47-
4822
<emu-clause id=sec-environment-records>
4923
<h1>Environment Records</h1>
5024

25+
<emu-clause id=sec-the-environment-record-type-hierarchy>
26+
<h1>The Environment Record Type Hierarchy</h1>
27+
5128
<emu-note type=editor>
52-
<p>This section augments the <a href=https://tc39.github.io/ecma262/#sec-environment-records>original Environment Records clause</a>.</p>
29+
<p>This section augments the <a href=https://tc39.github.io/ecma262/https://tc39.es/ecma262/#sec-the-environment-record-type-hierarchy>original Environment Records clause</a>.</p>
5330
</emu-note>
5431

5532
<emu-table id=table-15 caption="Abstract Methods of Environment Records">
@@ -70,7 +47,7 @@ <h1>Environment Records</h1>
7047
<ins>HasTopicBinding()</ins>
7148
</td>
7249
<td>
73-
<ins>Determine the status of an Environment Record's topic binding. Return *true* if it establishes a topic binding and *false* if it does not.</ins>
50+
<ins>Determine whether an Environment Record is a topic-binding environment. Return *true* if it establishes a topic binding and *false* if it does not.</ins>
7451
</td>
7552
</tr>
7653
</tbody>
@@ -113,7 +90,7 @@ <h1>Declarative Environment Records</h1>
11390
*false* | *true*
11491
</td>
11592
<td>
116-
If [[TopicBindingStatus]]'s value is *true*, the Environment Record binds the Environment Record establishes its environment's topic binding (that is, it binds `&quest;`) to values. If the value is *false*, the Environment Record has no topic binding. [[TopicBindingStatus]]'s default value is *false*. Its value may be changed from *false* to *true* but never vice versa.
93+
If [[TopicBindingStatus]]'s value is *true*, the declarative Environment Record is a topic-binding environment. If the value is *false*, the Environment Record has no topic binding. [[TopicBindingStatus]]'s default value is *false*. Its value may be changed from *false* to *true* but never vice versa.
11794
</td>
11895
</tr>
11996
<tr>
@@ -132,7 +109,7 @@ <h1>Declarative Environment Records</h1>
132109
</emu-table>
133110

134111
<emu-note type=editor>
135-
<p>[[TopicValues]] is a List in order to be forward compatible with future extensions that would use multiple topic values, e.g., topic functions.</p>
112+
<p>[[TopicValues]] is a List in order to be forward compatible with future extensions that would use multiple <emu-xref href="#sec-topic-bindings">topic values</emu-xref>, e.g., <a href=https://github.com/js-choi/proposal-hack-pipes/blob/master/README.md#pipe-functions>"pipe functions".</a></p>
136113
</emu-note>
137114

138115
<p>Declarative Environment Records support all of the abstract methods of Environment Records listed in <emu-xref href="#table-15"></emu-xref>. In addition, declarative Environment Records support the methods listed in <emu-xref href="#table-62"></emu-xref>.</p>
@@ -155,7 +132,7 @@ <h1>Declarative Environment Records</h1>
155132
BindTopicValues(V)
156133
</td>
157134
<td>
158-
Establish the immutable topic binding of this Environment Record and set the topic binding's value. _V_ is a List containing the one element which is the topic value and is a value of any ECMAScript language type. Afterward, the value returned by the Environment Record's HasTopicBinding method is *true*. This method cannot be called more than once on any single Environment Record.
135+
Establish the immutable topic binding of this Environment Record and set the topic binding's value. _V_ is a List containing the one element which is the topic value and is a value of any ECMAScript language type. Afterward, the Environment Record is a topic-binding environment, and the value returned by the Environment Record's HasTopicBinding method is *true*. This method cannot be called more than once on any single Environment Record.
159136
</td>
160137
</tr>
161138
</tbody>
@@ -164,7 +141,7 @@ <h1>Declarative Environment Records</h1>
164141
</ins>
165142

166143
<emu-note type=editor>
167-
<p>BindTopicValues() accepts a List argument rather than a single-value argument in order to be forward compatible with future extensions that would use multiple topic values, e.g., topic functions.</p>
144+
<p>BindTopicValues() accepts a List argument rather than a single-value argument in order to be forward compatible with future extensions that would use multiple <emu-xref href="#sec-topic-bindings">topic values</emu-xref>, e.g., <a href=https://github.com/js-choi/proposal-hack-pipes/blob/master/README.md#pipe-functions>"pipe functions".</a>.</p>
168145
</emu-note>
169146

170147
<p>The behaviour of the concrete <ins>and additional</ins> specification methods for declarative Environment Records is defined by the following algorithms.</p>
@@ -232,10 +209,34 @@ <h1><ins>HasTopicBinding ( )</ins></h1>
232209
1. Return *false*.
233210
</emu-alg>
234211
</emu-clause>
212+
213+
</emu-clause>
214+
235215
</emu-clause>
236216

217+
<emu-clause id=sec-topic-bindings>
218+
<h1><ins>Topic Bindings</ins></h1>
219+
220+
<emu-note type=editor>
221+
<p>This section is a wholly new sub-clause of the <a href=https://tc39.github.io/ecma262/#sec-environment-records>original Environment Records clause</a>.</p>
222+
</emu-note>
223+
224+
<p>The <dfn>topic binding</dfn> of a declarative Environment Record immutably binds the topic reference `&quest;` to one value of any ECMAScript language type (called the <dfn>topic value</dfn> or simply the <dfn>topic</dfn>), within that declarative Environment Record, at the time of the Environment Record's instantiation. The topic of a declarative Environment Record conceptually serves as the value that its lexical context is "about".</p>
225+
226+
<p>A <dfn>topic-binding environment</dfn> is a declarative Environment Record that establishes a topic binding. The <dfn>topic environment</dfn> of the running execution context is its LexicalEnvironment's nearest outer Environment Record that is also a topic-binding environment (or *null* if no such Environment Record exists), as defined by the abstract operator GetTopicEnvironment.</p>
227+
228+
<emu-note>
229+
<p>The <strong>only</strong> Environment Records that are topic-binding environments are declarative environments that are associated with <strong>|PipelineTopicBody|</strong> and which were created with the <strong>TopicEnvironmentInstantiation</strong> abstract operation.</p>
230+
231+
<p>In addition, |PipelineTopicBody| <strong>hides</strong> its own inner topic references from the static semantic rule Contains. Within the scope of <emu-grammar>PipelineTopicBody : ConditionalExpression</emu-grammar>, such topic references would <strong>not</strong> trigger early error rules during program compilation. Instead, they would be evaluated at runtime into the values of the <strong>newly instantiated</strong> topic-binding environments' topic bindings.</p>
232+
233+
<p>In addition, |ScriptBody| and |ModuleBody| are associated with early error rules that <strong>forbid</strong> their containing the topic reference `&quest;`, <strong>except</strong> where the topic reference is within |PipelineTopicBody|. These early error rules are defined using the static semantic rule Contains, from which |PipelineTopicBody| hides the topic reference.</p>
234+
</emu-note>
235+
237236
</emu-clause>
237+
238238
</emu-clause>
239+
239240
</emu-clause>
240241

241242
<emu-clause id=sec-ecmascript-language-lexical-grammar>
@@ -306,9 +307,9 @@ <h1>The <ins>Topic Reference</ins></h1>
306307
</emu-note>
307308

308309
<emu-note>
309-
<p>The <dfn>topic reference</dfn>, which is the token `&quest;`, is a nullary operator that evaluates to the value of the current Lexical Environment's topic. The topic reference acts as if it were a special variable: implicitly bound to the topic value, yet still lexically scoped. But `&quest;` is not actually an |IdentifierName| and the topic reference is not a variable, and it cannot be bound by typical assignment; instead, it is immutably bound to a value during the instantiation of certain topic-binding environments.</p>
310+
<p>The <dfn>topic reference</dfn>, which is the token `&quest;`, is a nullary operator that evaluates to the current Environment Record's topic value. The topic reference acts as if it were a special variable: implicitly bound to the topic value, yet still lexically scoped. But `&quest;` is not actually an |IdentifierName| and the topic reference is not a variable, and it cannot be bound by typical assignment; instead, it is immutably bound to a value during the instantiation of certain topic-binding environments.</p>
310311

311-
<p>The concept of lexical topic binding is further discussed in <emu-xref href="#sec-lexical-topics">Lexical Topics</emu-xref> and in <emu-xref href="#sec-declarative-environment-records">Declarative Environment Records</emu-xref>.</p>
312+
<p>The concept of topic bindings is further discussed in <emu-xref href="#sec-topic-bindings">Topic Bindings</emu-xref> and in <emu-xref href="#sec-declarative-environment-records">Declarative Environment Records</emu-xref>.</p>
312313
</emu-note>
313314

314315
<emu-clause id=sec-gettopicenvironment aoid=GetTopicEnvironment>
@@ -318,13 +319,13 @@ <h1>Runtime Semantics: GetTopicEnvironment</h1>
318319
</emu-note>
319320
<p>When the abstract operation GetTopicEnvironment is called, the following steps are performed:</p>
320321
<emu-alg>
321-
1. Let _lex_ be the running execution context's Lexical Environment.
322+
1. Let _envRec_ be the running execution context's LexicalEnvironment.
322323
2. Repeat,
323324
1. Let _envRec_ be _lex_'s Environment Record.
324325
2. Let _status_ be _envRec_.HasTopicBinding().
325326
3. If _status_ is *true*, return _envRec_.
326327
4. Assert: _lex_ is not a global environment.
327-
4. Let _outer_ be the value of _lex_'s outer environment reference.
328+
5. Let _outer_ be the value of _lex_.[[OuterEnv]].
328329
6. Set _lex_ to _outer_.
329330
3. Return _lex_.
330331
</emu-alg>
@@ -388,10 +389,10 @@ <h1>Static Semantics: Early Errors</h1>
388389
</emu-note>
389390

390391
<emu-note>
391-
<p><p>A pipeline’s body must use its topic reference.
392+
<p><p>A |PipelineTopicBody| must use its topic reference at least once.
392393
`value |&gt; foo + 1` is an early error,
393394
because it does not contain `&quest;`.
394-
This design is because omission of the topic reference from a pipeline body
395+
This design is because omission of the topic reference from a |PipelineTopicBody|
395396
is almost certainly an accidental programmer error.
396397
In order to interpose a side effect
397398
in the middle of a pipeline expression,
@@ -432,11 +433,11 @@ <h1>Runtime Semantics: TopicEnvironmentInstantiation</h1>
432433
<p>This section is a wholly new sub-clause.</p>
433434
</emu-note>
434435
<emu-note>
435-
<p>This abstract operation constructs, instantiates, then returns a new declarative Lexical Environment for a pipeline body. It creates an immutable topic binding in that declarative environment using the given _topicValues_.</p>
436+
<p>This abstract operation constructs, instantiates, then returns a new declarative Environment Record for a |PipelineTopicBody|. It creates an immutable topic binding in that declarative environment using the given _topicValues_.</p>
436437
</emu-note>
437438
<p>TopicPipelineInstantiation is performed as follows using arguments _env_ and _topicValues_.</p>
438439
<ul>
439-
<li>_env_ is the Lexical Environment in which the topic binding is to be created.</li>
440+
<li>_env_ is the declarative Environment Record in which the topic binding is to be created.</li>
440441
<li>_topicValues_ is a List of values: _env_'s primary topic reference will be bound to the first value.</li>
441442
</ul>
442443

@@ -456,12 +457,12 @@ <h1>Runtime Semantics: PipelineEvaluation</h1>
456457

457458
<emu-grammar>PipelineTopicBody : ConditionalExpression</emu-grammar>
458459
<emu-alg>
459-
1. Let _outerEnv_ be the running execution context's Lexical Environment.
460-
2. Let _pipelineBodyEnv_ be New Declarative Environment(_oldEnv_).
460+
1. Let _outerEnv_ be the running execution context's LexicalEnvironment.
461+
2. Let _pipelineBodyEnv_ be NewDeclarativeEnvironment(_outerEnv_).
461462
3. Perform TopicEnvironmentInstantiation(_inputValues_, _pipelineBodyEnv_).
462-
4. Set the running execution context's Lexical Environment to _pipelineBodyEnv_.
463+
4. Set the running execution context's LexicalEnvironment to _pipelineBodyEnv_.
463464
5. Let _pipelineValue_ be the result of evaluating _ConditionalExpression_.
464-
6. Set the running execution context's Lexical Environment to _outerEnv_.
465+
6. Set the running execution context's LexicalEnvironment to _outerEnv_.
465466
7. Return a List containing the one element which is _pipelineValue_.
466467
</emu-alg>
467468

0 commit comments

Comments
 (0)