Skip to content
Open
Changes from 2 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
70 changes: 37 additions & 33 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -48683,16 +48683,18 @@ <h1>Iterator.prototype.drop ( _limit_ )</h1>
1. If _numLimit_ is *NaN*, then
1. Let _error_ be ThrowCompletion(a newly created *RangeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. If _numLimit_ is finite and _numLimit_ > 𝔽(2<sup>53</sup> - 1), then
1. Let _error_ be ThrowCompletion(a newly created *RangeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. Let _integerLimit_ be ! ToIntegerOrInfinity(_numLimit_).
1. If _integerLimit_ &lt; 0, then
1. Let _error_ be ThrowCompletion(a newly created *RangeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. Set _iterated_ to ? GetIteratorDirect(_obj_).
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _integerLimit_ and performs the following steps when called:
1. Let _remaining_ be _integerLimit_.
1. Repeat, while _remaining_ > 0,
1. If _remaining_ ≠ +∞, then
1. Set _remaining_ to _remaining_ - 1.
1. Let _remaining_ be 𝔽(_integerLimit_).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the check above that _numLimit_ is either Infinity or a safe integer, what is the observable difference between doing all of these steps in the floats space vs mathematical values space?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is one. Just makes it very obvious to implementers that it's okay to do all of this with floats.

1. Repeat, while _remaining_ > *+0*<sub>𝔽</sub>,
1. Set _remaining_ to _remaining_ - *1*<sub>𝔽</sub>.
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is ~done~, return ReturnCompletion(*undefined*).
1. Repeat,
Expand All @@ -48717,14 +48719,14 @@ <h1>Iterator.prototype.every ( _predicate_ )</h1>
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. Set _iterated_ to ? GetIteratorDirect(_obj_).
1. Let _counter_ be 0.
1. Let _counter_ be *+0*<sub>𝔽</sub>.
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *true*.
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, _counter_ »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *false*, return ? IteratorClose(_iterated_, NormalCompletion(*false*)).
1. Set _counter_ to _counter_ + 1.
1. Set _counter_ to _counter_ + *1*<sub>𝔽</sub>.
</emu-alg>
</emu-clause>

Expand All @@ -48740,16 +48742,16 @@ <h1>Iterator.prototype.filter ( _predicate_ )</h1>
1. Return ? IteratorClose(_iterated_, _error_).
1. Set _iterated_ to ? GetIteratorDirect(_obj_).
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _predicate_ and performs the following steps when called:
1. Let _counter_ be 0.
1. Let _counter_ be *+0*<sub>𝔽</sub>.
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return ReturnCompletion(*undefined*).
1. Let _selected_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. Let _selected_ be Completion(Call(_predicate_, *undefined*, « _value_, _counter_ »)).
1. IfAbruptCloseIterator(_selected_, _iterated_).
1. If ToBoolean(_selected_) is *true*, then
1. Let _completion_ be Completion(Yield(_value_)).
1. IfAbruptCloseIterator(_completion_, _iterated_).
1. Set _counter_ to _counter_ + 1.
1. Set _counter_ to _counter_ + *1*<sub>𝔽</sub>.
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
1. Set _result_.[[UnderlyingIterators]] to « _iterated_ ».
1. Return _result_.
Expand All @@ -48767,14 +48769,14 @@ <h1>Iterator.prototype.find ( _predicate_ )</h1>
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. Set _iterated_ to ? GetIteratorDirect(_obj_).
1. Let _counter_ be 0.
1. Let _counter_ be *+0*<sub>𝔽</sub>.
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *undefined*.
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, _counter_ »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *true*, return ? IteratorClose(_iterated_, NormalCompletion(_value_)).
1. Set _counter_ to _counter_ + 1.
1. Set _counter_ to _counter_ + *1*<sub>𝔽</sub>.
</emu-alg>
</emu-clause>

Expand All @@ -48790,11 +48792,11 @@ <h1>Iterator.prototype.flatMap ( _mapper_ )</h1>
1. Return ? IteratorClose(_iterated_, _error_).
1. Set _iterated_ to ? GetIteratorDirect(_obj_).
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
1. Let _counter_ be 0.
1. Let _counter_ be *+0*<sub>𝔽</sub>.
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return ReturnCompletion(*undefined*).
1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, _counter_ »)).
1. IfAbruptCloseIterator(_mapped_, _iterated_).
1. Let _innerIterator_ be Completion(GetIteratorFlattenable(_mapped_, ~reject-primitives~)).
1. IfAbruptCloseIterator(_innerIterator_, _iterated_).
Expand All @@ -48810,7 +48812,7 @@ <h1>Iterator.prototype.flatMap ( _mapper_ )</h1>
1. Let _backupCompletion_ be Completion(IteratorClose(_innerIterator_, _completion_)).
1. IfAbruptCloseIterator(_backupCompletion_, _iterated_).
1. Return ? IteratorClose(_iterated_, _completion_).
1. Set _counter_ to _counter_ + 1.
1. Set _counter_ to _counter_ + *1*<sub>𝔽</sub>.
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
1. Set _result_.[[UnderlyingIterators]] to « _iterated_ ».
1. Return _result_.
Expand All @@ -48828,13 +48830,13 @@ <h1>Iterator.prototype.forEach ( _procedure_ )</h1>
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. Set _iterated_ to ? GetIteratorDirect(_obj_).
1. Let _counter_ be 0.
1. Let _counter_ be *+0*<sub>𝔽</sub>.
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *undefined*.
1. Let _result_ be Completion(Call(_procedure_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. Let _result_ be Completion(Call(_procedure_, *undefined*, « _value_, _counter_ »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. Set _counter_ to _counter_ + 1.
1. Set _counter_ to _counter_ + *1*<sub>𝔽</sub>.
</emu-alg>
</emu-clause>

Expand All @@ -48850,15 +48852,15 @@ <h1>Iterator.prototype.map ( _mapper_ )</h1>
1. Return ? IteratorClose(_iterated_, _error_).
1. Set _iterated_ to ? GetIteratorDirect(_obj_).
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
1. Let _counter_ be 0.
1. Let _counter_ be *+0*<sub>𝔽</sub>.
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return ReturnCompletion(*undefined*).
1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, _counter_ »)).
1. IfAbruptCloseIterator(_mapped_, _iterated_).
1. Let _completion_ be Completion(Yield(_mapped_)).
1. IfAbruptCloseIterator(_completion_, _iterated_).
1. Set _counter_ to _counter_ + 1.
1. Set _counter_ to _counter_ + *1*<sub>𝔽</sub>.
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
1. Set _result_.[[UnderlyingIterators]] to « _iterated_ ».
1. Return _result_.
Expand All @@ -48879,17 +48881,17 @@ <h1>Iterator.prototype.reduce ( _reducer_ [ , _initialValue_ ] )</h1>
1. If _initialValue_ is not present, then
1. Let _accumulator_ be ? IteratorStepValue(_iterated_).
1. If _accumulator_ is ~done~, throw a *TypeError* exception.
1. Let _counter_ be 1.
1. Let _counter_ be *1*<sub>𝔽</sub>.
1. Else,
1. Let _accumulator_ be _initialValue_.
1. Let _counter_ be 0.
1. Let _counter_ be *+0*<sub>𝔽</sub>.
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return _accumulator_.
1. Let _result_ be Completion(Call(_reducer_, *undefined*, « _accumulator_, _value_, 𝔽(_counter_) »)).
1. Let _result_ be Completion(Call(_reducer_, *undefined*, « _accumulator_, _value_, _counter_ »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. Set _accumulator_ to _result_.
1. Set _counter_ to _counter_ + 1.
1. Set _counter_ to _counter_ + *1*<sub>𝔽</sub>.
</emu-alg>
</emu-clause>

Expand All @@ -48904,14 +48906,14 @@ <h1>Iterator.prototype.some ( _predicate_ )</h1>
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. Set _iterated_ to ? GetIteratorDirect(_obj_).
1. Let _counter_ be 0.
1. Let _counter_ be *+0*<sub>𝔽</sub>.
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *false*.
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. Let _result_ be Completion(Call(_predicate_, *undefined*, « _value_, _counter_ »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *true*, return ? IteratorClose(_iterated_, NormalCompletion(*true*)).
1. Set _counter_ to _counter_ + 1.
1. Set _counter_ to _counter_ + *1*<sub>𝔽</sub>.
</emu-alg>
</emu-clause>

Expand All @@ -48927,18 +48929,20 @@ <h1>Iterator.prototype.take ( _limit_ )</h1>
1. If _numLimit_ is *NaN*, then
1. Let _error_ be ThrowCompletion(a newly created *RangeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. If _numLimit_ is finite and _numLimit_ > 𝔽(2<sub>53</sub> - 1), then

Check warning on line 48932 in spec.html

View workflow job for this annotation

GitHub Actions / esmeta yet phrases detection

Newly Introduced Unknown Step

This step in INTRINSICS.Iterator.prototype.take cannot be understood by ESMeta. Type check for this algorithm will not be performed after this line.
Comment thread
michaelficarra marked this conversation as resolved.
Outdated
1. Let _error_ be ThrowCompletion(a newly created *RangeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. Let _integerLimit_ be ! ToIntegerOrInfinity(_numLimit_).
1. If _integerLimit_ &lt; 0, then
1. Let _error_ be ThrowCompletion(a newly created *RangeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. Set _iterated_ to ? GetIteratorDirect(_obj_).
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _integerLimit_ and performs the following steps when called:
1. Let _remaining_ be _integerLimit_.
1. Let _remaining_ be 𝔽(_integerLimit_).
1. Repeat,
1. If _remaining_ = 0, then
1. If _remaining_ is *+0*<sub>𝔽</sub>, then
1. Return ? IteratorClose(_iterated_, ReturnCompletion(*undefined*)).
1. If _remaining_ ≠ +∞, then
1. Set _remaining_ to _remaining_ - 1.
1. Set _remaining_ to _remaining_ - *1*<sub>𝔽</sub>.
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return ReturnCompletion(*undefined*).
1. Let _completion_ be Completion(Yield(_value_)).
Expand Down
Loading