head const (again), but for free?

Meta jared771 at gmail.com
Wed Jan 13 19:42:14 UTC 2021


On Wednesday, 13 January 2021 at 19:22:07 UTC, Ola Fosheim 
Grøstad wrote:
> On Wednesday, 13 January 2021 at 18:37:02 UTC, sighoya wrote:
>> Yep, head const is usually readonly or better final, readonly 
>> should be transitive.
>
> Why? "immutable" is transitive in D. readonly memory or 
> registers are not transitive.
>
>
>> I just find it confusing to denote readonly as head immutable 
>> because readonly in other languages denote head const, that's 
>> it.
>
> No, readonly in technical specifications usually means that it 
> is isn't possible to write to it at all. e.g. readonly hardware 
> registers. They can still point to writable memory.
>
> "readonly" in Typescript and C# is immutable, not const.
>
> Which languages are you thinking of?

Is there even any value to having head-const in a language? As I 
think Walter has said before, it's basically just 
documentation/convention in C++. I can see the value in 
head-immutable, in terms of type system guarantees, but not 
head-const.


More information about the Digitalmars-d mailing list