New super switch, was Re: The final word on GOTO

Michael Hunter bagpiper at pnet02.gryphon.com
Mon Oct 9 14:20:19 AEST 1989


jackson at jabberwock.shs.ohio-state.edu (Michel Jackson) writes:
>Press, Flannery, Teukolsky, & Vetterling remark, in their very useful
>book _Numerical Recipes: The Art of Scientific Computing_
>
[stuff about FORTRAN deleted]
>
>  In C, the most dubious control structure is the switch...case...default
>  construction, recognizable to FORTRAN programmers as a kind of elaborate
>  "computed goto". Not only is the structure a confusing one, with a
>  bizarre "drop through" feature, it is also burdened with uncertainty,
>  from compiler to compiler, about what data types are allowed in its
>  control expression. It can virtually always be easily replaced by a
>  more recognizable and translatable if ...else construction. (p.13)
>
>I generally agree with them. Some of the most confusing code I have
This is not meant as a flame, but these guys are the one who state in their
intro to the C version of their book that "...we intend that all the programs
should work on both mainframe, multi-user computers and on personal
computers." and then use a routine to provide arrays with indices between two
arbitrary index's by subracting a constant from an integer.  I don't usually
listen to their comments about programming.  I would rather think of their
code as a way to generate some numbers to test your own routines and that is
usually not worth much as test cases are fairly easy to come by for most of
the topics that they cover.

                                        Michael

UUCP: {ames!elroy, <routing site>}!gryphon!pnet02!bagpiper
INET: bagpiper at pnet02.gryphon.com



More information about the Comp.lang.c mailing list