From: Christoph Grein <christoph.grein@eurocopter.com>
Subject: Re: constrained subtypes
Date: Wed, 13 Mar 2002 07:22:09 +0100 (MET)
Date: 2002-03-13T07:22:09+01:00 [thread overview]
Message-ID: <mailman.1016000642.11581.comp.lang.ada@ada.eu.org> (raw)
> From: Jeffrey Carter <jeffrey.carter@boeing.com>
> With parentheses, you have an expression, which is of the unconstrained
> base subtype (Integer'Base), not the constrained subtype. Expressions
> are always evaluated using the unconstrained base type. This allows
> things such as
>
> subtype X is Integer range 1 .. 8;
> Y : Integer := 16;
> Z : X;
> ...
> Z := Y / 2;
> Y := 3 * Z;
>
> to be legal. "Y / 2" is not necessarily in X, so a constraint check is
> performed before assignment. "3 * Z" is not of subtype X, but is legal,
> even though Z is of subtype X, because it is an expression.
>
> This is why "case Z" and "case (Z)" are different. "Case Y" and "case
> (Y)" cover the same range, so you don't see a difference (though it's
> there).
>
Nice exegesis, I also thought it was this way. But when I looked into the RM, I
found only:
4.4(7) primary ::= numeric_literal | null | string_literal | aggregate
| name | qualified_expression | allocator | (expression)
4.4(9) Each expression has a type; it specifies the computation or retrieval
of a value of that type.
4.4(10) The value of a primary that is a name denoting an object is the
value of the object.
Thus (X) has to be further reduced to X, and then X denotes an object,
so where is the difference between "case X is" and "case (X) is"?
I would like to see a formal exegesis with the RM.
next reply other threads:[~2002-03-13 6:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-13 6:22 Christoph Grein [this message]
2002-03-13 14:18 ` constrained subtypes Robert Dewar
-- strict thread matches above, loose matches on Subject: below --
2002-03-14 11:01 Christoph Grein
2002-03-12 10:37 Christoph Grein
2002-03-12 7:59 Christoph Grein
2002-03-11 15:00 George Stevens
2002-03-11 16:16 ` Stephen Leake
2002-03-11 16:50 ` Jeffrey Carter
2002-03-11 21:05 ` Anh_Vo
2002-03-12 9:39 ` George Stevens
2002-03-12 10:38 ` Martin Dowie
2002-03-12 11:57 ` George Stevens
2002-03-12 12:02 ` Martin Dowie
2002-03-12 12:03 ` Martin Dowie
2002-03-12 16:42 ` Jeffrey Carter
2002-03-13 22:09 ` Wannabe h4x0r
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox