Cannot compare object.opEquals is not nogc

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


On Sunday, 24 July 2016 at 15:31:28 UTC, lqjglkqjsg wrote:
> Almost off topic but I've recognized a typical error here, I 
> think that many of us have already seen it too. You develop a 
> nice class. You put attributes everywhere @safe pure nothrow 
> @nogc. Yay the unittest pass.
>
> Later you use it for real and you realize then that the 
> attributes must be removed because you can't do anything in the 
> overriden methods.

That's why I'm against putting @nogc on Object.
You must only annotate specific sub-hierarchies that you know 
will never need the GC (or whatever: @system, impure, throwing). 
This often means that you can only annotate closed hierarchies. 
This is correct: you must not annotate open ended classes unless 
you decide that you really NEED (NEED != WANT) these limitations. 
And your users will probably find them restrictive, so you need a 
compelling reason that cannot be solved in other ways.


More information about the Digitalmars-d-learn mailing list