Const sucks
Daniel Keep
daniel.keep.lists at gmail.com
Tue Sep 11 02:10:29 PDT 2007
Bill Baxter wrote:
> Janice Caron wrote:
>> On 9/11/07, *Janice Caron* <caron800 at googlemail.com
>> <mailto:caron800 at googlemail.com>> wrote:
>>
>> It's simple, but - I would argue - the wrong choice. A better choice
>> (in my humble opinion) would be
>>
>> const = constant
>> readonly = read-only
>>
>> If it's not too late to change the keywords, that, to me, would be
>> the way to go.
>>
>>
>>
>> By which I mean, if it's at all feasable to consider ditching the
>> keyword "invariant" altogether, and introducing a new keyword
>> "readonly", then let's do it. "readonly" should indicate a read-only
>> view of data which someone else might modify, and "const" should imply
>> that no-one can modify it ever, no way, nohow.
>>
>> I'm not quite sure why no one before now has suggested using
>> "readonly" to mean read-only and "const" to mean constant, but seems
>> kind of a no-brainer to me. You know - calling a thing what it is,
>> instead of something it's not. I know I'd be dead confused if int
>> meant float, for example.
>
> It has been suggested before several times. The problem is there's
> disagreement over what it should mean. To some it is obvious that
> "readonly" should mean permanently unwriteable, just like "read only
> memory" is unwriteable. To others it is equally obvious that it should
> mean a read-only view of data that is writeable through some other means.
>
> --bb
The problem is that, broadly speaking, all these words mean the same
thing. Once you get down to splitting hairs over exactly how
constant/invariant/immutable/readonly/final something is, you're always
going to find some (possibly obscure) argument against the way you want
it to work.
Aren't natural languages fun?!
:P
-- Daniel
More information about the Digitalmars-d
mailing list