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: 103376,74a56083ffbe573d X-Google-Attributes: gid103376,public From: rgilbert@unconfigured.xvnews.domain (Bob Gilbert) Subject: Re: Zoo question Date: 1996/08/14 Message-ID: <4uskjf$ilg@zeus.orl.mmc.com>#1/1 X-Deja-AN: 174142030 references: <3211C9C6.41C67EA6@escmail.orl.mmc.com> organization: The unconfigured xvnews people reply-to: rgilbert@unconfigured.xvnews.domain newsgroups: comp.lang.ada Date: 1996-08-14T00:00:00+00:00 List-Id: In article <3211C9C6.41C67EA6@escmail.orl.mmc.com>, Ted Dennison writes: > 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. I guess I should have said that the base type of Animal_ID is *equivalent* to or derived from type integer, at least as far as the constraints are concerned. > However, the base type's range may well be the same as integer's. As I would expect it to be. > 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. That's what I said (I think). The attribute 'Succ is not constrained to the specified range 1 .. 5, but I think I would expect a constraint check to raise an exception when making the assignment back to Next_Animal. -Bob