Extended Type Design.
Joel C. Salomon
JoelCSalomon at Gmail.com
Sat Mar 17 18:38:00 PDT 2007
Andrei Alexandrescu (See Website For Email) wrote:
>> How about “const const”? No new keywords, no reuse of keywords in
>> disparate contexts, and equally noticeable to the eye.
>
> It was on the plate briefly. Probably it would be an uphill battle to
> convince people to enjoy it.
I’m still kinda shaky on the question of why the various extra
specifiers are needed. If a variable is being declared “const” ought to
mean nobody can change it, if it’s a function parameter it’s a promise
that the function won’t change it. How vital is it that the language
express “put this in read-only memory” as opposed to “don’t put this in
read-only memory, but complain if I try to change it”? Why should a
function care if it got a pointer to read-only memory or if it just
promised not to alter the value?
For numeric constants that don’t need addresses, I’d suggest “define”
rather than “final”, as in:
define float PI = 3.14159;
If the “#if” syntax for “static if” is adopted, I might even suggest
“#define”, just to make it clear that something is happening at
compile-time rather than run-time.
--Joel
More information about the Digitalmars-d
mailing list