Bug 3999 and 4261
so
so at so.do
Wed Sep 1 11:58:39 PDT 2010
On Wed, 01 Sep 2010 11:06:51 +0300, Rainer Deyke <rainerd at eldwood.com>
wrote:
> On 8/31/2010 19:46, bearophile wrote:
>> But you can use const for constants that are known at run-time only.
>> While you can't use enum for constant known at run-time.
>
> In C++, const is used for both run-time and compile-time constants. In
> practice, this works out fine. It its value can only be known at
> run-time, it's a run-time constant. If its value is used at
> compile-time, it's a compile-time constant. If both of these apply,
> it's an error. If neither applies, nobody cares if it's a compile-time
> or run-time constant.
>
> (The actual rules in C++ are a bit more complex, less intuitive, and
> less useful than that, which is presumably why Walter chose not to copy
> the C++ in this case. Still, overloading 'const' for both compile-time
> and run-time constants is viable, and more intuitive than the current
> situation with 'enum'.)
I have never had troubles with C++ compile/runtime "const" difference,
and don't think it is a problem in C++. With this in mind "enum" is a
great keyword
of choice to express compile-time types, as long as it is forbidden for
run-time constants.
(I hope that example of bearophile is just a bug.)
Thanks.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list