The D Programming Language: cases (fallthrough)
Carsten Bormann
cabo at tub.UUCP
Sun Mar 6 02:13:39 AEST 1988
In article <25200 at cca.CCA.COM> g-rh at CCA.CCA.COM.UUCP (Richard Harter) writes:
[about a solution to get back some expressive power that will be lost if
``case'' implies ``break'':]
() switch (e) {
() case foo:
() some code;
() fallthrough;
() case baz:
() some more code;
() }
(Current) C already has a good fallthrough statement.
It is called (surprise):
goto.
switch (e) {
case foo:
some code;
goto baz_case;
case baz:
baz_case:
some more code;
}
Any optimizer will throw away the superfluous branch implied by the goto.
This also has the advantage to use the existing ``spaghetti code warning''
keyword, and to allow you to give a descriptive name for the ``baz_case''.
Now if D had a comefrom...
--
Carsten Bormann, <cabo at tub.UUCP> <cabo at db0tui6.BITNET> <cabo at tub.BITNET>
Communications and Operating Systems Research Group
Technical University of Berlin (West, of course...)
Path: ...!pyramid!tub!cabo from the world, ...!unido!tub!cabo from Europe only.
More information about the Comp.lang.c
mailing list