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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,74a56083ffbe573d X-Google-Attributes: gid103376,public From: husseinp@logica.co.uk (Paul Hussein) Subject: Re: Zoo question Date: 1996/08/14 Message-ID: <4usfu1$eug@romeo.logica.co.uk>#1/1 X-Deja-AN: 174117529 references: <320F16B6.6944@lmtas.lmco.com> organization: Logica UK Ltd. newsgroups: comp.lang.ada Date: 1996-08-14T00:00:00+00:00 List-Id: Ken Garlington wrote: >Here's a little brain teaser we received recently. Assuming no typos or >other obvious syntax errors, will the Fill procedure work in Ada 83? >package Zoo is > type Animal_ID is range 1 .. 5; -- yes, an enumeration type might be > -- better, but it spoils the example! > subtype Cage_ID is Positive range 1 .. 12; > type Cage_Row is array (Cage_ID) of Animal_ID; > -- Fill fills a row of cages with various animals, in sequential order > -- with alternating animals > procedure Fill ( Cages : in out Cage_Row ); >end Zoo; >package body Zoo is > procedure Fill ( Cages : in out Cage_Row ) is > Next_Animal : Animal_ID := Animal_ID'First; > begin -- Fill > for Cage in Cages'Range loop > Cages(Cage) := Next_Animal; > Get_Next_Animal: begin -- look carefully at this code! > Next_Animal := Animal_ID'Succ(Next_Animal); > exception > when others => Next_Animal := Animal_ID'First; > end Get_Next_Animal; > end loop; > end Fill; >end Zoo; I think it will 'work' also, but is not good example of ADA using exceptions in that way. I know youre going to come up with some more subtle problem.