home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!decwrl!borland.com!pete
- From: pete@genghis.borland.com (Pete Becker)
- Newsgroups: comp.lang.c++
- Subject: Re: GOTO, was: Tiny proposal for na
- Message-ID: <1992Sep2.155510.4274@genghis.borland.com>
- Date: 2 Sep 92 15:55:10 GMT
- References: <2318@devnull.mpd.tandem.com> <rmartin.715001372@thor> <4192@papaya.bbn.com>
- Sender: news@borland.com (News Admin)
- Organization: Borland International
- Lines: 40
- Originator: pete@genghis.borland.com
-
- In article <4192@papaya.bbn.com> cbarber@bbn.com (Chris Barber) writes:
- >
- >My way:
- >
- >void foo(void)
- >{
- > FILE *fp = NULL ;
- > char *data = NULL ;
- >
- > if ((fp = fopen("foo", "r")) == NULL)
- > goto cleanup ;
- >
- > data = malloc(DATASIZE) ;
- >
- > if (DoStuff(fp, data) == ERROR)
- > goto cleanup ;
- >
- > DoMoreStuff(data) ;
- >
- > cleanup:
- > if (fp)
- > (void)fclose(fp) ;
- > if (data)
- > free(data) ;
- >}
- >
-
- C++ version:
-
- void foo()
- {
- ifstream input( "foo" );
- DataObject data;
- if( data.doStuff( input ) == ERROR )
- return;
- data.doMoreStuff();
- }
-
- Let the compiler do the work...
- -- Pete
-