The D Programming Language: cases
Karl Heuer
karl at haddock.ISC.COM
Wed Mar 23 09:11:19 AEST 1988
In article <336 at wsccs.UUCP> terry at wsccs.UUCP (terry) writes:
>I think that [an explicit fallthrough statement] would be dangerous, in that
>it would have further reaching effects than Richard anticipates. Since the
>discussion centers around 'D', which by context is simply "a new standard C
>which may not be compatable with the current K&R standard of C so we'll call
>it 'D'", I believe that "upward" compatability must be maintained if all C
>software is to be recompiled in D with minimal tweaking.
That sounds more like a description of ANSI C. "D" is intended to be a
language which is as powerful as C but (unlike ANSI C and C++) is *not bound
at all* by the compatibility requirement. (Although a C-to-D translation tool
would probably appear, in the unlikely event that this thought experiment
actually materializes into something tangible.)
>While a change this drastic _could_ be worked around with something as simple
>as #define case fallthrough; case this does _not_ help code generators
>such as YACC and LEX generate this new code.
What's the problem? I think yacc currently generates a break after each case
block; the solution then is to omit this if generating D. Even if yacc does
depend on the current automatic fall-through semantics, it could generate an
explicit "fallthrough;" statement at the bottom of each case block. Surely it
has enough information for this -- I'd bet it's a one-line change.
(Btw, although I would prefer a "fallthrough" statement to the current C
semantics, I think that both are inferior to "goto case N".)
Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint
More information about the Comp.lang.c
mailing list