From 0f017325c3e7c18858f39746164f611e65743a75 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 8 Nov 2023 15:27:34 -0500 Subject: [PATCH] Editorial: Rework the 'Identity' section --- spec.html | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/spec.html b/spec.html index 504dbfdee8..b8164d4a46 100644 --- a/spec.html +++ b/spec.html @@ -1107,10 +1107,25 @@

Value Notation

Identity

In this specification, both specification values and ECMAScript language values are compared for equality. When comparing for equality, values fall into one of two categories. Values without identity are equal to other values without identity if all of their innate characteristics are the same — characteristics such as the magnitude of an integer or the length of a sequence. Values without identity may be manifest without prior reference by fully describing their characteristics. In contrast, each value with identity is unique and therefore only equal to itself. Values with identity are like values without identity but with an additional unguessable, unchangeable, universally-unique characteristic called identity. References to existing values with identity cannot be manifest simply by describing them, as the identity itself is indescribable; instead, references to these values must be explicitly passed from one place to another. Some values with identity are mutable and therefore can have their characteristics (except their identity) changed in-place, causing all holders of the value to observe the new characteristics. A value without identity is never equal to a value with identity.

-

From the perspective of this specification, the word “is” is used to compare two values for equality, as in “If _bool_ is *true*, then ...”, and the word “contains” is used to search for a value inside lists using equality comparisons, as in "If _list_ contains a Record _r_ such that _r_.[[Foo]] is *true*, then ...". The specification identity of values determines the result of these comparisons and is axiomatic in this specification.

-

From the perspective of the ECMAScript language, language values are compared for equality using the SameValue abstract operation and the abstract operations it transitively calls. The algorithms of these comparison abstract operations determine language identity of ECMAScript language values.

-

For specification values, examples of values without specification identity include, but are not limited to: mathematical values and extended mathematical values; ECMAScript source text, surrogate pairs, Directive Prologues, etc; UTF-16 code units; Unicode code points; enums; abstract operations, including syntax-directed operations, host hooks, etc; and ordered pairs. Examples of specification values with specification identity include, but are not limited to: any kind of Records, including Property Descriptors, PrivateElements, etc; Parse Nodes; Lists; Sets and Relations; Abstract Closures; Data Blocks; Private Names; execution contexts and execution context stacks; agent signifiers; and WaiterList Records.

-

Specification identity agrees with language identity for all ECMAScript language values except Symbol values produced by Symbol.for. The ECMAScript language values without specification identity and without language identity are *undefined*, *null*, Booleans, Strings, Numbers, and BigInts. The ECMAScript language values with specification identity and language identity are Symbols not produced by Symbol.for and Objects. Symbol values produced by Symbol.for have specification identity, but not language identity.

+

To some extent, which values have identity depends on perspective, so we distinguish specification identity and language identity.

+

Specification identity is identity as seen from the perspective of the algorithms of this specification. Within these algorithms, the word “is” is used to compare two values for equality, as in “If _bool_ is *true*, then ...”, and the word “contains” is used to search for a value inside lists using equality comparisons, as in "If _list_ contains a Record _r_ such that _r_.[[Foo]] is *true*, then ...". For such comparisons:

+ +

Language identity is identity as seen from the perspective of ECMAScript code. There, language values can be compared for equality in various ways, but the most discriminating is the `Object.is` built-in function, whose semantics are given by the SameValue abstract operation and the abstract operations it transitively calls. These semantics are such that, to a first approximation, language identity matches specification identity. In fact, the only difference between the two involves Symbol values: whereas all Symbols have specification identity, Symbols produced by Symbol.for do not have language identity.