Equalizer

The Equalizer implements the algorithm for testing sameness.

explain further

An Equalizer is present in the universal environment.

? __equalizer
 * 1) value: &lt;equalizer>

Protocol
? def unresolved := Ref.promise[0]
 * 1) value: &lt;Promise>

(XXX don't use sugar?) ? 1 == 1 ? 1 == 2 ? 1 == unresolved ? def _ {} == unresolved
 * 1) value: true
 * 1) value: false
 * 1) problem: &lt;insufficientlySettledException: not sufficiently settled: 1 == &lt;Promise>>
 * 1) problem: &lt;insufficientlySettledException: not sufficiently settled: &lt;_> == &lt;Promise>>

? __equalizer.sameYet(1, 1) ? __equalizer.sameYet(1, 2) ? __equalizer.sameYet(1, unresolved)
 * 1) value: true
 * 1) value: false
 * 1) value: false

write documentation

This is a proposed change, implemented in E-on-CL: that the isSettled operation be moved from Object Ref to Equalizer, since the definition of settledness is tightly related to the definition of sameness.

write tests

See comment and rationale on isSettled.

Tests
Discuss whether these tests should be placed on this page or on Sameness, and whether these tests should be broken up by method documentation sections or all together like this.

review whether these tests have good coverage (they were compiled by TDD in E-on-CL).

Just defining some objects to use later:

? def makeCoercedSlot := &lt;elib:slot.makeCoercedSlot>; null ? def a {} ? def b {} ? def semiA1 := makeCoercedSlot(any, 1, null) > def semiA2 := makeCoercedSlot(any, 1, null) > def semiB := makeCoercedSlot(any, 2, null) > def semiU := makeCoercedSlot(any, Ref.promise[0], null) >null
 * 1)  we should define our semitransparent type here, not rely on CoercedSlot being this incidentally
 * 1) value: &lt;a>
 * 1) value: &lt;b>

Algorithm checking
Two selfish objects are different.

? __equalizer.optSame(a, b)
 * 1) value: false

A selfish object is the same as itself.

? __equalizer.optSame(a, a)
 * 1) value: true

An atomic selfless object is the same as any object with the same value.

? [1, 1000000000000000000001 - 1000000000000000000000] ? __equalizer.optSame(1, 1.0) ? __equalizer.optSame(1, 1000000000000000000001 - 1000000000000000000000)
 * 1) value: [1, 1]
 * 1) value: false
 * 1) value: true

A transparent selfless object is the same as any object with the same portrayal as from __optUncall.

? __equalizer.optSame([1], [1]) ? __equalizer.optSame([1], [2])
 * 1) value: true
 * 1) value: false

An unresolved reference is the same as itself, but not the same or different as anything else.

fix all updoc impls and eliminate use of [null] gimmick

? [__equalizer.optSame(1, unresolved)] ? [__equalizer.optSame(unresolved, unresolved)] ? [__equalizer.optSame([unresolved], [unresolved])] ? [__equalizer.optSame(unresolved, Ref.promise[0])]
 * 1) value: [null]
 * 1) value: [true]
 * 1) value: [true]
 * 1) value: [null]

Cyclic Selfless objects are the same as each other provided they have the same structure.

? [__equalizer.optSame(def circle := [circle], def loop := [loop])] ? [__equalizer.optSame(def circle := [1, [1, circle]], def loop := [1, loop])]
 * 1) value: [true]
 * 1) value: [true]

More Selfless (XXX move these?)

? [__equalizer.optSame('q', 'q')] ? [__equalizer.optSame('q', 'w')] ? "a" + "bc" ? [__equalizer.optSame("abc", "a" + "bc")]
 * 1) value: [true]
 * 1) value: [false]
 * 1) value: "abc"
 * 1) value: [true]

A String is a kind of list but it isn't the same as a plain ConstList.

? [__equalizer.optSame(['a', 'b', 'c'], "a" + "bc")]
 * 1) value: [false]

Tests of semitransparency ( document this; currently only actually implemented in general in E-on-CL; semitransparency is the general case of what SturdyRef, and now CoercedSlot is):

? [__equalizer.optSame(semiA1, semiA2)] ? [__equalizer.optSame(semiA1, semiB)] ? [__equalizer.optSame(semiA1, semiU)] This is a test for a former bug in E-on-CL: the sofar list was sometimes being filled with the right-side reference only (broken sort-by-hash swap), so a cycle on the right would be assumed to be a cycle on the left as well. The test is done with two sets of references because whether the swap occurs depends on the hash-values involved.
 * 1) value: [true]
 * 1) value: [false]
 * 1) value: [null]

? def l1 := [l1] > def c1 := [[[['a']]]] > def l2 := [l2] > def c2 := [[[['b']]]] > [c1 == l1, c1 == l2, c2 == l1, c2 == l2, > l1 == c1, l1 == c2, l2 == c1, l2 == c2]
 * 1) value: [false, false, false, false, false, false, false, false]

isSettled
? __equalizer.isSettled(semiA1) ? __equalizer.isSettled(semiU)
 * 1) value: true
 * 1) value: false

there are other isSettled tests from E-on-CL to be moved here