ecma262
ecma262 copied to clipboard
fixes #2405: clarify spec values that have identity and its implications
Opened as draft since I only have the prose for now. Once we get this part agreed on and settled, I'll audit for uses of comparison, mutation, article choice, construction, etc.
New section rendering: https://ci.tc39.es/preview/tc39/ecma262/pull/2821#sec-identity
Fixes #2405. Related (maybe will soon fix) #2794.
Updated based on @syg's feedback. @tc39/ecma262-editors Please take another look.
Thoughts on "characteristics" as an alternative to "qualities"?
Are all values with identity guaranteed to be Record
s? If yes, it seems we can:
-
Replace a term values with(out) identity with a presense/absense of a new
[[UniqueID]]
field -
Extend abstract operations that create "objects with identity" with assignment of a value to
newObject.[[UniqueID]]
. The value is to be obtained by a call to a new implementation(or host)-defined abstract operationGetValueUniqueId(object: Any): Any
. The operation may return an address of an underlying memory chunk, freshly created UUID, or sequentially incremented number. -
Change the section proposed in the PR to something like this:
In this specification, the word is is used to compare two values through equality, as in “If bool is true, then”. The equality operation returns
true
if either both operands are Records and all their fields are pairwise equal, or both operands are primitive values and all their specification-defined properties are pairwise equal. Otherwise, the equality operation returnsfalse
.Probably, "is" should become a
<def>
if the specification gives it a special meaning.
In other words, I propose to keep the value identity important for comparisons only as the PR states, but move it from a vaguely defined realm into another abstract field.
Are all values with identity guaranteed to be Records?
No. The spec-internal List type and the ES language Object type both have identity, and neither are Records, for example.
@michaelficarra All of the editorial choices in https://github.com/tc39/ecma262/pull/2821#issue-1299519833 seem to be strictly speaking unrelated to nailing down a definition of identity. It'd be easier to review some of those as separate PRs.
Dropped all the editorial changes I've been working on, cleaning up how comparisons are done. Now this just includes the identity section. I'll open up other PRs for the comparison changes. Marked as ready for review.