Re: D5 Constant expression expected
From: Maarten Wiltink (maarten_at_kittensandcats.net)
Date: 04/19/04
- Next message: Maarten Wiltink: "Re: D5 Constant expression expected"
- Previous message: Bjørge Sæther: "Re: floating point arithmetic problems"
- In reply to: Supply and Demand: "Re: D5 Constant expression expected"
- Next in thread: Bjørge Sæther: "Re: D5 Constant expression expected"
- Reply: Bjørge Sæther: "Re: D5 Constant expression expected"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 19 Apr 2004 10:02:21 +0200
"Supply and Demand" <matko . lokas @ comhem . se (without blanks!)> wrote in
message news:M3zgc.56503$mU6.233374@newsb.telia.net...
> By the way... do you see any logical reason for Why they ever made
> typed constants... not constant?
Because they could.
In my book, there is one simple and bad reason, one almost as simple
and almost as bad one, and one complicated and simply bad one.
The simple and bad reason is that it saves one or two keystrokes when
you use them in place of global variables. Global variables can't be
declared initialised, you have to do that in the initialization section.
Note that all the elements to do this already existed; no expressive
power was added to the language.
The almost as simple and almost as bad reason is that you can declare
typed constants inside any scope, and they will not be visible (although
they will still exist) outside it. It also keeps the declaration and the
initialisation together. These are considerations in a different domain,
one that I am usually more concerned with than saving keystrokes: purity
of esse^BSlanguage. I'm still not impressed.
The complicated reason is the one pointed out here, which I had never
thought of: that it's possible to manipulate the "constant"'s value
through pointers. I consider this an equally bad reason as the first.
You should not be allowed to ask for a pointer to a constant, and there
should be no predictable, reproducible way to compute it.
So, yes, I can see logical reasons. But not good reasons.
Groetjes,
Maarten Wiltink
- Next message: Maarten Wiltink: "Re: D5 Constant expression expected"
- Previous message: Bjørge Sæther: "Re: floating point arithmetic problems"
- In reply to: Supply and Demand: "Re: D5 Constant expression expected"
- Next in thread: Bjørge Sæther: "Re: D5 Constant expression expected"
- Reply: Bjørge Sæther: "Re: D5 Constant expression expected"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|