const

renoX renosky at free.fr
Fri Mar 28 13:25:30 PDT 2008


Janice Caron a écrit :
> On 28/03/2008, renoX <renosky at free.fr> wrote:
>>  > I've suggested "view" in the past,
>>
>> I like it a lot: view as in 'view but don't touch' :-)
> 
> I like that one too. It's shorter than "readonly" as well, which is
> another big plus.

Yes, I just realised that in the sentence 'read only view' in fact the 
most important part is the 'view', and read only is not fully true so 
it's a view: if everyone's only looking at something, of course this 
thing won't change but if someone modifies it, everyone will see the change.


> Under that regime, my "ideal" would be
> 
>     in -> view
>     const -> view
>     invariant -> const

Agreed.

>     enum -> const

I'd say that here both enum and const could be interesting:
-const for 'traditional enum' and
-enum for 'named' enumerated objects which you could print the name..
It has always shocked me that with C/C++ (and currently D)'s enum you 
refer inside the program to an enum by it's label but outside you can't 
unless the developer makes the effort of maintaining a map (value -> 
'value string'), or then you have some documentation which must be 
maintained too :-(

But this would have the downside of surprising C, D1 developers so 
'named enum' -> label or something similar.

Regards,
renoX




More information about the Digitalmars-d mailing list