Cannot compare object.opEquals is not nogc

Lodovico Giaretta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 24 08:41:55 PDT 2016


On Sunday, 24 July 2016 at 15:28:53 UTC, Jonathan Marler wrote:
> Whoa wait a second...I didn't know you could do this.  I 
> thought everything had to inherit from the object class.  Can 
> you share the syntax to define a class that doesn't derive from 
> object?

Currently, you cannot. Everything inherits from Object. I 
personally think this is not the best idea. But it's not that 
horrible either, so probably not worth a big change.

But you can just ignore it. You can put on your opCmp all the 
attributes you want and forget about it inheriting from Object. 
You can decide to never write a method that takes Object. Always 
take the root of your sub-hierarchy, so that you know what 
attributes you have.
If it derives from Object or not, nobody cares as long as your 
sub-root overrides all opXXX with new (even abstract) 
declarations that have @nogc.


More information about the Digitalmars-d-learn mailing list