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: Ted Dennison Subject: Re: Zoo question Date: 1996/08/14 Message-ID: <3211C9C6.41C67EA6@escmail.orl.mmc.com>#1/1 X-Deja-AN: 174139218 references: <320F16B6.6944@lmtas.lmco.com> <4usdkl$fg6@zeus.orl.mmc.com> content-type: text/plain; charset=us-ascii organization: Lockheed Martin Information Systems mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.0 (X11; I; SunOS 4.1.3_U1 sun4m) Date: 1996-08-14T00:00:00+00:00 List-Id: Bob Gilbert wrote: > > In article <320F16B6.6944@lmtas.lmco.com>, Ken Garlington writes: > > 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 > > I assume that the tricky part is that the attribute 'Succ operates > on the base type of Animal_ID, which is of type integer, and does not > consider the constraint 1 .. 5 (although the attributes 'First and This didn't sound right to me, so its LRM time... 3.5.4 - the type declaration is equivalent to - type integer_type is new predefined_integer_type; subtype Animal_ID is integer_type range 1..5; where integer_type is an ananoymous base type, snd predefined_integer_type can be any predefined integer type the compiler wants, as long as it includes 1 and 5. Thus the base type is NOT integer. However, the base type's range may well be the same as integer's. 3.5.5(8) - Animal_ID'SUCC(Next_Animal) returns a value in the range of the BASE type of Animal_ID, which is the range of whatever predefined type the compiler picked above. However, when this value is assigned back into Next_Animal, it is subject to a constraint check on the 1..5 range. The constraint check doesn't HAVE to happen, but it could. -- T.E.D. | Work - mailto:dennison@escmail.orl.mmc.com | | Home - mailto:dennison@iag.net | | URL - http://www.iag.net/~dennison |