|
|
CBFalconer <cbfalconer@xxxxxxxxx> writes:
> "christian.bau" wrote:
>> aark...@xxxxxxxxx wrote:
>>
>>> why are constant integer expressions required in case labels of
>>> the switch statement? what would be the impact of allowing
>>> general integer expressions instead of constant integer
>>> expressions? discuss both user convenience and implementation
>>> aspects?
>>
>> Consider
>>
>> switch (i) {
>> case f (): printf ("f"); break;
>> case g (): printf ("g"); break;
>> }
>>
>> Discuss under user convenience, implementation, and general
>> mental health aspects.
>
> The function f() is not a constant integer expression. Illegal.
Yes, of course it's illegal. That's the point. The example was
intended to illustrate *why* it's illegal (beyond "because the
standard says so").
--
Keith Thompson (The_Other_Keith) <kst-u@xxxxxxx>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
|
|