Timeline for What are some options for adding a sound equality operator (or avoiding it) in a type system with subtyping?
Current License: CC BY-SA 4.0
3 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 24 at 15:02 | comment | added | Steve | @osa1, as well as passing a comparison function at construction time, ultimately you could just design the entire collection bespoke to incorporate the relevant comparison function in a fixed way, or you could fall back on using plain arrays and separate insertion/retrieval methods that work on the array and enforce/employ the desired constraints as part of their workings. It isn't always necessary, or desirable, to attach the algorithms directly to the data. | |
Oct 24 at 14:28 | comment | added | osa1 | You advice makes sense, but then the problem becomes: how to design collection types like hash maps and sets that require comparing keys for equality. One option is, as mentioned by two other responses here, to pass the equality function as you construct such collections. Are there other options? Perhaps this should be discussed in a separate thread.. | |
Oct 23 at 13:32 | history | answered | Steve | CC BY-SA 4.0 |