Skip to content

Commit

Permalink
Editorial: Define "Let"/"Set"; correct usage (#958)
Browse files Browse the repository at this point in the history
* Editorial: Define `Let` and `Set`
* Editorial: Correct usage of Let/Set
  • Loading branch information
jugglinmike authored and bterlson committed Jul 25, 2017
1 parent 785c053 commit 77b8451
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ <h1>Algorithm Conventions</h1>
<p>A step may specify the iterative application of its substeps.</p>
<p>A step that begins with &ldquo;<dfn id="assert">Assert</dfn>:&rdquo; asserts an invariant condition of its algorithm. Such assertions are used to make explicit algorithmic invariants that would otherwise be implicit. Such assertions add no additional semantic requirements and hence need not be checked by an implementation. They are used simply to clarify algorithms.</p>
<p>Algorithm steps may declare named aliases for any value using the form &ldquo;Let _x_ be _someValue_&rdquo;. These aliases are reference-like in that both _x_ and _someValue_ refer to the same underlying data and modifications to either are visible to both. Algorithm steps that want to avoid this reference-like behaviour should explicitly make a copy of the right-hand side: &ldquo;Let _x_ be a copy of _someValue_&rdquo; creates a shallow copy of _someValue_.</p>
<p>Once declared, aliases may be referenced in any subsequent step or substep thereof, but they may not be referenced from steps at a higher level. Aliases may be modified using the form &ldquo;Set _x_ to _someOtherValue_&rdquo;.</p>

<emu-clause id=sec-algorithm-conventions-abstract-operations>
<h1>Abstract Operations</h1>
Expand Down Expand Up @@ -31272,6 +31273,7 @@ <h1>Array.prototype.reduce ( _callbackfn_ [ , _initialValue_ ] )</h1>
1. If IsCallable(_callbackfn_) is *false*, throw a *TypeError* exception.
1. If _len_ is 0 and _initialValue_ is not present, throw a *TypeError* exception.
1. Let _k_ be 0.
1. Let _accumulator_ be *undefined*.
1. If _initialValue_ is present, then
1. Set _accumulator_ to _initialValue_.
1. Else _initialValue_ is not present,
Expand All @@ -31280,15 +31282,15 @@ <h1>Array.prototype.reduce ( _callbackfn_ [ , _initialValue_ ] )</h1>
1. Let _Pk_ be ! ToString(_k_).
1. Let _kPresent_ be ? HasProperty(_O_, _Pk_).
1. If _kPresent_ is *true*, then
1. Let _accumulator_ be ? Get(_O_, _Pk_).
1. Set _accumulator_ to ? Get(_O_, _Pk_).
1. Increase _k_ by 1.
1. If _kPresent_ is *false*, throw a *TypeError* exception.
1. Repeat, while _k_ &lt; _len_
1. Let _Pk_ be ! ToString(_k_).
1. Let _kPresent_ be ? HasProperty(_O_, _Pk_).
1. If _kPresent_ is *true*, then
1. Let _kValue_ be ? Get(_O_, _Pk_).
1. Let _accumulator_ be ? Call(_callbackfn_, *undefined*, &laquo; _accumulator_, _kValue_, _k_, _O_ &raquo;).
1. Set _accumulator_ to ? Call(_callbackfn_, *undefined*, &laquo; _accumulator_, _kValue_, _k_, _O_ &raquo;).
1. Increase _k_ by 1.
1. Return _accumulator_.
</emu-alg>
Expand All @@ -31313,6 +31315,7 @@ <h1>Array.prototype.reduceRight ( _callbackfn_ [ , _initialValue_ ] )</h1>
1. If IsCallable(_callbackfn_) is *false*, throw a *TypeError* exception.
1. If _len_ is 0 and _initialValue_ is not present, throw a *TypeError* exception.
1. Let _k_ be _len_-1.
1. Let _accumulator_ be *undefined*.
1. If _initialValue_ is present, then
1. Set _accumulator_ to _initialValue_.
1. Else _initialValue_ is not present,
Expand All @@ -31321,15 +31324,15 @@ <h1>Array.prototype.reduceRight ( _callbackfn_ [ , _initialValue_ ] )</h1>
1. Let _Pk_ be ! ToString(_k_).
1. Let _kPresent_ be ? HasProperty(_O_, _Pk_).
1. If _kPresent_ is *true*, then
1. Let _accumulator_ be ? Get(_O_, _Pk_).
1. Set _accumulator_ to ? Get(_O_, _Pk_).
1. Decrease _k_ by 1.
1. If _kPresent_ is *false*, throw a *TypeError* exception.
1. Repeat, while _k_ &ge; 0
1. Let _Pk_ be ! ToString(_k_).
1. Let _kPresent_ be ? HasProperty(_O_, _Pk_).
1. If _kPresent_ is *true*, then
1. Let _kValue_ be ? Get(_O_, _Pk_).
1. Let _accumulator_ be ? Call(_callbackfn_, *undefined*, &laquo; _accumulator_, _kValue_, _k_, _O_ &raquo;).
1. Set _accumulator_ to ? Call(_callbackfn_, *undefined*, &laquo; _accumulator_, _kValue_, _k_, _O_ &raquo;).
1. Decrease _k_ by 1.
1. Return _accumulator_.
</emu-alg>
Expand Down

0 comments on commit 77b8451

Please sign in to comment.