this() immutable
Stephan Schiffels
stephan_schiffels at mac.com
Thu Jun 13 05:17:22 PDT 2013
Hi,
I have some problems with adopting my code to a breaking change
introduced in version 2.063. Apparently, now it's not anymore
possible to instantiate an immutable object via:
auto object = new immutable(SomeClass)(contructor_args...);
without also defining either
this(constructor_args...) immutable {...}
or
this(constructor_args...) pure {...}
As much as I think that this change will make the system more
consistent, I don't know how to fix my code. Often, in a
constructor you pass other objects (via constructor dependency
injection), and it seems that I have to fix a hell of a lot of
dependency code that way. Is there a simple way of emulating the
way it "just magically worked" in version 2.062?
For example, is there a way of instantiating an object normally
(i.e. mutable), and then later "freeze" it to immutable via a
simple cast or so?
Thanks,
Stephan
More information about the Digitalmars-d-learn
mailing list