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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,f66d11aeda114c52 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,f66d11aeda114c52 X-Google-Attributes: gid103376,public From: Paul M Gover Subject: Re: Building blocks (Was: Design By Contract) Date: 1997/10/01 Message-ID: <3432788C.E35@uk.ibm.com>#1/1 X-Deja-AN: 277068358 References: <34316EC3.5B62@dynamite.com.au> <199710011402.QAA02444@basement.replay.com> Reply-To: Paul_Gover@uk.ibm.com Organization: IBM Warwick Development Group Newsgroups: comp.lang.ada,comp.lang.eiffel Date: 1997-10-01T00:00:00+00:00 List-Id: Anonymous wrote: > ... > > Makes sense to me. OTOH there is a school of thought that eschews > > multiple exits. But that's another story. The point is, is that both > > versions show in a minimum number of lines the various options one has > > in Ada ( -83 at least, there are more in -95), which was the basic idea. > > I'm aware of those who think multiple exits are bad. This is something > that came out of program correctness proving. However, when you look at > languages that only allow a single exit from a loop (Pascal, excluding > gotos) you find many common situations in which this results in > unreadable code. For this reason, "exit" and the possiblity of multiple > exits were included in Ada, and are considered acceptable by all > competent software engineers. > ... Some of my colleagues worked on a language which had a loop exit when end construct, but with the restriction that each loop had exactly one exit. So it didn't allow multiple exits from a loop, but still allowed: loop record = file.read() exit when file.eof() thing.accept(record) end which keeps the code readable, and prevents duplication. Does this have any impact on correctness proofs? Presumably not much, as the loop can be converted to a true while-loop by duplication. (One of the while-loop problem is that for a tidy record processing program you have to write record = file.read() Do while(~file.eof()) thing.accept(record) record = file.read() End while ) -- Paul Gover IBM Warwick Development Group Mumbling for myself, not IBM