A fresh look at comparisons
Robert Fraser
fraserofthenight at gmail.com
Mon Apr 14 13:35:25 PDT 2008
Janice Caron wrote:
> [...]
There's no reason why two user-defined types that are not typically
castable to one another can't be defined as equal... as long as this is
transitive (so they both know about each other). Your syntax arbitrarily
limits that option. It may be questionable software design, but it has a
very legitimate use: backwards compatibility. For example, version 1 of
a library could have a certain thing as a struct, but to make it more
extensible, version 2 introduces a class version of the same type. They
both have overridden opEquals to make them evaluate as equal to one
another (for example, so users can use both of them in a hash and not
have to switch their entire codebase over at once). For efficiency, both
the class and struct versions may live on.
More information about the Digitalmars-d
mailing list