Skip to content

Commit

Permalink
Editorial: Refactor 10.3 "Built-in Function Objects" (tc39#3145)
Browse files Browse the repository at this point in the history
- Delete prose that repeats step 10 of BuiltinCallOrConstruct.
- Move one sentence to a NOTE-step in BuiltinCallOrConstruct.
- Move two sentences to 18 "ECMAScript Standard Built-in Objects".
- Reword the remains of "Built-in Function Objects".
  • Loading branch information
jmdyck authored and ljharb committed Sep 22, 2023
1 parent 644e586 commit a651255
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -13723,13 +13723,16 @@ <h1>

<emu-clause id="sec-built-in-function-objects">
<h1>Built-in Function Objects</h1>
<p>For a built-in function object defined in this specification, the effect of calling such a function must conform to its specification. An implementation may also provide additional built-in function objects that are not defined in this specification.</p>
<p>Built-in function objects must have the ordinary object behaviour specified in <emu-xref href="#sec-ordinary-object-internal-methods-and-internal-slots"></emu-xref>. All such function objects have [[Prototype]], [[Extensible]], [[Realm]], and [[InitialName]] internal slots. [[Realm]] has the same meaning as in <emu-xref href="#table-internal-slots-of-ecmascript-function-objects"></emu-xref>. The value of the [[InitialName]] internal slot is a String value that is the initial name of the function. It is used by <emu-xref href="#sec-function.prototype.tostring"></emu-xref>.</p>
<p>Unless otherwise specified every built-in function object has the %Function.prototype% object as the initial value of its [[Prototype]] internal slot.</p>
<p>The behaviour specified for each built-in function via algorithm steps or other means is the specification of the function body behaviour for both [[Call]] and [[Construct]] invocations of the function. However, [[Construct]] invocation is not supported by all built-in functions. For each built-in function, when invoked with [[Call]], the [[Call]] _thisArgument_ provides the *this* value, the [[Call]] _argumentsList_ provides the named parameters, and the NewTarget value is *undefined*. When invoked with [[Construct]], the *this* value is uninitialized, the [[Construct]] _argumentsList_ provides the named parameters, and the [[Construct]] _newTarget_ parameter provides the NewTarget value.</p>
<p>Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in the description of a particular function. When a built-in constructor is called as part of a `new` expression the _argumentsList_ parameter of the invoked [[Construct]] internal method provides the values for the built-in constructor's named parameters.</p>
<p>Built-in functions that are not constructors do not have a *"prototype"* property unless otherwise specified in the description of a particular function.</p>
<p>A built-in function object must provide [[Call]] and [[Construct]] internal methods that conform to the following definitions:</p>
<p>A built-in function object is an ordinary object; it must satisfy the requirements for ordinary objects set out in <emu-xref href="#sec-ordinary-object-internal-methods-and-internal-slots"></emu-xref>.</p>
<p>In addition to the internal slots required of every ordinary object (see <emu-xref href="#sec-ordinary-object-internal-methods-and-internal-slots"></emu-xref>), a built-in function object must also have the following internal slots:</p>
<ul>
<li>[[Realm]], a Realm Record that represents the realm in which the function was created.</li>
<li>[[InitialName]], a String that is the initial name of the function. It is used by <emu-xref href="#sec-function.prototype.tostring"></emu-xref>.</li>
</ul>
<p>The initial value of a built-in function object's [[Prototype]] internal slot is %Function.prototype%, unless otherwise specified.</p>
<p>A built-in function object must have a [[Call]] internal method that conforms to the definition in <emu-xref href="#sec-built-in-function-objects-call-thisargument-argumentslist"></emu-xref>.</p>
<p>A built-in function object has a [[Construct]] internal method if and only if it is described as a “constructor”, or some algorithm in this specification explicitly sets its [[Construct]] internal method. Such a [[Construct]] internal method must conform to the definition in <emu-xref href="#sec-built-in-function-objects-construct-argumentslist-newtarget"></emu-xref>.</p>
<p>An implementation may provide additional built-in function objects that are not defined in this specification.</p>

<emu-clause id="sec-built-in-function-objects-call-thisargument-argumentslist" type="internal method">
<h1>
Expand Down Expand Up @@ -13785,6 +13788,7 @@ <h1>
1. Perform any necessary implementation-defined initialization of _calleeContext_.
1. Push _calleeContext_ onto the execution context stack; _calleeContext_ is now the running execution context.
1. [id="step-call-builtin-function-result"] Let _result_ be the Completion Record that is <emu-meta effects="user-code">the result of evaluating</emu-meta> _F_ in a manner that conforms to the specification of _F_. If _thisArgument_ is ~uninitialized~, the *this* value is uninitialized; otherwise, _thisArgument_ provides the *this* value. _argumentsList_ provides the named parameters. _newTarget_ provides the NewTarget value.
1. NOTE: If _F_ is defined in this document, “the specification of _F_” is the behaviour specified for it via algorithm steps or other means.
1. Remove _calleeContext_ from the execution context stack and restore _callerContext_ as the running execution context.
1. Return ? _result_.
</emu-alg>
Expand Down Expand Up @@ -28652,7 +28656,9 @@ <h1>ECMAScript Standard Built-in Objects</h1>
</emu-note>
<p>Unless otherwise specified every built-in function and every built-in constructor has the Function prototype object, which is the initial value of the expression `Function.prototype` (<emu-xref href="#sec-properties-of-the-function-prototype-object"></emu-xref>), as the value of its [[Prototype]] internal slot.</p>
<p>Unless otherwise specified every built-in prototype object has the Object prototype object, which is the initial value of the expression `Object.prototype` (<emu-xref href="#sec-properties-of-the-object-prototype-object"></emu-xref>), as the value of its [[Prototype]] internal slot, except the Object prototype object itself.</p>
<p>If this specification defines a built-in constructor's behaviour via algorithm steps, then that is its behaviour for the purposes of both [[Call]] and [[Construct]]. If such an algorithm needs to distinguish the two cases, it checks whether NewTarget is *undefined*, which indicates a [[Call]] invocation.</p>
<p>Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in the description of a particular function.</p>
<p>Built-in function objects that are not constructors do not have a *"prototype"* property unless otherwise specified in the description of a particular function.</p>
<p>Each built-in function defined in this specification is created by calling the CreateBuiltinFunction abstract operation (<emu-xref href="#sec-createbuiltinfunction"></emu-xref>). The values of the _length_ and _name_ parameters are the initial values of the *"length"* and *"name"* properties as discussed below. The values of the _prefix_ parameter are similarly discussed below.</p>
<p>Every built-in function object, including constructors, has a *"length"* property whose value is a non-negative integral Number. Unless otherwise specified, this value is the number of required parameters shown in the subclause heading for the function description. Optional parameters and rest parameters are not included in the parameter count.</p>
<emu-note>
Expand Down

0 comments on commit a651255

Please sign in to comment.