Article View: comp.lang.c.moderated
Article #2250Re: use of the break statement
From: news
Date: Tue, 12 Mar 1996 01:28
Date: Tue, 12 Mar 1996 01:28
25 lines
1834 bytes
1834 bytes
In article <4hqefk$1p5@solutions.solon.com> schwarz@a2.complang.tuwien.ac.at (Konrad Schwarz) writes:
>|> I have yet to see code which uses break/continue/goto which could not
>|> be re-written without them, but if used carefully they make the code
>|> clearer and faster.
>
>Sorry to be so vague, but a pair of Italian researchers prooved this in
>the late '60s or early '70s. Structured programming is equivalent in
>expression power to arbitrary gotos. (Of course this is obvious when
>you realize that a Turing machine can be implemented with programming
>constructs. I think what they did was to provide some kind of mapping
>from arbitrary programs using only goto to programs using only structured
>constructs.)
Essentially you can replace any goto+label with a switch variable
and one or more if/while constructs, and perhaps some replicated
code. Applying the process mechanically will of course just produce
code that is a much spagetti as anything built with goto's. When
reading code a human will have as much trouble with
condition = TRUE;
that causes a change of flow on the next page, as he will with a goto.
There is a place for gotos and restricted goto's (break continue etc).
There is also a place for switch variables. As always it takes
some thought, and usually a few rewrites to get the "right"
combination.
Technical Details
Message-ID:
<4i2jv0$8hp@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4h9ml2$gub@solutions.solon.com> <4hladl$4cr@solutions.solon.com> <4hqefk$1p5@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: news@Thinkage.On.CA Newsgroups: comp.lang.c.moderated Subject: Re: use of the break statement Date: 11 Mar 1996 19:28:00 -0600 Organization: Thinkage Ltd. Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4i2jv0$8hp@solutions.solon.com> References: <4h9ml2$gub@solutions.solon.com> <4hladl$4cr@solutions.solon.com> <4hqefk$1p5@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com