Extended Type Design.
Sean Kelly
sean at f4.ca
Fri Mar 16 15:33:09 PDT 2007
Frits van Bommel wrote:
> Walter Bright wrote:
>> Frits van Bommel wrote:
>>> Seriously though:
>>> "readonly" would mean that you (meaning any code that can access the
>>> symbol so declared) can only read data referenced through it, but
>>> someone else _may_ be able to write to it[2].
>>
>> My perception of that is different. I used to do embedded systems, and
>> 'readonly' means the data went into ROM. Also, marking a page in a
>> virtual memory system as 'readonly' means that nobody can modify it.
>
> Perhaps, but my perception of 'const' is different ;). Particularly, it
> seems to be short for "constant", which is therefore what it should
> mean. Not "*you* can't change this, but someone else might anyway".
>
> Oh, and on x86 (and amd64) processors the operating system is allowed to
> write to 'readonly'[1] pages unless it sets the WP (Write-Protect) bit
> in system register CR0. Note: as this bit is *off* by default, it needs
> to be explicitly turned on by the OS.
So *that's* why Win32 doesn't complain when constant data is modified
and pretty much every other OS does. Good to know.
By the way... I feel the same about the meaning of 'const'. On some
level I still even think that const-by-default is the correct choice,
but now that D has hit 1.0 that will be a much harder sell.
Sean
More information about the Digitalmars-d
mailing list