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: Use CreateBuiltinFunction with Abstract Closures #548

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 9 additions & 31 deletions spec/collator.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,49 +169,27 @@ <h1>Intl.Collator.prototype [ @@toStringTag ]</h1>
</p>
</emu-clause>

<emu-clause id="sec-intl.collator.prototype.compare">
<emu-clause id="sec-intl.collator.prototype.compare" oldids="sec-collator-compare-functions">
<h1>get Intl.Collator.prototype.compare</h1>

<p>
This named accessor property returns a function that compares two strings according to the sort order of this Collator object.
</p>
<p>
Intl.Collator.prototype.compare is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:
</p>

<p>`Intl.Collator.prototype.compare` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _collator_ be the *this* value.
1. Perform ? RequireInternalSlot(_collator_, [[InitializedCollator]]).
1. If _collator_.[[BoundCompare]] is *undefined*, then
1. Let _F_ be a new built-in function object as defined in <emu-xref href="#sec-collator-compare-functions"></emu-xref>.
1. Set _F_.[[Collator]] to _collator_.
1. Let _closure_ be a new Abstract Closure with parameters (_x_, _y_) that captures _collator_ and performs the following steps when called:
1. Let _X_ be ? ToString(_x_).
1. Let _Y_ be ? ToString(_y_).
1. Return CompareStrings(_collator_, _X_, _Y_).
1. Let _F_ be CreateBuiltinFunction(_closure_, 2, *""*, &laquo; &raquo;).
1. Set _collator_.[[BoundCompare]] to _F_.
1. Return _collator_.[[BoundCompare]].
</emu-alg>

<emu-note>
The returned function is bound to _collator_ so that it can be passed directly to `Array.prototype.sort` or other functions.
<p>The returned function is bound to _collator_ so that it can be passed directly to `Array.prototype.sort` or other functions.</p>
<p>This is considered a historical artefact, as part of a convention which is no longer followed for new features, but is preserved to maintain compatibility with existing programs.</p>
</emu-note>

<emu-clause id="sec-collator-compare-functions">
<h1>Collator Compare Functions</h1>

<p>A Collator compare function is an anonymous built-in function that has a [[Collator]] internal slot.</p>
<p>When a Collator compare function _F_ is called with arguments _x_ and _y_, the following steps are taken:</p>

<emu-alg>
1. Let _collator_ be _F_.[[Collator]].
1. Assert: Type(_collator_) is Object and _collator_ has an [[InitializedCollator]] internal slot.
1. If _x_ is not provided, let _x_ be *undefined*.
1. If _y_ is not provided, let _y_ be *undefined*.
1. Let _X_ be ? ToString(_x_).
1. Let _Y_ be ? ToString(_y_).
1. Return CompareStrings(_collator_, _X_, _Y_).
</emu-alg>

<p>The *"length"* property of a Collator compare function is 2.</p>
</emu-clause>

<emu-clause id="sec-collator-comparestrings" aoid="CompareStrings">
<h1>CompareStrings ( _collator_, _x_, _y_ )</h1>

Expand Down
42 changes: 11 additions & 31 deletions spec/datetimeformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,27 +311,6 @@ <h1>BestFitFormatMatcher ( _options_, _formats_ )</h1>
</p>
</emu-clause>

<emu-clause id="sec-datetime-format-functions">
<h1>DateTime Format Functions</h1>

<p>A DateTime format function is an anonymous built-in function that has a [[DateTimeFormat]] internal slot.</p>
<p>When a DateTime format function _F_ is called with optional argument _date_, the following steps are taken:</p>

<emu-alg>
1. Let _dtf_ be _F_.[[DateTimeFormat]].
1. Assert: Type(_dtf_) is Object and _dtf_ has an [[InitializedDateTimeFormat]] internal slot.
1. If _date_ is not provided or is *undefined*, then
1. Let _x_ be Call(%Date.now%, *undefined*).
1. Else,
1. Let _x_ be ? ToNumber(_date_).
1. Return ? FormatDateTime(_dtf_, _x_).
</emu-alg>

<p>
The *"length"* property of a DateTime format function is 1.
</p>
</emu-clause>

<emu-clause id="sec-formatdatetimepattern" aoid="FormatDateTimePattern">
<h1>FormatDateTimePattern ( _dateTimeFormat_, _patternParts_, _x_, _rangeFormatOptions_ )</h1>

Expand Down Expand Up @@ -1017,27 +996,28 @@ <h1>Intl.DateTimeFormat.prototype [ @@toStringTag ]</h1>
</p>
</emu-clause>

<emu-clause id="sec-intl.datetimeformat.prototype.format">
<emu-clause id="sec-intl.datetimeformat.prototype.format" oldids="sec-datetime-format-functions">
<h1>get Intl.DateTimeFormat.prototype.format</h1>

<p>
Intl.DateTimeFormat.prototype.format is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:
</p>

<p>`Intl.DateTimeFormat.prototype.format` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _dtf_ be the *this* value.
1. If Type(_dtf_) is not Object, throw a *TypeError* exception.
1. Let _dtf_ be ? UnwrapDateTimeFormat(_dtf_).
1. If _dtf_.[[BoundFormat]] is *undefined*, then
1. Let _F_ be a new built-in function object as defined in DateTime Format Functions (<emu-xref href="#sec-datetime-format-functions"></emu-xref>).
1. Set _F_.[[DateTimeFormat]] to _dtf_.
1. Let _closure_ be a new Abstract Closure with parameters (_date_) that captures _dtf_ and performs the following steps when called:
1. If _date_ is *undefined*, then
1. Let _x_ be Call(%Date.now%, *undefined*).
1. Else,
1. Let _x_ be ? ToNumber(_date_).
1. Return ? FormatDateTime(_dtf_, _x_).
1. Let _F_ be CreateBuiltinFunction(_closure_, 1, *""*, &laquo; &raquo;).
1. Set _dtf_.[[BoundFormat]] to _F_.
1. Return _dtf_.[[BoundFormat]].
</emu-alg>

<emu-note>
The returned function is bound to _dtf_ so that it can be passed directly to `Array.prototype.map` or other functions.
This is considered a historical artefact, as part of a convention which is no longer followed for new features, but is preserved to maintain compatibility with existing programs.
<p>The returned function is bound to _dtf_ so that it can be passed directly to `Array.prototype.map` or other functions.</p>
<p>This is considered a historical artefact, as part of a convention which is no longer followed for new features, but is preserved to maintain compatibility with existing programs.</p>
</emu-note>
</emu-clause>

Expand Down
37 changes: 8 additions & 29 deletions spec/numberformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,6 @@ <h1>CurrencyDigits ( _currency_ )</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-number-format-functions">
<h1>Number Format Functions</h1>

<p>A Number format function is an anonymous built-in function that has a [[NumberFormat]] internal slot.</p>
<p>When a Number format function _F_ is called with optional argument _value_, the following steps are taken:</p>

<emu-alg>
1. Let _nf_ be _F_.[[NumberFormat]].
1. Assert: Type(_nf_) is Object and _nf_ has an [[InitializedNumberFormat]] internal slot.
1. If _value_ is not provided, let _value_ be *undefined*.
1. Let _x_ be ? ToNumeric(_value_).
1. Return ? FormatNumeric(_nf_, _x_).
</emu-alg>

<p>
The *"length"* property of a Number format function is 1.
</p>
</emu-clause>

<emu-clause id="sec-formatnumberstring" aoid="FormatNumericToString">
<h1>FormatNumericToString ( _intlObject_, _x_ )</h1>

Expand Down Expand Up @@ -1025,27 +1006,25 @@ <h1>Intl.NumberFormat.prototype [ @@toStringTag ]</h1>
</p>
</emu-clause>

<emu-clause id="sec-intl.numberformat.prototype.format">
<emu-clause id="sec-intl.numberformat.prototype.format" oldids="sec-number-format-functions">
<h1>get Intl.NumberFormat.prototype.format</h1>

<p>
Intl.NumberFormat.prototype.format is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:
</p>

<p>Intl.NumberFormat.prototype.format is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _nf_ be the *this* value.
1. If Type(_nf_) is not Object, throw a *TypeError* exception.
1. Let _nf_ be ? UnwrapNumberFormat(_nf_).
1. If _nf_.[[BoundFormat]] is *undefined*, then
1. Let _F_ be a new built-in function object as defined in Number Format Functions (<emu-xref href="#sec-number-format-functions"></emu-xref>).
1. Set _F_.[[NumberFormat]] to _nf_.
1. Let _closure_ be a new Abstract Closure with parameters (_value_) that captures _nf_ and performs the following steps when called:
1. Let _x_ be ? ToNumeric(_value_).
1. Return ? FormatNumeric(_nf_, _x_).
1. Let _F_ be CreateBuiltinFunction(_closure_, 1, *""*, &laquo; &raquo;).
1. Set _nf_.[[BoundFormat]] to _F_.
1. Return _nf_.[[BoundFormat]].
</emu-alg>

<emu-note>
The returned function is bound to _nf_ so that it can be passed directly to `Array.prototype.map` or other functions.
This is considered a historical artefact, as part of a convention which is no longer followed for new features, but is preserved to maintain compatibility with existing programs.
<p>The returned function is bound to _nf_ so that it can be passed directly to `Array.prototype.map` or other functions.</p>
<p>This is considered a historical artefact, as part of a convention which is no longer followed for new features, but is preserved to maintain compatibility with existing programs.</p>
</emu-note>
</emu-clause>

Expand Down