https://issues.dlang.org/show_bug.cgi?id=2347

Vladimir Panteleev <dlang-bugzi...@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
           Hardware|x86                         |All
         Resolution|---                         |WONTFIX
                 OS|Linux                       |All

--- Comment #4 from Vladimir Panteleev <dlang-bugzi...@thecybershadow.net> ---
(In reply to Stewart Gordon from comment #1)
> I think that having opIs is philosophically wrong.  The whole point of is is
> to override any type-defined equality operator by forcing a byte-for-byte
> comparison.  There are probably plenty of template libraries and the like
> that rely on this.

Agreed. Currently `is` provides a guarantee that it compares bits and will
never invoke any other user-defined comparison mechanisms. This applies to
user-defined types (structs, classes) as well as floating-point types (where
x==x may not always be true due to NaNs). An opIs operator would break that
guarantee.

User-defined smart references and slices could instead expose identity
comparison via a ".ptr" property, which could then be compared using `==` or
`is`.

Also, I understand that such language additions would need to be done via a DIP
today.

@Andrei: I'll close this (also because this issue is close to a decade old),
but please reopen if you disagree.

--

Reply via email to