From: Ted Dennison <dennison@escmail.orl.mmc.com>
Subject: Re: Zoo question
Date: 1996/08/14
Date: 1996-08-14T00:00:00+00:00 [thread overview]
Message-ID: <3211C9C6.41C67EA6@escmail.orl.mmc.com> (raw)
In-Reply-To: 4usdkl$fg6@zeus.orl.mmc.com
Bob Gilbert wrote:
>
> In article <320F16B6.6944@lmtas.lmco.com>, Ken Garlington <garlingtonke@lmtas.lmco.com> 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 |
next prev parent reply other threads:[~1996-08-14 0:00 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-08-12 0:00 Zoo question Ken Garlington
1996-08-12 0:00 ` Chris Morgan
1996-08-13 0:00 ` Ken Garlington
1996-08-13 0:00 ` Ted Dennison
1996-08-14 0:00 ` Ken Garlington
1996-08-14 0:00 ` Ted Dennison
1996-08-15 0:00 ` Ken Garlington
1996-08-18 0:00 ` Robert Dewar
1996-08-19 0:00 ` Ted Dennison
1996-08-19 0:00 ` Mark A Biggar
1996-08-20 0:00 ` Robert Dewar
1996-08-15 0:00 ` Robert A Duff
1996-08-15 0:00 ` Robert Dewar
1996-08-15 0:00 ` Bob Gilbert
1996-08-19 0:00 ` Ted Dennison
1996-08-16 0:00 ` Ken Garlington
1996-08-19 0:00 ` Ted Dennison
1996-08-15 0:00 ` Keith Thompson
1996-08-14 0:00 ` Bob Gilbert
1996-08-14 0:00 ` Ted Dennison [this message]
1996-08-14 0:00 ` Bob Gilbert
1996-08-14 0:00 ` Ted Dennison
1996-08-14 0:00 ` Bob Gilbert
1996-08-14 0:00 ` Ken Garlington
1996-08-15 0:00 ` Robert A Duff
1996-08-16 0:00 ` Bob Gilbert
1996-08-19 0:00 ` Ted Dennison
1996-08-25 0:00 ` Robert Dewar
1996-08-15 0:00 ` Robert I. Eachus
1996-08-14 0:00 ` Paul Hussein
1996-08-15 0:00 ` John Herro
1996-08-16 0:00 ` Robert Dewar
1996-08-18 0:00 ` John Herro
1996-08-19 0:00 ` Ken Garlington
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox