Skip to content

Commit

Permalink
'length' is an own property on Tuple (#310)
Browse files Browse the repository at this point in the history
* 'length' is an own property on tuple
  • Loading branch information
acutmore authored Jun 30, 2022
1 parent 827d308 commit fb9cd57
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
9 changes: 0 additions & 9 deletions spec/immutable-data-structures.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,6 @@ <h1>Properties of the Tuple Prototype Object</h1>
<h1>Tuple.prototype.constructor</h1>
<p>The initial value of *Tuple.prototype.constructor* is the intrinsic object %Tuple%</p>
</emu-clause>
<emu-clause id="sec-tuple.prototype.length">
<h1>get Tuple.prototype.length</h1>
<p>*Tuple.prototype.length* is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _T_ be ? thisTupleValue(*this* value).
1. Let _size_ be the length of _T_.[[Sequence]].
1. Return 𝔽(_size_).
</emu-alg>
</emu-clause>
<emu-clause id="sec-tuple.prototype.at">
<h1>Tuple.prototype.at ( _index_ )</h1>
<p>`Tuple.prototype.at` is a distinct function that implements the same algorithm as `Array.prototype.at` as defined in <emu-xref href="#sec-array.prototype.at"></emu-xref> except that ? thisTupleValue(*this* value) is used instead of directly accessing the *this* value. The implementation of the algorithm may be optimized with the knowledge that the *this* value is an object that has a fixed length and whose <emu-xref href="#integer-index">integer-indexed</emu-xref> properties are not sparse, do not change, and their access is not observable. However, such optimization must not introduce any observable changes in the specified behaviour of the algorithm.</p>
Expand Down
33 changes: 23 additions & 10 deletions spec/ordinary-and-exotic-object-behaviours.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1>Record Exotic Objects</h1>
<p>An object is a <dfn id="record-exotic-object">Record exotic object</dfn> (or simply, a Record object) if its following internal methods use the following implementations and is an <emu-xref href="#sec-immutable-prototype-exotic-objects">Immutable Prototype Exotic Object</emu-xref>. These methods are installed in RecordCreate.</p>

<p>Record exotic objects have the same internal slots as ordinary objects. They also have a [[RecordData]] internal slot.</p>

<emu-clause id="sec-record-exotic-objects-isextensible" type="internal method">
<h1>[[IsExtensible]] ()</h1>
<dl class="header">
Expand Down Expand Up @@ -59,7 +59,7 @@ <h1>[[DefineOwnProperty]] ( _P_, _Desc_ )</h1>
1. Return *false*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-record-exotic-objects-hasproperty-p" type="internal method">
<h1>[[HasProperty]] ( _P_ )</h1>
<dl class="header">
Expand All @@ -71,7 +71,7 @@ <h1>[[HasProperty]] ( _P_ )</h1>
1. Return ! RecordHasProperty(_R_, _P_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-record-exotic-objects-get-p-receiver" type="internal method">
<h1>[[Get]] ( _P_, _Receiver_ )</h1>
<emu-alg>
Expand Down Expand Up @@ -144,7 +144,7 @@ <h1>
1. Return _R_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-recordhasproperty-r-p" type="abstract operation">
<h1>
RecordHasProperty (
Expand Down Expand Up @@ -191,7 +191,7 @@ <h1>

<emu-clause id="sec-tuple-exotic-objects">
<h1>Tuple Exotic Objects</h1>
<p>A Tuple object is an exotic object that encapsulates a Tuple value and exposes virtual integer-indexed data properties corresponding to the individual entries set on the underlying Tuple value. All keys properties are non-writable and non-configurable.</p>
<p>A Tuple object is an exotic object that encapsulates a Tuple value and exposes virtual integer-indexed data properties corresponding to the individual entries set on the underlying Tuple value. Tuple exotic objects always have a data property named *"length"* whose value is the number of entries in the underlying Tuple value. All keys properties are non-writable and non-configurable.</p>

<p>An object is a <dfn id="tuple-exotic-object">Tuple exotic object</dfn> (or simply, a Tuple object) if its following internal methods use the following implementations and is an <emu-xref href="#sec-immutable-prototype-exotic-objects">Immutable Prototype Exotic Object</emu-xref>.</p>

Expand All @@ -211,6 +211,9 @@ <h1>[[GetOwnProperty]] ( _P_ )</h1>
<emu-alg>
1. Assert: IsPropertyKey(_P_) is *true*.
1. If Type(_P_) is a Symbol, return *false*.
1. If _P_ is *"length"*, then
1. Let _length_ be the length of _T_.[[Sequence]].
1. Return the PropertyDescriptor { [[Value]]: 𝔽(_length_), [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.
1. Let _numericIndex_ be ! CanonicalNumericIndexString(_P_).
1. If _numericIndex_ is *undefined*, return *undefined*.
1. Let _value_ be ? TupleGet(_T_, _numericIndex_)
Expand All @@ -228,6 +231,10 @@ <h1>[[DefineOwnProperty]] ( _P_, _Desc_ )</h1>
<emu-alg>
1. Assert: IsPropertyKey(_P_) is *true*.
1. If Type(_P_) is a Symbol, return *false*.
1. If _P_ is *"length"*, then
1. Let _lengthDesc_ be ! _T_.[[GetOwnProperty]](_P_).
1. Let _extensible_ be _T_.[[Extensible]].
1. Return ! IsCompatiblePropertyDescriptor(_extensible_, _Desc_, _lengthDesc_).
1. If _Desc_.[[Writable]] is present and has value *true*, return *false*.
1. If _Desc_.[[Enumerable]] is present and has value *false*, return *false*.
1. If _Desc_.[[Configurable]] is present and has value *true*, return *false*.
Expand All @@ -240,7 +247,7 @@ <h1>[[DefineOwnProperty]] ( _P_, _Desc_ )</h1>
1. Return *false*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-tuple-exotic-objects-hasproperty-p" type="internal method">
<h1>[[HasProperty]] ( _P_ )</h1>
<dl class="header">
Expand All @@ -250,13 +257,14 @@ <h1>[[HasProperty]] ( _P_ )</h1>
<emu-alg>
1. Assert: IsPropertyKey(_P_) is *true*.
1. If Type(_P_) is not Symbol, then
1. If _P_ is *"length"*, return *true*.
1. Let _numericIndex_ be ! CanonicalNumericIndexString(_P_).
1. If _numericIndex_ is not *undefined*, return ? IsValidTupleIndex(_T_, _numericIndex_)
1. Let _parent_ be ? _T_.[[GetPrototypeOf]]().
1. Return ? _parent_.[[HasProperty]](_P_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-tuple-exotic-objects-get-p-receiver" type="internal method">
<h1>[[Get]] ( _P_, _Receiver_ )</h1>
<dl class="header">
Expand All @@ -265,6 +273,9 @@ <h1>[[Get]] ( _P_, _Receiver_ )</h1>
</dl>
<emu-alg>
1. Assert: IsPropertyKey(_P_) is *true*.
1. If _P_ is *"length"*, then
1. Let _length_ be the length of _T_.[[Sequence]].
1. Return 𝔽(_length_).
1. If Type(_P_) is not Symbol, then
1. Let _numericIndex_ be ! CanonicalNumericIndexString(_P_).
1. If _numericIndex_ is not *undefined*, then
Expand Down Expand Up @@ -297,14 +308,15 @@ <h1>[[Delete]] ( _P_ )</h1>
<emu-alg>
1. Assert: IsPropertyKey(_P_) is *true*.
1. If Type(_P_) is a Symbol, return *true*.
1. If _P_ is *"length"*, return *false*.
1. Let _numericIndex_ be ! CanonicalNumericIndexString(_P_).
1. If _numericIndex_ is *undefined*, return *true*.
1. Let _isValidIndex_ ? IsValidTupleIndex( _T_, _numericIndex_ ).
1. If _isValidIndex_ is *false*, return *true*.
1. Return *false*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-tuple-exotic-objects-ownpropertykeys" type="internal method">
<h1>[[OwnPropertyKeys]] ( )</h1>
<dl class="header">
Expand All @@ -320,11 +332,12 @@ <h1>[[OwnPropertyKeys]] ( )</h1>
1. Repeat, while _index_ &lt; _len_,
1. Add ! ToString(_index_) to _keys_.
1. Set _index_ to _index_ + 1.
1. Add *"length"* to _keys_.
1. Return _keys_
</emu-alg>
</emu-clause>


<emu-clause id="sec-tuplecreate" type="abstract operation">
<h1>
TupleCreate (
Expand All @@ -343,7 +356,7 @@ <h1>
1. Return _T_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-isvalidtupleindex-r-p" type="abstract operation">
<h1>
IsValidTupleIndex (
Expand Down

0 comments on commit fb9cd57

Please sign in to comment.