🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #5328

Loops

#5328
From: Frank Adams
Date: Thu, 17 Mar 1988 22:21
36 lines
1652 bytes
The more I program, the more convinced I become that the 'while' loop is a
mistake.  It just doesn't match the semantics of too many real loops.

I would prefer something like the following:

do
	...
	while <exp> else
		...
	end while
	...
	while <exp>
	...
end do

The key points are:

(1) Exit from any point in the loop.
(2) Multiple exits.
(3) Code can be associated with any exit point.

I would use a special keyword (forever) instead of the normal end (end do)
in the case that the loop had no while's associated with it.  The compiler
should check that loops end in forever if and only if they have no while's.

C at least lets me write such a loop, although it's awkward.  (And missing
the ability to exit from within an inner loop, unless I want to use a goto.)
With many other structured languages, such a loop can be written only with
goto's.  (I am aware of the practice of using switches for exits, and
consider it no better than the goto -- the resulting code suffers from the
same readability and maintainability problems.)
-- 

Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Ashton-Tate          52 Oakland Ave North         E. Hartford, CT 06108
Technical Details
Message-ID: <2773@mmintl.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!necntc!linus!philabs!pwa-b!mmintl!franka
References: <2827@enea.se> <1557@pasteur.Berkeley.Edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!necntc!linus!philabs!pwa-b!mmintl!franka
From: franka@mmintl.UUCP (Frank Adams)
Newsgroups: comp.lang.misc
Subject: Loops
Message-ID: <2773@mmintl.UUCP>
Date: 17 Mar 88 22:21:43 GMT
References: <2827@enea.se> <1557@pasteur.Berkeley.Edu>
Reply-To: franka@mmintl.UUCP (Frank Adams)
Organization: Ashton-Tate Corporation, East Hartford Development Center
Lines: 36