how to declare an immutable class?

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 12 02:28:21 PDT 2016


On Friday, 12 August 2016 at 08:35:54 UTC, Jonathan M Davis wrote:
> On Friday, August 12, 2016 05:25:45 Mike Parker via 
> Digitalmars-d-learn wrote:
>> immutable class Foo { ... } is the same as declaring every 
>> member of Foo as immutable, just as final class Foo { ... } 
>> makes every method final.
>
> I'm not sure that that's quite the same thing, because there is 
> such a thing as a final class, because making the class final 
> makes it illegal to derive another class from it rather than 
> just affecting the class' functions. So, final does affect the 
> class itself, whereas immutable does not.

Yes, bad comparison, but the rest of your post makes the point I 
intended.


More information about the Digitalmars-d-learn mailing list