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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,80134c7589e7b709 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-12 10:18:29 PST Path: supernews.google.com!sn-xit-03!supernews.com!cyclone2.usenetserver.com!news-out.usenetserver.com!newsfeed.icl.net!newspeer.clara.net!news.clara.net!btnet-peer!btnet-peer0!btnet!news5-gui.server.ntli.net!ntli.net!news6-win.server.ntlworld.com.POSTED!not-for-mail From: "chris.danx" Newsgroups: comp.lang.ada References: <3AACECE3.6D6E274E@bton.ac.uk> Subject: Re: Two questions X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: Date: Mon, 12 Mar 2001 18:11:44 -0000 NNTP-Posting-Host: 62.253.15.86 X-Complaints-To: abuse@ntlworld.com X-Trace: news6-win.server.ntlworld.com 984420703 62.253.15.86 (Mon, 12 Mar 2001 18:11:43 GMT) NNTP-Posting-Date: Mon, 12 Mar 2001 18:11:43 GMT Organization: ntlworld News Service Xref: supernews.google.com comp.lang.ada:5649 Date: 2001-03-12T18:11:44+00:00 List-Id: I misread it. Thanks for your help, Chris Campbell "John English" wrote in message news:3AACECE3.6D6E274E@bton.ac.uk... > "chris.danx" wrote: > > > > Hi, > > two questions, one on exceptions and one on objects or tagged types. > > > > Where exactly can i put an exception handler? I read in JE's book that you > > can put them in loop ... end loop statements after an exit statement. > > You've misread the book then, or written "can" instead of "can't" by mistake... > > > I > > normally put handlers at the end of a routine, and i was supprised to find > > you could put them elsewhere. What i want to know is where else can i put > > them? In a while loop? In a for loop? In an if? ... etc. > > Inside a begin...end block (which can go inside a loop or whatever), e.g. > like this: > > loop > begin > Put("Enter an integer: "); > Get(X); > exit; -- get out of loop if this line is reached > exception > when Constraint_Error | Data_Error => > Put_Line ("Error in input -- please try again"); > Skip_Line; -- end up here if "Get" fails, > end; -- so don't exit from the loop > end loop; > > (This is the example from p.40 of my book.) > > > The second is to do with tagged types. Sometimes it is suggested that you > > put your 'create routine' -- the initialisation routine -- in a nested > > package. Others suggest putting it in the same package as the tagged type. > > > > Example > > > > package something_cool is > > > > type cool is tagged private; > > > > package constructor is > > > > procedure create (c : out cool; ... ... ); > > > > end constructor; > > > > private > > ... > > ... > > > > end something_cool; > > > > or > > > > package something_cool is > > > > type cool is tagged private; > > > > procedure create (c : out cool; ... ... ); > > > > private > > ... > > ... > > > > end something_cool; > > > > What's the difference? Where should i use method 1 and where should i use > > method 2? > > Generally, use the first. If you use the second approach, "create" > is inherited by types derived from Cool, but it may well need extra > parameters for a derived type... so you end up with two versions of > Create, one with the old set of parameters (which will presumably do > incomplete initialisation) which you might call accidentally. The > second technique just avoids making Create a primitive of Cool, so > it isn't inherited. (This is discussed in section 14.6 of my book.) > > ----------------------------------------------------------------- > John English | mailto:je@brighton.ac.uk > Senior Lecturer | http://www.it.bton.ac.uk/staff/je > Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS ** > University of Brighton | -- see http://burks.bton.ac.uk > -----------------------------------------------------------------