archives

« Bugzilla Issues Index

#4270 — Spec treatment/relationship of "Strict Equality" and "SameValue"


The note on 7.2.13 says:

"This algorithm differs from the SameValue Algorithm (7.2.9) in its treatment of signed zeroes and NaNs."

The symmetric note however is *not* present in 7.2.9.

------

Suggestion (1): For helpful clarity, add this note to 7.2.9:

"This algorithm differs from the Strict Equality Comparison Algorithm (7.2.13) in its treatment of signed zeroes and NaNs."

-------

Also to aid in clarity, one can observe the implication of these notes, which is that one could simply reference the other, after first expressing the two exceptions (NaN and -0).

For example, Strict Equality Comparison Algorithm could be significantly simplified like this:


The comparison x === y, where x and y are values, produces true or false. Such a comparison is performed as follows:

1. If Type(x) is Number, then
If x is NaN, return false.
If y is NaN, return false.
If x is +0 and y is −0, return true.
If x is −0 and y is +0, return true.
2. If SameValue(x, y) is true, then return true.
3. Return false.


The advantage here is not just a simpler spec, but it reinforces the implication of those notes discussed earlier. It makes it clear the relationship between the two algorithms. A rewritten section as I suggest wouldn't need a note, because it's now obvious.

However, the suggested 7.2.9 note above would still be a benefit to cross-reference clarity.

Of course, you could do the reverse symmetrical, and simplify SameValue as invoking === after tackling the exceptions.


fixed in rev38 editor's draft

added the note to 7.2.9

any algorithm restructuring will have to wait until ES7. File free to file that part of this item as a new ticket against ES7.


in rev38