A
Arthur J. O'Dwyer
const int foo = 5;
char arr[foo];
Legal C++ (because in C++, const objects are really "constant"),
but illegal C (because 'foo' is an object whose value needn't
be stored [or even computed] at compile time). I think C's way
is easier for me to grasp. And I think (but this is just IMH
and uneducated O) that C++ compilers need a lot of extra baggage
to deal with constant "consts," and I wouldn't want to foist all
that on C compilers.
Ooh, that would just be ugly and mean.
Except possibly for flavors of 'char', why would anyone want to
walk over all values of a type anyway? Solving equations by
exhaustive search? ;-)
-Arthur
char arr[foo];
Legal C++ (because in C++, const objects are really "constant"),
but illegal C (because 'foo' is an object whose value needn't
be stored [or even computed] at compile time). I think C's way
is easier for me to grasp. And I think (but this is just IMH
and uneducated O) that C++ compilers need a lot of extra baggage
to deal with constant "consts," and I wouldn't want to foist all
that on C compilers.
Something like
fancy_enum { fred=32, george=23 } bar;
bar = fred;
bar++; /* bar now equals george */
possibly?
Ooh, that would just be ugly and mean.
i=0;
while (1) {
/* do stuff */
if (i==INT_MAX) break; /* or whatever other MAX */
i++;
}
Even uglier but safe for signed types.
Except possibly for flavors of 'char', why would anyone want to
walk over all values of a type anyway? Solving equations by
exhaustive search? ;-)
-Arthur