head const (again), but for free?

sighoya sighoya at gmail.com
Wed Jan 13 15:14:29 UTC 2021


On Monday, 11 January 2021 at 17:15:39 UTC, Ola Fosheim Grøstad 
wrote:
> Introduce "readonly" as head-immutable. That means that all 
> values in an immutable array are immutable, including the 
> address of reference, but not the objects being pointed to.

This is an idiomatic break to the meaning of immutability which 
is global const, while readonly serves the purpose of being 
locally const.
You can mutate a readonly var outside the readonly scope, this is 
never possible with immutable, let it be either head, tail or 
head & tail immutable.




More information about the Digitalmars-d mailing list