🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #5429

Re: Loops

#5429
From: 00704a-Liber
Date: Mon, 04 Apr 1988 23:27
36 lines
2103 bytes
In article <270@bby-bc.UUCP> john@bby-bc.UUCP (john) writes:
> Well it doesn't have to look that bad.

> done := false;
> while not done do begin
>	do_some;
>	done := done | done_now;
>	if not done then begin
>		do_some_more;
>		done := done | done_already;
>		end;
>		else do_even_more;
>	end;

I'm sorry, but to all but Pascal/Modula-2 programmers, this does look bad!!
Why should I have to have 9 or 10 levels of nesting so that I can 'fall off
the end of the loop'.  All this does is obscure the fact that I want to do
to the end of the loop.  This is one of the pluses of the 'break'
statement in C (although it is not general enough, but I don't want to
start that discussion again :-)).

>I don't quite understand your { ... causes a mess} comment; I had to guess
>- is do_even_more supposed to execute if done_already is false?

I think what he meant by leaving the 'else' clause off (a mistake about as
common as putting an = instead of a == in C), is that once you determine
that this loop is finished, no more code within it should be executed.  If
the else clause isn't there then unwanted execution probably occurs (ie,
do_even_more is suppose to be executed *only* if done_already is false).
If the style was good, you shouldn't of had to guess when do_even_more is
suppose to be (and not suppose to be) executed.
-- 
 _ __			NEVIN J. LIBER	..!ihnp4!ihlpf!nevin1	(312) 510-6194
' )  )				"The secret compartment of my ring I fill
 /  / _ , __o  ____		 with an Underdog super-energy pill."
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah
Technical Details
Message-ID: <4266@ihlpf.ATT.COM>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!uwvax!oddjob!gargoyle!att-ih!ihnp4!ihlpf!nevin1
References: <2827@enea.se> <1557@pasteur.Berkeley.Edu> <2773@mmintl.UUCP> <AWJ9X4y00WAHE53kVi@andrew.cmu.edu> <270@bby-bc.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!uwvax!oddjob!gargoyle!att-ih!ihnp4!ihlpf!nevin1
From: nevin1@ihlpf.ATT.COM (00704a-Liber)
Newsgroups: comp.lang.misc
Subject: Re: Loops
Message-ID: <4266@ihlpf.ATT.COM>
Date: 4 Apr 88 23:27:45 GMT
References: <2827@enea.se> <1557@pasteur.Berkeley.Edu> <2773@mmintl.UUCP> <AWJ9X4y00WAHE53kVi@andrew.cmu.edu> <270@bby-bc.UUCP>
Reply-To: nevin1@ihlpf.UUCP (00704a-Liber,N.J.)
Organization: AT&T Bell Laboratories - Naperville, Illinois
Lines: 36