effect icon indicating copy to clipboard operation
effect copied to clipboard

Equal in 4.0 (Proposal)

Open mikearnaldi opened this issue 1 year ago • 2 comments

I propose to change how equality works in 4.0 to be more structural by default, the idea would be:

  1. consider plain objects, arrays, sets and maps structurally
  2. consider non plain objects (prototype !== Object.prototype) by reference
  3. provide a byReference function backed by a weakmap to consider an instance of an object as by reference

We previously backed off from structural by default due to errors with circular structures but this was mainly due to considering ALL objects structurally (i.e. also custom classes). We should also be able to deal with circular structures by detecting loops.

mikearnaldi avatar May 26 '24 12:05 mikearnaldi

Does this mean that equals(new Thing(),new Thing()) will be false? 🤔

datner avatar May 29 '24 13:05 datner

Does this mean that equals(new Thing(),new Thing()) will be false? 🤔

depends how Thing is defined, not if it is defined via Data

mikearnaldi avatar May 29 '24 15:05 mikearnaldi