Skip to content

Commit 70b0872

Browse files
bakkotljharb
authored andcommitted
Editorial: remove ReturnIfAbrupt and specify ! and ? directly (#3705)
1 parent 8c9cc3b commit 70b0872

File tree

1 file changed

+25
-55
lines changed

1 file changed

+25
-55
lines changed

spec.html

Lines changed: 25 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,74 +1079,44 @@ <h1>Throw an Exception</h1>
10791079
</emu-alg>
10801080
</emu-clause>
10811081

1082-
<emu-clause id="sec-returnifabrupt" aoid="ReturnIfAbrupt">
1083-
<h1>ReturnIfAbrupt</h1>
1084-
<p>Algorithms steps that say or are otherwise equivalent to:</p>
1082+
<emu-clause id="sec-shorthands-for-unwrapping-completion-records" oldids="sec-returnifabrupt">
1083+
<h1>Shorthands for Unwrapping Completion Records</h1>
1084+
<p>Prefix `?` and `!` are used as shorthands which unwrap Completion Records. `?` is used to propagate an abrupt completion to the caller, or otherwise to unwrap a normal completion. `!` is used to assert that a Completion Record is normal and unwrap it. Formally, the step</p>
10851085
<emu-alg example>
1086-
1. ReturnIfAbrupt(_argument_).
1086+
1. Let _result_ be ? _record_.
10871087
</emu-alg>
1088-
<p>mean the same thing as:</p>
1088+
<p>is equivalent to</p>
10891089
<emu-alg example>
1090-
1. Assert: _argument_ is a Completion Record.
1091-
1. If _argument_ is an abrupt completion, return Completion(_argument_).
1092-
1. Else, set _argument_ to _argument_.[[Value]].
1090+
1. Assert: _record_ is a Completion Record.
1091+
1. If _record_ is an abrupt completion, return _record_.
1092+
1. Let _result_ be _record_.[[Value]].
10931093
</emu-alg>
1094-
<p>Algorithms steps that say or are otherwise equivalent to:</p>
1094+
<p>Likewise, the step</p>
10951095
<emu-alg example>
1096-
1. ReturnIfAbrupt(AbstractOperation()).
1096+
1. Let _result_ be ! _record_.
10971097
</emu-alg>
1098-
<p>mean the same thing as:</p>
1098+
<p>is equivalent to</p>
10991099
<emu-alg example>
1100-
1. Let _hygienicTemp_ be AbstractOperation().
1101-
1. Assert: _hygienicTemp_ is a Completion Record.
1102-
1. If _hygienicTemp_ is an abrupt completion, return Completion(_hygienicTemp_).
1103-
1. Else, set _hygienicTemp_ to _hygienicTemp_.[[Value]].
1100+
1. Assert: _record_ is a normal completion.
1101+
1. Let _result_ be _record_.[[Value]].
11041102
</emu-alg>
1105-
<p>Where _hygienicTemp_ is ephemeral and visible only in the steps pertaining to ReturnIfAbrupt.</p>
1106-
<p>Algorithms steps that say or are otherwise equivalent to:</p>
1103+
<p>When `?` or `!` is used in any other context, first apply the rewrite given in <emu-xref href="#sec-evaluation-order" title></emu-xref> until this rule can be applied, then apply this rule. For example, the step</p>
11071104
<emu-alg example>
1108-
1. Let _result_ be AbstractOperation(ReturnIfAbrupt(_argument_)).
1105+
1. Perform AO(? Other()).
11091106
</emu-alg>
1110-
<p>mean the same thing as:</p>
1107+
<p>can be rewritten to</p>
11111108
<emu-alg example>
1112-
1. Assert: _argument_ is a Completion Record.
1113-
1. If _argument_ is an abrupt completion, return Completion(_argument_).
1114-
1. Else, set _argument_ to _argument_.[[Value]].
1115-
1. Let _result_ be AbstractOperation(_argument_).
1109+
1. Let _tmp1_ be Other().
1110+
1. Let _tmp2_ be ? _tmp1_.
1111+
1. Perform AO(_tmp2_).
11161112
</emu-alg>
1117-
</emu-clause>
1118-
1119-
<emu-clause id="sec-returnifabrupt-shorthands">
1120-
<h1>ReturnIfAbrupt Shorthands</h1>
1121-
<p>Invocations of abstract operations and syntax-directed operations that are prefixed by `?` indicate that ReturnIfAbrupt should be applied to the resulting Completion Record. For example, the step:</p>
1122-
<emu-alg example>
1123-
1. ? OperationName().
1124-
</emu-alg>
1125-
<p>is equivalent to the following step:</p>
1126-
<emu-alg example>
1127-
1. ReturnIfAbrupt(OperationName()).
1128-
</emu-alg>
1129-
<p>Similarly, for method application style, the step:</p>
1130-
<emu-alg example>
1131-
1. ? _someValue_.OperationName().
1132-
</emu-alg>
1133-
<p>is equivalent to:</p>
1134-
<emu-alg example>
1135-
1. ReturnIfAbrupt(_someValue_.OperationName()).
1136-
</emu-alg>
1137-
<p>Similarly, prefix `!` is used to indicate that the following invocation of an abstract or syntax-directed operation will never return an abrupt completion and that the resulting Completion Record's [[Value]] field should be used in place of the return value of the operation. For example, the step:</p>
1138-
<emu-alg example>
1139-
1. Let _val_ be ! OperationName().
1140-
</emu-alg>
1141-
<p>is equivalent to the following steps:</p>
1142-
<emu-alg example>
1143-
1. Let _val_ be OperationName().
1144-
1. Assert: _val_ is a normal completion.
1145-
1. Set _val_ to _val_.[[Value]].
1146-
</emu-alg>
1147-
<p>Syntax-directed operations for runtime semantics make use of this shorthand by placing `!` or `?` before the invocation of the operation:</p>
1113+
<p>which in turn expands to</p>
11481114
<emu-alg example>
1149-
1. Perform ! SyntaxDirectedOperation of |NonTerminal|.
1115+
1. Let _tmp1_ be Other().
1116+
1. Assert: _tmp1_ is a Completion Record.
1117+
1. If _tmp1_ is an abrupt completion, return _tmp1_.
1118+
1. Let _tmp2_ be _tmp1_.[[Value]].
1119+
1. Perform AO(_tmp2_).
11501120
</emu-alg>
11511121
</emu-clause>
11521122

0 commit comments

Comments
 (0)