Path: 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 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 else ... end while ... while ... 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