Is this a bug?

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 15 17:17:17 PDT 2016


On Saturday, April 16, 2016 00:28:46 ag0aep6g via Digitalmars-d-learn wrote:
> On 15.04.2016 20:55, Eric wrote:
> >   13 class C : const (I!(J))
>
> I think this const is ignored by the compiler.

It's definitely ignored, and I'd argue that it's a bug in the compiler that
it's even accepted. There's no such thing as a const or immutable class -
just a const or immutable instance of a class. Member functions of a class
can be const or immutable but not the class itself.  Doing so is just
equivalent to marking every function in the class as const or immutable.
Deriving from a const or immutable class is nonsense.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list