Article View: comp.std.c
Article #3492Re: Multi-level break and elimination of GOTO
From: Christopher R. Volpe
Date: Thu, 16 Nov 1995 21:26
Date: Thu, 16 Nov 1995 21:26
52 lines
2423 bytes
2423 bytes
In article <4892se$np@news0.rain.rg.net>, Paul Long <plong@perf.com> writes:
>
>Oh, I'm sure somebody'd find a use for it and really like it. Here's
>how it could be (ab)used with an if statement.
>
> void manipulate_the_windows(Window *top)
> {
> Window *A = NULL, *B = NULL *C = NULL;
>
> if check_parms (top == NULL)
> break check_parms;
> else {
> do_something_with_window(top);
> A = get_subwindow(top);
> if (A == NULL)
> break check_parms;
>
> do_something_different_with_window(A);
> B = get_subwindow(A);
> if (B == NULL)
> break check_parms;
>
> do_something_with_window(B);
> C = get_subwindow(B);
> if (C == NULL)
> break check_parms;
>
> /* All windows I'm looking for are good, so do it */
> do_something_weird_with_four_windows(top,A,B,C);
>
> return;
> }
>
> /* Do error handling here */
> }
>
>Ugly, huh, early return and all? People do this sort of thing, though.
>What the programmer is doing here would be better served by a labeled
>compound statement and breaks to leave it (or situation indicators).
>Gotos are currently used. IMO, though, the best solution would be to
>rewrite the logic as something more conventional.
>
>BTW, this example came from something someone posted to comp.std.c
>awhile back. Look familiar?
Very familiar. I much prefer the way I originally wrote it.
--
Chris Volpe Phone: (518) 387-7766 (Dial Comm 8*833
GE Corporate R&D Fax: (518) 387-6560
PO Box 8, Schenectady, NY 12301 Email: volpecr@crd.ge.com
Technical Details
Message-ID:
<48gaaj$s4g@rdsunx.crd.ge.com>Path:
arc1-ca.pugleaf.net!bart.crd.ge.com!volpeReferences:
<DF8FE3.97H@news.cern.ch> <rnbohuqj8p3.fsf@euax7i3c01.eua.ericsson.se> <DHpCK1.HyG@kroete2.freinet.de> <480oqa$l1j@panix.com> <488orf$bfb@news.mel.aone.net.au> <4892se$np@news0.rain.rg.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!bart.crd.ge.com!volpe From: volpe@bart.crd.ge.com (Christopher R. Volpe) Newsgroups: comp.std.c,comp.lang.c Subject: Re: Multi-level break and elimination of GOTO Date: 16 Nov 1995 21:26:43 GMT Organization: GE Corporate Research & Development Sender: volpe@bart (Christopher R. Volpe) Distribution: world Message-ID: <48gaaj$s4g@rdsunx.crd.ge.com> References: <DF8FE3.97H@news.cern.ch> <rnbohuqj8p3.fsf@euax7i3c01.eua.ericsson.se> <DHpCK1.HyG@kroete2.freinet.de> <480oqa$l1j@panix.com> <488orf$bfb@news.mel.aone.net.au> <4892se$np@news0.rain.rg.net> Reply-To: volpe@ausable.crd.ge.com NNTP-Posting-Host: bart.crd.ge.com