Regards,
Chander.
> Why const in C language is not a compile time constant ?
void foo(int bar)
{
const int xyzzy = bar;
/* etc. */
}
--
Morris Keesan -- mke...@post.harvard.edu
>
> Regards,
> Chander.
It's not possible to make "const" mean "compile-time constant" in all
cases. For example, this is (and should continue to be) perfectly
legal:
const int r = rand();
I think it would be possible to make the name of a const-qualified
object a constant expression if the initial value is a constant
expression; I don't believe it would break any existing valid code.
--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
"const" seems to be "a big can of worms". Can someone list the issues? It
almost seems like "double the code" and "half the productivity" kind of
thing. I haven't yet studied the issue, but that's the feeling I get from
language groups is that "const" is hardly a benign introduction into a
language. It looks like a key problem to be solved.
Not too bad: "WORM: Write Once, Read Many"
Bye, Jojo