[OT] [sdiy] IN your mind, what is ....
Michael E. Caloroso
analoguediehard at att.net
Wed Feb 4 04:13:16 CET 2004
Shokwave wrote:
>
> This reminds me of goto's in C. I make a point of showing my students some
> of my code that contains a line like:
>
> if(stuff_happened) goto error;
>
> ...nestled at the center of a deeply nested loop. They always look at each
> other, and gingerly one will raise a hand and say "but other instructors
> told us to never use a goto", and I grin peacefully like Buddha and say
> "Yes, *you* shouldn't...unless you know you should. Try and write that code
> without one, and show me a CLEARER way to do it.
(loopx (condition) substituted for, do, while, etc)
error=0;
loop1 (condition1 & !error)
{
loop2 (condition2 & !error)
{
...code
if (fubar) error=1; /* all loops exit when returned to top */
if (error) continue; /* aborts rest of loop2 */
...code
} /* end loop2 */
if (error) continue; /* aborts rest of loop1 */
} /* end loop1 */
There is ALWAYS a way around goto statements. Not a simpler solution,
but it keeps the pointer stack clean which is a goto cannot do.
I design code to run 24/7. goto statements are forbidden in my work.
MC
More information about the Synth-diy
mailing list