Non-transitive immutable? Read only struct.

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Fri Dec 6 09:12:17 UTC 2019


On Friday, 6 December 2019 at 08:45:15 UTC, Gregor Mückl wrote:
> Can you clarify how this goes beyond the classic OO pattern of 
> private member variables with public getters and no setters? If 
> there was a class-private visibility, D could emulate 
> everything except point 3 on your list, I think, albeit 
> somewhat verbosely. So how is your thinking diverging from that?

You cannot easily emulate it since this is low-level typing where 
you can obtain the address of the memory and that memory should 
be read only within its lifetime.

The problem with "immutable" is that it requires that read only 
memory only can point to read only memory, which is too limiting.

(You can try to set up a big machinery of emulating pointers etc, 
but then you are basically implementing a new type system within 
the type system. Which probably will be too cumbersome and 
therefore not used.)



More information about the Digitalmars-d mailing list