Why D doesn't have an equivalent to C#'s readonly?

Assembly via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 29 13:12:11 PDT 2015


I believe it's a design choice, if so, could someone explain why? 
is immutable better than C#'s readonly so that the readonly 
keyword isn't even needed? for example, I'd like to declare a 
member as readonly but I can't do it directly because immutable 
create a new type (since it's a type specific, correct?) isn't 
really the same thing.

MyClass x = new MyClass();

if I do

auto x = new immutable(MyClass)();

give errors


More information about the Digitalmars-d-learn mailing list