switch case for constants-only?
Rainer Deyke
rainerd at eldwood.com
Sat Dec 5 16:31:12 PST 2009
Nick Sabalausky wrote:
> "Rainer Deyke" <rainerd at eldwood.com> wrote in message
> news:hfenkl$veq$1 at digitalmars.com...
>> I assume the same rule applies to 'goto case'?
>
> I think that amounts to a computed goto, which I don't think D currently
> has, so that probably just wouldn't compile.
So case labels could be variables but labels for 'goto case' would be
constant? That seems backwards and inconsistent. It also fails to
address this:
int i = 0, j = 0;
switch (j) {
case i:
break;
case j:
// Never reached.
}
> But with or without computerd goto, this sounds like a reason to use an
> actual fallthrough command instead of "goto case".
Not really. If you want fallthrough, use 'goto case' without a label,
like this:
goto case;
--
Rainer Deyke - rainerd at eldwood.com
More information about the Digitalmars-d
mailing list