Path: utzoo!utgpu!water!watmath!clyde!bellcore!faline!purtill From: purtill@faline.bellcore.com (Mark Purtill) Newsgroups: comp.lang.c Subject: Re: gotos Message-ID: <1842@faline.bellcore.com> Date: 17 Apr 88 23:11:25 GMT Reply-To: purtill@math.mit.edu (Mark Purtill) Distribution: na Organization: Bell Communications Research Lines: 34 Organization: In article <> ajmyrvold@violet.waterloo.edu (Alan Myrvold) writes: >Why do I use goto's ? > >Because I believe that every function should have >exactly one entry point and exactly one exit point. > >Multiple RETURN statements are as bad as bad goto's -- i.e. >the thread of the subroutine gets confusing. First off, I find this claim dubious to say the least, especially if many returns are error returns (eg: char * get_foo( char *filename) { /* returns the foo or NULL on error */ ... if(( fp = fopen( filename, mode)) == NULL) { return (char *)NULL ; } ... if( syntax error in the foo) return (char *)NULL ; ... return foo ; } ). In any case, I fail to see how replacing a "return" with a "goto" will make it any less confusing, especially given that the label for the goto may be on the next page, or that the next person to deal with the code may add code after the label, etc. All you've done is replace earlier "return"s with "goto label"s which may not really do what you want. ^.-.^ Mark Purtill ((")) purtill@math.mit.edu