Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!mcnc!gatech!bloom-beacon!think!ames!hc!beta!cmcl2!phri!orville!dvm!hymie From: hymie@dvm.UUCP (Hyman Rosen) Newsgroups: comp.lang.c Subject: Re: goto's in C: an opinion... Message-ID: <322@dvm.UUCP> Date: Sun, 19-Jul-87 05:49:40 EDT Article-I.D.: dvm.322 Posted: Sun Jul 19 05:49:40 1987 Date-Received: Sun, 19-Jul-87 19:52:02 EDT References: <3289@bigburd.PRC.Unisys.COM> Reply-To: hymie@dvm.UUCP (Hyman Rosen) Organization: Philon, Inc. (NY, NY) Lines: 30 In article <3289@bigburd.PRC.Unisys.COM> weiss@bigburd.PRC.Unisys.COM (Tom Weiss) writes: > >Since now appears to be the time to express opinions about >style/clarity, I would like to address my own pet peeve: the goto >statement. > >There are very few legitimate uses for the goto statement, and C >provides alternates for most of them. ... > ... >Once I was involved in rewriting a piece of code which contained a ... > ... goto [that] was used to jump >forward into the middle of an if/else construct. ... That's about the only time that I've had to use goto's. (I usually handle jumping out of a couple of loops by an extra test.) The case that particularly comes to mind is in converting a string to float, which I've had to do a number of times (in situations where atof() or sscanf() were not options). Handling the cases of no digits before the decimal point or no digits after the decimal point always seems to require either a duplication of code, or a branch into one of the cases of an if-else statement, and I always choose the goto. On the other hand, another programmer I work with insists that this is an abomination, and would outrightly ban jumps into blocks from C. Note that in C++ such branches are forbidden when they would cause a declaration of an item with a constructor to be bypassed. -- - Hymie ...{decvax,ihnp4,ucbvax}!allegra!phri!orville!dvm!hymie