Non-transitive immutable? Read only struct.

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


On Friday, 6 December 2019 at 09:26:40 UTC, Ola Fosheim Grøstad 
wrote:
>>> 4. To have structures in ROM that can point to memory mapped 
>>> registers or RAM. Not a must have, but sensible.
>>
>> Getters can do this. You'll probably have to dip into some 
>> un- at safe code, but this seems like an exotic enough use case 
>> that we can live with that.
>
> Casting away immutable sounds very dangerous. If that can be 
> done then the optimizer cannot use immutable for anything?
>
> Anyway, getters are not useful in low level programming. You 
> need to be able to take the address of the memory. So what you 
> are left with is to leave it mutable to the typesystem and 
> never write to it in your code, so basically no help from the 
> type system.

I guess you could use const for ROM, but that might affect 
caching and ROM can be slow.



More information about the Digitalmars-d mailing list