From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,a9ec16e88ef2b543 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,a7b18e7570ac8dc3 X-Google-Attributes: gid103376,public X-Google-Thread: f43e6,a9ec16e88ef2b543 X-Google-Attributes: gidf43e6,public X-Google-ArrivalTime: 1994-09-12 05:24:27 PST Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!EU.net!Germany.EU.net!netmbx.de!zrz.TU-Berlin.DE!zib-berlin.de!gs.dfn.de!news.dkrz.de!dscomsa.desy.de!x4u2!mernst From: mernst@desy.de (Matthias Ernst) Newsgroups: comp.software-eng,comp.lang.eiffel,comp.lang.ada Subject: Re: Eiffel gripe (was Ada vs. Eiffel) Followup-To: comp.software-eng,comp.lang.eiffel,comp.lang.ada Date: 12 Sep 1994 09:35:14 GMT Organization: DESY Message-ID: <3517ci$f12@dscomsa.desy.de> References: <1994Sep1.094653@lglsun.epfl.ch> <34473c$ru5@info2.rus.uni-stuttgart.de> <344isl$brd@Starbase.NeoSoft.COM> <3450li$t04@disuns2.epfl.ch> <1994Sep4.100449.205@aldur.demon.co.uk> <34e4rgINNqdg@ephor.tusc.com.au> NNTP-Posting-Host: x4u2.desy.de X-Newsreader: TIN [version 1.2 PL2] Xref: nntp.gmd.de comp.software-eng:17588 comp.lang.eiffel:4118 comp.lang.ada:14628 Date: 1994-09-12T09:35:14+00:00 List-Id: Anthony Shipman (als@tusc.com.au) wrote: : In <1994Sep4.100449.205@aldur.demon.co.uk> neil@aldur.demon.co.uk (Neil Wilson) writes: : The absence of a 'break'-like statement or early return can make coding a : lot more tedious than it should be. Since code with a break or early return : can be mechanically translated into code without why have the programmer do : it? : The one type of loop that has been settled on doesn't cover the range of : loop architectures in common use. It provides a : loop : if not condition then break; : B; : end : style of loop whereas a : loop : A; : if not condition then break; : B; : end : style would be more general. The second reduces to the first by : omitting A but the first cannot be used to implement the second without : duplicating code as in: : [deleted] Ever looked at Sather ? Its iteration approach is IMO the synthesis of powerful but simple constructs. A loop in Sather consists of a - loop ... end frame. - normal code - iter calls An iter is something like a function/procedure with the difference that it has control of the embedding loop: it may either 'yield' control to the loop or 'quit' which exits the loop. Sequential calls to the iter resume execution after the last 'yield' statement. Examples are better than thousand words: [conservative]: i := 1; sum := 0; loop sum := sum + i; until i = 10; [innovative]: sum := 0; loop sum := sum + 1.upto!(10); end; or i := 0; loop while i<10 CODE; i := i+1; end; better: loop 10.times!; CODE end; Here the iters upto! and times! encapsulate - initialization - loop variance - termination Note that the standard loop controls while, until, break can easily be expressed as iters: while yields as long as its argument is true until yields as long as its argument is false break quits immediately One difference: calls to while! and until! can appear ANYWHERE in the loop: loop i := get_int; while!(i ~= 0); print 1/i; end; Further you can easily generalize iteration through containers of any kind. If you're interested, look at the Sather home page: http://www.icsi.berkeley.edu/Sather There is a tech report about iters. Matthias : -- : Anthony Shipman "You've got to be taught before it's too late, : TUSC Computer Systems Pty Ltd Before you are six or seven or eight, : To hate all the people your relatives hate, : E-mail: als@tusc.com.au You've got to be carefully taught." R&H