Extended Type Design.
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Fri Mar 16 15:17:33 PDT 2007
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.
[1] Well, technically they're not really readonly, it's more like
non-writable (since the appropriate bit must be 1 on all levels of the
paging data structures to get a writable page) but that's heading /even
faster/ into the realm of nitpicking :).
> 'super const' at least has the connotation of being "constant, this time
> we mean it".
Wouldn't it be better if 'const' just _meant what it said_ in the first
place? :P
More information about the Digitalmars-d
mailing list