Keywords (was: Const sucks)

Derek Parnell derek at psych.ward
Tue Sep 11 04:53:54 PDT 2007


On Tue, 11 Sep 2007 19:10:29 +1000, Daniel Keep wrote:

> 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?!

Therefore let's invent some new keywords, ones that are unlikely to clash
with user declared identifiers ... 

I'll start this ball rolling.


  'rodata' instead of 'invariant'  (Read Only Data)
  'roview' instead of 'const' (Read Only View)


alias string rodata(char)[];

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell



More information about the Digitalmars-d mailing list