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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,af3dada69080e420 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-24 05:46:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!dialin-145-254-043-014.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Interesting effects in array renaming Date: Tue, 24 Jun 2003 14:48:46 +0200 Organization: At home Message-ID: References: <3EF5E6B8.3030203@spam.com> <3EF7B8CC.3000100@attbi.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-043-014.arcor-ip.net (145.254.43.14) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1056458760 28178790 145.254.43.14 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:39658 Date: 2003-06-24T14:48:46+02:00 List-Id: Georg Bauhaus wrote: > Dmitry A. Kazakov wrote: > : That the new view is wellcome to be inconsistent does not follow from > : that. It is written pair lines below. BTW, for tagged types it is > : different and semantically consistent: > : > : procedure Foo (X : Base'Class) is > : XX : Derived renames X; -- Illegal > : XX : Derived renames Derived (X); -- Legal and *CHECKED* > > I'm not sure, considering > > procedure Foo (X : in out Varying'Class) is > subtype Nono is Changeant (false); > X1 : Changeant renames X; -- Illegal > X2 : Nono renames Changeant(X); -- Legal and *CHECKED* You could make it even more scandalous: X2 : Nono renames Nono(X); -- !!!No discriminant checks!!! > begin > X2.messy := 2 * X2.messy; > -- constraint_error when discriminant is true > end Foo; > > where > package Derivs is > > type Varying (special: Boolean) > is > tagged record > comp: Natural; > end record; > > type Changeant (very_special: Boolean) > is > new Varying(very_special) with > record > case very_special is > when true => > another: Boolean; > when false => > messy: Integer; > end case; > end record; > end Derivs; Clarification: I meant tags, not discriminants (of possibly tagged types). What happens in your example, is the following. Nono has two constraints: 1. The discriminant very_special => False 2. The tag => Changeant'Tag (viewed as a constraint for any of the classes: Varying'Class, Changeant'Class) When you rename X, the constraint 2 is checked. The constraint 1 is silently ignored as ARM requires. Here we are. Now, convince me that it is GOOD. -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de