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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6d748e86b56b1269 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-26 22:49:34 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!skynet.be!skynet.be!freenix!enst.fr!not-for-mail From: "Grein, Christoph" Newsgroups: comp.lang.ada Subject: Re: Prefix to 'ACCESS must either statically match... But why? Date: Mon, 27 Jan 2003 07:41:34 +0100 (MET) Organization: ENST, France Message-ID: Reply-To: "Grein, Christoph" , "comp.lang.ada mail to news gateway" NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii X-Trace: avanie.enst.fr 1043650174 36810 137.194.161.2 (27 Jan 2003 06:49:34 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 27 Jan 2003 06:49:34 +0000 (UTC) To: comp.lang.ada@ada.eu.org Return-Path: X-Authentication-Warning: mail.eurocopter.com: uucp set sender to using -f Content-MD5: 50/7dlwpKir7tAqe83uqiA== X-Mailer: dtmail 1.2.1 CDE Version 1.2.1 SunOS 5.6 sun4u sparc X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:33442 Date: 2003-01-27T07:41:34+01:00 > > Could somebody please explain me why is this rule present? I find it > > very limting. Is this because AR2 bounds are not stored with the > > object? > > > > Type Stream_Element_Array_access is access all Stream_Element_Array; > > > > AR1 : aliased Stream_Element_Array := ( 2, 4, 5 ); > > AR2 : aliased Stream_Element_Array ( 1 .. 3 ) := ( 2, 4, 5 ); > > > > AR1A : Stream_Element_Array_access := AR1'access; > > > > -- Illegal > > AR2A : Stream_Element_Array_access := AR2'access; > > > > > > LRM:3.10.2(27), The nominal subtype of the prefix to 'ACCESS or > > 'UNCHECKED_ACCESS must either statically match the designated subtype > > of the expected type or the designated subtype must be discriminated > > and unconstrained, Continuing > > Well I am a Ada-beginner myself so I might be wrong, but as far as I > understand strictly typed languages in general "Stream_Element_Array ( 1 .. 3 )" is a > new anonymous type which ist not a Stream_Element_Array anymore. A bit like typing > > Type Stream_Element_Array_AR2 is new Stream_Element_Array ( 1 .. 3 ); > AR2 : aliased Stream_Element_Array_AR2 := ( 2, 4, 5 ); No, that model is absolutely wrong! Stream_Element_Array ( 1 .. 3 ) is a subtype of Stream_Element_Array, not a new type derived from it. The difference is that Stream_Element_Array is unconstrained, Stream_Element_Array ( 1 .. 3 ) is constrained. Objects of Stream_Element_Array have their bounds stored. Objects of Stream_Element_Array ( 1 .. 3 ) have no bounds stored, the bounds are known at compile time. Stream_Element_Array_access is an access type to the unconstrained (first named subtype) Stream_Element_Array, so its objects cannot point to objects of the constrained subtype. So they do not statically match.