ProtoObject and comparison for equality and ordering

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed May 15 10:17:45 UTC 2019


On Wednesday, May 15, 2019 3:54:15 AM MDT Jacob Carlborg via Digitalmars-d 
wrote:
> On 2019-05-15 04:09, Andrei Alexandrescu wrote:
> > In this case, ProtoObject is a carefully considered addition that
> > bypasses a malfunctioning artery - the Object class. But it doesn't
> > change or remove it, because there's much live tissue connected to it.
> > Changing how opCmp works - inserting a little botox during the surgery -
> > is a damaging distraction.
>
> It will cause issues with code that does `is(T : Object)` and expect
> that to be the root class. In other cases the same code has been used to
> identify D classes before `__traits(getLinkage)` was available for
> classes.

is(T == class) should work. And as it is, IIRC, using is(T : Object) is
already problematic due to extern(C++) classes not being derived from
Object. I think that there's also an issue with interfaces not necessarily
being classes due to how D handles COM, but fortunately, I haven't had to do
anything with COM recently, so I'm not very familiar with D's COM support.
There's also the problem that is(T : Object) can be true if alias this is
used. So, is(T : Object) probably shouldn't be used much even now, but I do
think that it's likely that adding classes below Object will break some
existing code. I'm not sure that there's much that we can do about that
though.

- Jonathan M Davis





More information about the Digitalmars-d mailing list