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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e646052dc594401f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,CP1252 Path: g2news2.google.com!postnews.google.com!c33g2000yqm.googlegroups.com!not-for-mail From: Martin Newsgroups: comp.lang.ada Subject: Re: Strategies with SPARK which does not support exceptions Date: Fri, 18 Jun 2010 01:49:20 -0700 (PDT) Organization: http://groups.google.com Message-ID: <28cc6b90-fce4-44e0-903e-9c1dd1b91f5a@c33g2000yqm.googlegroups.com> References: NNTP-Posting-Host: 20.133.0.8 Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1276850960 11152 127.0.0.1 (18 Jun 2010 08:49:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 18 Jun 2010 08:49:20 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c33g2000yqm.googlegroups.com; posting-host=20.133.0.8; posting-account=g4n69woAAACHKbpceNrvOhHWViIbdQ9G User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:12784 Date: 2010-06-18T01:49:20-07:00 List-Id: On Jun 18, 9:06=A0am, Phil Thornley wrote: > On 17 June, 16:33, Yannick Duch=EAne (Hibou57) > > > > wrote: > > Hello, > > > (This topic will probably not be the most exiting topic to some people)= . > > > When I use SPARK, or even when I don't use SPARK while I still have SPA= RK =A0 > > design style in mind (even with Pascal which I still use), I have like = any =A0 > > one else, to forget about exceptions. > > > The only one thing which seems simple and clean enough I could figure, = is =A0 > > to use a Boolean variable, named =93OK=94, and a sequence of =93if OK t= hen=94 =A0 > > statements. That is, execution of one sequence of statements, which set= OK =A0 > > to False is something goes wrong, and execute clean-up statements by th= e =A0 > > way. Then a next sequence of statements wrapped in a =93if OK then=94 w= hich do =A0 > > the same, and so on with next statements groups which are also wrapped = in =A0 > > a =93if OK then=94 (as many as needed). > > > Although this seems clean and maintainable enough to me so far, I was = =A0 > > still wondering how other people deal with this (and may be by the way,= I =A0 > > may have comment about why my way could be bad in some way). > > > Note: a similar strategy may also obviously applies to fulfill the =93o= nly =A0 > > one single exit point=94 requirement. > > > So, let us talk and comment about design strategies in this area (if = =A0 > > someones wish to). > > (Perhaps not an entirely serious suggestion, but...) > The only way of interrupting a code sequence in SPARK is the exit > statement for a loop, so one possibility might be to create a 'single > pass' loop with an unconditional exit at the end. > > Unfortunately such an unconditional exit is illegal, so you have to > use 'exit when True;' > > Also there may be flow errors for some or all of the 'exit when' > statements (if the OK values only depend on the program inputs) - but > here we can put an accept statement - which will usefully document > that the loop is a not a real loop. > > --# accept F, 40, "This is a single pass loop."; > OK :=3D True; > loop > =A0 =A0Some complicated code that might set OK; > =A0 =A0exit when not OK; > =A0 =A0Some more complicated code that might set OK; > =A0 =A0exit when not OK; > =A0 =A0Some more code; > =A0 =A0exit when True; > end loop; > > :-) > > Cheers, > > Phil No there's a fancy 'goto'! :-) -- Martin