opDispatch and compile time parameters

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 21 06:31:26 PDT 2015


On Wednesday, 21 October 2015 at 12:32:37 UTC, Andrei 
Alexandrescu wrote:
> The quickest way to stop the bleeding is to disallow the code. 
> It's incorrect for immutable data and misleading for mutable 
> data. (What an user might expect is that each data comes with a 
> distinct array.)

It's perfectly correct for immutable data if the member variable 
is declared to be immutable or if it's a Rebindable which 
explicitly refers to immutable (in fact, SysTime would be 
defaulting to an immutable TimeZone for its default value if it 
weren't for the fact that a compiler bug is preventing it). What 
doesn't work is to have the member variable be declared to be 
mutable and then declare an instance of the object it's in to be 
immutable, since then you can have a mutable and immutable object 
referring to the same data with different levels of mutability.

- Jonathan M Davis


More information about the Digitalmars-d mailing list