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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d342f2360cfae987 X-Google-Attributes: gid103376,public From: Simon Wright Subject: Re: what is happening here? (access types & discriminants...) Date: 2000/03/19 Message-ID: #1/1 X-Deja-AN: 600081929 X-NNTP-Posting-Host: pogner.demon.co.uk:158.152.70.98 References: X-Trace: news.demon.co.uk 953584454 nnrp-13:21282 NO-IDENT pogner.demon.co.uk:158.152.70.98 Organization: At Home Newsgroups: comp.lang.ada X-Complaints-To: abuse@demon.net Date: 2000-03-19T00:00:00+00:00 List-Id: dale@cs.rmit.edu.au (Dale Stanbrough) writes: > I've got the equivalent of the following code... > > with ada.strings.unbounded; use ada.strings.unbounded; > > package ua is > type Unbounded_Array is array (Positive range <>) of Unbounded_String; > type Unbounded_Array_Ptr is access Unbounded_Array; > > > i_dont_understand : unbounded_Array_ptr (1..100); > end ua; > > > Not quite sure what the definition of i_dont_understand is doing... Judging by this experiment, with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_Io; use Ada.Text_Io; procedure Ua is type Unbounded_Array is array (Positive range <>) of Unbounded_String; type Unbounded_Array_Ptr is access Unbounded_Array; I_Dont_Understand : Unbounded_Array_Ptr (13 .. 42) := new Unbounded_Array (13 .. 42); Me_Neither : Unbounded_Array_Ptr := new Unbounded_Array (14 .. 43); begin Put_Line ("f" & I_Dont_Understand'First'Img & " l" & I_Dont_Understand'Last'Img); Put_Line ("f" & Me_Neither'First'Img & " l" & Me_Neither'Last'Img); -- I_Dont_Understand := Me_Neither; ------------------ CE -- Put_Line ("f" & I_Dont_Understand'First'Img & -- " l" & I_Dont_Understand'Last'Img); I_Dont_Understand.all := Me_Neither.all; Put_Line ("f" & I_Dont_Understand'First'Img & " l" & I_Dont_Understand'Last'Img); Me_Neither := new Unbounded_Array (13 .. 43); Put_Line ("f" & Me_Neither'First'Img & " l" & Me_Neither'Last'Img); end Ua; where the commented-out bit raises Constraint_Error, we've declared i_dont_understand as a pointer capable of pointing only to arrays with the designated constraint. So an array assignment (of the right length) is OK, but a pointer assignment with different constraints isn't.