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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4fb6ec6cd054de65 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-12 08:56:14 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!hub1.nntpserver.com!peer1-sjc1.usenetserver.com!usenetserver.com!newsfeed1.cidera.com!Cidera!newsfeed.cwix.com!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: constrained subtypes X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3C8E2FDB.5E48CB9@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: <3c8cc63b$1@pull.gecm.com> <3c8dcc9d$1@pull.gecm.com> Mime-Version: 1.0 Date: Tue, 12 Mar 2002 16:42:03 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:21122 Date: 2002-03-12T16:42:03+00:00 List-Id: George Stevens wrote: > > Problem seemed to be in using: > > case (constrained_subtype) > > rather than: > > case constrained_subtype > > Removing the brackets sorted the problem. Not sure why this is a problem > for constrained subtypes, as the compilers cope fine for enums and (base) > integers. 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). -- Jeffrey Carter