Skip to content

Commit 587adc0

Browse files
jmdyckljharb
authored andcommitted
Editorial: Recast "Abstract Relational Comparison" (#2378)
... as a proper abstract operation, named IsLessThan.
1 parent 28fb25e commit 587adc0

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

β€Žspec.html

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ <h1>Numeric Types</h1>
13821382
</td>
13831383
<td>
13841384
<emu-xref href="#sec-relational-operators" title></emu-xref>,
1385-
via <emu-xref href="#sec-abstract-relational-comparison" title></emu-xref>
1385+
via <emu-xref href="#sec-islessthan" title></emu-xref>
13861386
</td>
13871387
<td>
13881388
Boolean or *undefined* (for unordered inputs)
@@ -5240,9 +5240,9 @@ <h1>SameValueNonNumeric ( _x_, _y_ )</h1>
52405240
</emu-alg>
52415241
</emu-clause>
52425242

5243-
<emu-clause id="sec-abstract-relational-comparison" aoid="Abstract Relational Comparison">
5244-
<h1>Abstract Relational Comparison</h1>
5245-
<p>The comparison _x_ &lt; _y_, where _x_ and _y_ are values, produces *true*, *false*, or *undefined* (which indicates that at least one operand is *NaN*). In addition to _x_ and _y_ the algorithm takes a Boolean flag named _LeftFirst_ as a parameter. The flag is used to control the order in which operations with potentially visible side-effects are performed upon _x_ and _y_. It is necessary because ECMAScript specifies left to right evaluation of expressions. The default value of _LeftFirst_ is *true* and indicates that the _x_ parameter corresponds to an expression that occurs to the left of the _y_ parameter's corresponding expression. If _LeftFirst_ is *false*, the reverse is the case and operations must be performed upon _y_ before _x_. Such a comparison is performed as follows:</p>
5243+
<emu-clause id="sec-islessthan" aoid="IsLessThan" oldids="sec-abstract-relational-comparison">
5244+
<h1>IsLessThan ( _x_, _y_ [ , _LeftFirst_ ] )</h1>
5245+
<p>The abstract operation IsLessThan takes arguments _x_ (an ECMAScript language value) and _y_ (an ECMAScript language value), and optional argument _LeftFirst_ (a Boolean). It provides the semantics for the comparison _x_ &lt; _y_, returning *true*, *false*, or *undefined* (which indicates that at least one operand is *NaN*). The _LeftFirst_ flag is used to control the order in which operations with potentially visible side-effects are performed upon _x_ and _y_. It is necessary because ECMAScript specifies left to right evaluation of expressions. The default value of _LeftFirst_ is *true* and indicates that the _x_ parameter corresponds to an expression that occurs to the left of the _y_ parameter's corresponding expression. If _LeftFirst_ is *false*, the reverse is the case and operations must be performed upon _y_ before _x_. It performs the following steps when called:</p>
52465246
<emu-alg>
52475247
1. If the _LeftFirst_ flag is *true*, then
52485248
1. Let _px_ be ? ToPrimitive(_x_, ~number~).
@@ -17184,8 +17184,7 @@ <h1>Runtime Semantics: Evaluation</h1>
1718417184
1. Let _lval_ be ? GetValue(_lref_).
1718517185
1. Let _rref_ be the result of evaluating |ShiftExpression|.
1718617186
1. Let _rval_ be ? GetValue(_rref_).
17187-
1. Let _r_ be the result of performing Abstract Relational Comparison _lval_ &lt; _rval_.
17188-
1. ReturnIfAbrupt(_r_).
17187+
1. Let _r_ be ? IsLessThan(_lval_, _rval_).
1718917188
1. If _r_ is *undefined*, return *false*. Otherwise, return _r_.
1719017189
</emu-alg>
1719117190
<emu-grammar>RelationalExpression : RelationalExpression `&gt;` ShiftExpression</emu-grammar>
@@ -17194,8 +17193,7 @@ <h1>Runtime Semantics: Evaluation</h1>
1719417193
1. Let _lval_ be ? GetValue(_lref_).
1719517194
1. Let _rref_ be the result of evaluating |ShiftExpression|.
1719617195
1. Let _rval_ be ? GetValue(_rref_).
17197-
1. Let _r_ be the result of performing Abstract Relational Comparison _rval_ &lt; _lval_ with _LeftFirst_ equal to *false*.
17198-
1. ReturnIfAbrupt(_r_).
17196+
1. Let _r_ be ? IsLessThan(_rval_, _lval_, *false*).
1719917197
1. If _r_ is *undefined*, return *false*. Otherwise, return _r_.
1720017198
</emu-alg>
1720117199
<emu-grammar>RelationalExpression : RelationalExpression `&lt;=` ShiftExpression</emu-grammar>
@@ -17204,8 +17202,7 @@ <h1>Runtime Semantics: Evaluation</h1>
1720417202
1. Let _lval_ be ? GetValue(_lref_).
1720517203
1. Let _rref_ be the result of evaluating |ShiftExpression|.
1720617204
1. Let _rval_ be ? GetValue(_rref_).
17207-
1. Let _r_ be the result of performing Abstract Relational Comparison _rval_ &lt; _lval_ with _LeftFirst_ equal to *false*.
17208-
1. ReturnIfAbrupt(_r_).
17205+
1. Let _r_ be ? IsLessThan(_rval_, _lval_, *false*).
1720917206
1. If _r_ is *true* or *undefined*, return *false*. Otherwise, return *true*.
1721017207
</emu-alg>
1721117208
<emu-grammar>RelationalExpression : RelationalExpression `&gt;=` ShiftExpression</emu-grammar>
@@ -17214,8 +17211,7 @@ <h1>Runtime Semantics: Evaluation</h1>
1721417211
1. Let _lval_ be ? GetValue(_lref_).
1721517212
1. Let _rref_ be the result of evaluating |ShiftExpression|.
1721617213
1. Let _rval_ be ? GetValue(_rref_).
17217-
1. Let _r_ be the result of performing Abstract Relational Comparison _lval_ &lt; _rval_.
17218-
1. ReturnIfAbrupt(_r_).
17214+
1. Let _r_ be ? IsLessThan(_lval_, _rval_).
1721917215
1. If _r_ is *true* or *undefined*, return *false*. Otherwise, return *true*.
1722017216
</emu-alg>
1722117217
<emu-grammar>RelationalExpression : RelationalExpression `instanceof` ShiftExpression</emu-grammar>
@@ -17663,7 +17659,7 @@ <h1>ApplyStringOrNumericBinaryOperator ( _lval_, _opText_, _rval_ )</h1>
1766317659
<p>No hint is provided in the calls to ToPrimitive in steps <emu-xref href="#step-binary-op-toprimitive-lval"></emu-xref> and <emu-xref href="#step-binary-op-toprimitive-rval"></emu-xref>. All standard objects except Date objects handle the absence of a hint as if ~number~ were given; Date objects handle the absence of a hint as if ~string~ were given. Exotic objects may handle the absence of a hint in some other manner.</p>
1766417660
</emu-note>
1766517661
<emu-note>
17666-
<p>Step <emu-xref href="#step-binary-op-string-check"></emu-xref> differs from step <emu-xref href="#step-arc-string-check"></emu-xref> of the Abstract Relational Comparison algorithm, by using the logical-or operation instead of the logical-and operation.</p>
17662+
<p>Step <emu-xref href="#step-binary-op-string-check"></emu-xref> differs from step <emu-xref href="#step-arc-string-check"></emu-xref> of the IsLessThan algorithm, by using the logical-or operation instead of the logical-and operation.</p>
1766717663
</emu-note>
1766817664
</emu-clause>
1766917665

@@ -27722,7 +27718,7 @@ <h1>Math.max ( ..._args_ )</h1>
2772227718
1. Return _highest_.
2772327719
</emu-alg>
2772427720
<emu-note>
27725-
<p>The comparison of values to determine the largest value is done using the Abstract Relational Comparison algorithm except that *+0*<sub>𝔽</sub> is considered to be larger than *-0*<sub>𝔽</sub>.</p>
27721+
<p>The comparison of values to determine the largest value is done using the IsLessThan algorithm except that *+0*<sub>𝔽</sub> is considered to be larger than *-0*<sub>𝔽</sub>.</p>
2772627722
</emu-note>
2772727723
<p>The *"length"* property of the `max` method is *2*<sub>𝔽</sub>.</p>
2772827724
</emu-clause>
@@ -27744,7 +27740,7 @@ <h1>Math.min ( ..._args_ )</h1>
2774427740
1. Return _lowest_.
2774527741
</emu-alg>
2774627742
<emu-note>
27747-
<p>The comparison of values to determine the largest value is done using the Abstract Relational Comparison algorithm except that *+0*<sub>𝔽</sub> is considered to be larger than *-0*<sub>𝔽</sub>.</p>
27743+
<p>The comparison of values to determine the largest value is done using the IsLessThan algorithm except that *+0*<sub>𝔽</sub> is considered to be larger than *-0*<sub>𝔽</sub>.</p>
2774827744
</emu-note>
2774927745
<p>The *"length"* property of the `min` method is *2*<sub>𝔽</sub>.</p>
2775027746
</emu-clause>
@@ -33430,9 +33426,9 @@ <h1>SortCompare ( _x_, _y_ )</h1>
3343033426
1. Return _v_.
3343133427
1. [id="step-sortcompare-tostring-x"] Let _xString_ be ? ToString(_x_).
3343233428
1. [id="step-sortcompare-tostring-y"] Let _yString_ be ? ToString(_y_).
33433-
1. Let _xSmaller_ be the result of performing Abstract Relational Comparison _xString_ &lt; _yString_.
33429+
1. Let _xSmaller_ be IsLessThan(_xString_, _yString_).
3343433430
1. If _xSmaller_ is *true*, return *-1*<sub>𝔽</sub>.
33435-
1. Let _ySmaller_ be the result of performing Abstract Relational Comparison _yString_ &lt; _xString_.
33431+
1. Let _ySmaller_ be IsLessThan(_yString_, _xString_).
3343633432
1. If _ySmaller_ is *true*, return *1*<sub>𝔽</sub>.
3343733433
1. Return *+0*<sub>𝔽</sub>.
3343833434
</emu-alg>

0 commit comments

Comments
Β (0)