[FoRK] Re: gotos was: open source awareness [was Re: BoRK BoRK BoRK]

Robert Harley robert.harley at gmail.com
Fri May 20 13:50:01 PDT 2005

>So what do you think about gotos?

You can't have asked that tongue-in-cheek and expected not to get an
actual answer, now, can you?

> cat foo/*.c bar/*.c [...] baz/*.c | sort | uniq | wc -l
> cat foo/*.c bar/*.c [...] baz/*.c | sort | uniq | grep goto | wc -l
> cat foo/*.c bar/*.c [...] baz/*.c | sort | uniq | grep goto
  if (!y) goto mem_err;
  if ((s64)ua <= 0L) goto pm_zero_or_negative;
  if (Ieq1(ipNum)) goto done0;
  if (argc != 1) goto syntax_err;;
  if (argn >= argc) goto expecting_more_arguments;
  if (argn >= argc) goto the_end;
  if (ch != '4') goto bad;
  if (ch != 'P') goto bad;
  if (div3(i) != j) goto broken;
  if (ea == 2047) goto pos_nan_or_inf;
  if (minCol >= minDist) goto done; /* Cost can't decrease... */
  if (pr >= NPRIMES) goto errOutOfPrimes;
  if (scanf("%d", &h) != 1 || h < 0) goto bad;

Obviously gotos are called for once in a while to branch away and
handle an error or speical case.  Other than that, break and continue
are your friends, except when you need summat like "break out of this
loop and the enclosing one and continue the one around that".  Then
you can use a contorted chunk of flag setting and checking and setting
and checking, or a goto.

I remain,

More information about the FoRK mailing list