ecma262 icon indicating copy to clipboard operation
ecma262 copied to clipboard

fixes #2405: clarify spec values that have identity and its implications

Open michaelficarra opened this issue 2 years ago • 2 comments

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.

michaelficarra avatar Jul 08 '22 23:07 michaelficarra

Updated based on @syg's feedback. @tc39/ecma262-editors Please take another look.

michaelficarra avatar Jul 28 '22 02:07 michaelficarra

Thoughts on "characteristics" as an alternative to "qualities"?

michaelficarra avatar Aug 12 '22 16:08 michaelficarra

Are all values with identity guaranteed to be Records? If yes, it seems we can:

  1. Replace a term values with(out) identity with a presense/absense of a new [[UniqueID]] field

  2. 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 operation GetValueUniqueId(object: Any): Any. The operation may return an address of an underlying memory chunk, freshly created UUID, or sequentially incremented number.

  3. 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 returns false.

    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.

arhadthedev avatar Aug 23 '22 19:08 arhadthedev

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.

bakkot avatar Aug 23 '22 19:08 bakkot

@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.

syg avatar Aug 24 '22 21:08 syg

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.

michaelficarra avatar Aug 30 '22 15:08 michaelficarra