New super switch, was Re: The final word on GOTO
David Adrien Tanguay
datanguay at watmath.waterloo.edu
Sat Oct 7 15:00:33 AEST 1989
In article <4467 at buengc.BU.EDU> bph at buengc.bu.edu (Blair P. Houghton) writes:
<Switch provides a method of conditionally splitting the flow-graph,
<but there doesn't exist a dual of it that would describe the joining of
<some subset of the split branches of the flow-graph.
<
<Something like
<
< switch(fc) {
< case 'c': stuff under c; break;
< case 's': stuff under s; break;
< ...
< case 'u': stuff under u; break;
<
< cases 'd', 'o', 'x', 'u': stuff for doxu cases; break;
< cases 'd', 'c', 'u': stuff for dcu cases; break;
< }
A friend of mine kicked this idea around a few ago when he was
designing a language (Andrew Wright, ForceTwo). You can also have
cases like "anything except 'a', 'b' 'c'", "anything", and "default - i.e.,
anything that isn't explicitly mentioned elsewhere". This kind of flow of
control construct can do some neat things, but it can also lead to
hard to follow code and strange bugs (no "multiple case in switch" errors).
It shouldn't be that hard for the compiler to generate good code for it.
Unfortunately, I don't think it's useful enough to warrant the extra
language complexity. Multiple (sequential) switches would probably mimic
most of the functionality, anyway. Still, it would be fun to play with.
David Tanguay
More information about the Comp.lang.c
mailing list