Skip to content

Commit

Permalink
Editorial: use abstract closures in MakeArg{Getter,Setter} (tc39#2439)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored and mathiasbynens committed Oct 18, 2021
1 parent f89eaf7 commit bb614d8
Showing 1 changed file with 8 additions and 30 deletions.
38 changes: 8 additions & 30 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -12108,46 +12108,24 @@ <h1>CreateMappedArgumentsObject ( _func_, _formals_, _argumentsList_, _env_ )</h
<h1>MakeArgGetter ( _name_, _env_ )</h1>
<p>The abstract operation MakeArgGetter takes arguments _name_ (a String) and _env_ (an Environment Record). It creates a built-in function object that when executed returns the value bound for _name_ in _env_. It performs the following steps when called:</p>
<emu-alg>
1. Let _steps_ be the steps of an ArgGetter function as specified below.
1. Let _length_ be the number of non-optional parameters of an ArgGetter function as specified below.
1. Let _getter_ be ! CreateBuiltinFunction(_steps_, _length_, *""*, &laquo; [[Name]], [[Env]] &raquo;).
1. Set _getter_.[[Name]] to _name_.
1. Set _getter_.[[Env]] to _env_.
1. Let _getterClosure_ be a new Abstract Closure with no parameters that captures _name_ and _env_ and performs the following steps when called:
1. Return _env_.GetBindingValue(_name_, *false*).
1. Let _getter_ be ! CreateBuiltinFunction(_getterClosure_, 0, *""*, &laquo; &raquo;).
1. NOTE: _getter_ is never directly accessible to ECMAScript code.
1. Return _getter_.
</emu-alg>
<p>An ArgGetter function is an anonymous built-in function with [[Name]] and [[Env]] internal slots. When an ArgGetter function that expects no arguments is called it performs the following steps:</p>
<emu-alg>
1. Let _f_ be the active function object.
1. Let _name_ be _f_.[[Name]].
1. Let _env_ be _f_.[[Env]].
1. Return _env_.GetBindingValue(_name_, *false*).
</emu-alg>
<emu-note>
<p>ArgGetter functions are never directly accessible to ECMAScript code.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-makeargsetter" aoid="MakeArgSetter">
<h1>MakeArgSetter ( _name_, _env_ )</h1>
<p>The abstract operation MakeArgSetter takes arguments _name_ (a String) and _env_ (an Environment Record). It creates a built-in function object that when executed sets the value bound for _name_ in _env_. It performs the following steps when called:</p>
<emu-alg>
1. Let _steps_ be the steps of an ArgSetter function as specified below.
1. Let _length_ be the number of non-optional parameters of an ArgSetter function as specified below.
1. Let _setter_ be ! CreateBuiltinFunction(_steps_, _length_, *""*, &laquo; [[Name]], [[Env]] &raquo;).
1. Set _setter_.[[Name]] to _name_.
1. Set _setter_.[[Env]] to _env_.
1. Let _setterClosure_ be a new Abstract Closure with parameters (_value_) that captures _name_ and _env_ and performs the following steps when called:
1. Return _env_.SetMutableBinding(_name_, _value_, *false*).
1. Let _setter_ be ! CreateBuiltinFunction(_setterClosure_, 1, *""*, &laquo; &raquo;).
1. NOTE: _setter_ is never directly accessible to ECMAScript code.
1. Return _setter_.
</emu-alg>
<p>An ArgSetter function is an anonymous built-in function with [[Name]] and [[Env]] internal slots. When an ArgSetter function is called with argument _value_ it performs the following steps:</p>
<emu-alg>
1. Let _f_ be the active function object.
1. Let _name_ be _f_.[[Name]].
1. Let _env_ be _f_.[[Env]].
1. Return _env_.SetMutableBinding(_name_, _value_, *false*).
</emu-alg>
<emu-note>
<p>ArgSetter functions are never directly accessible to ECMAScript code.</p>
</emu-note>
</emu-clause>
</emu-clause>
</emu-clause>
Expand Down

0 comments on commit bb614d8

Please sign in to comment.