const
Don Clugston
dac at nospam.com.au
Sat Apr 5 02:19:31 PDT 2008
Walter Bright wrote:
> Don Clugston wrote:
>> Ditto. Come on, even non-programmers know what "read only access" means.
>> I find it hard to believe there would be many people who'd have
>> trouble grasping the idea that "read only" means "look but don't
>> touch". Are there any languages where 'readonly' is used for putting
>> values into ROM?
>
> Yes, there are C extensions to do just that. Secondly, there is often
> hardware memory protection available, which has a "read only" bit. That
> means the data cannot be changed.
It's pretty common for the OS to load the exe into writable memory, then set the
readonly bit. "read only" = the OS can write to it, but you can only read it.
Ditto for files -- the administrator can always delete them.
Files marked "read only" cannot be
> written to by anyone. Read only has a long history of meaning immutable
> by anything, not just the viewer.
>
> "The readonly storage-class modifier, like the const data-type
> qualifier, assigns the NOWRT attribute to the variable's program
> section; if used with the static or globaldef specifier, the variable is
> stored in the $CODE psect, which has the NOWRT attribute by default." --
> http://h71000.www7.hp.com/commercial/c/docs/5492profile_017.html
>
That looks pretty obscure to me. Besides, a paragraph later, that page describes
const and readonly as pretty much synonymous:
"For new program development, HP recommends that you use the const modifier,
because const is standard-conforming and readonly is not."
How often have you heard someone say "sorry, I only have read-only access to
that directory?"
More information about the Digitalmars-d
mailing list