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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a0c:f404:: with SMTP id h4mr14555367qvl.251.1580084532361; Sun, 26 Jan 2020 16:22:12 -0800 (PST) X-Received: by 2002:a9d:3d0a:: with SMTP id a10mr10845505otc.327.1580084532006; Sun, 26 Jan 2020 16:22:12 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!g89no2467570qtd.0!news-out.google.com!w29ni556qtc.0!nntp.google.com!g89no2467566qtd.0!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 26 Jan 2020 16:22:11 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=71.250.209.52; posting-account=h3IwYwoAAAAeE2lWQnRSCqcQ0dO-KDvQ NNTP-Posting-Host: 71.250.209.52 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <79386e8a-20cb-4bcb-a60a-531919ee6976@googlegroups.com> Subject: Having problems instantiating a child class with an extension aggregate From: b.mcguinness747@gmail.com Injection-Date: Mon, 27 Jan 2020 00:22:12 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:57958 Date: 2020-01-26T16:22:11-08:00 List-Id: I have three packages: ---------------------------------------------------------------------------= ----- -- Basic data types used by other packages ---------------------------------------------------------------------------= ----- package APL_Types is ... type Int64 is range -9223372036854775808..9223372036854775807= ; subtype Int32 is Int64 range -2147483648..2147483647; subtype Int16 is Int64 range -32768..32767; subtype APL_Integer is Int64; ... type Array_Index is range 0..APL_Integer'Last; type Index_List is array(Array_Index range <>) of Array_Index; type Index_List_Pointer is access Index_List; procedure Free_Index_List is new Ada.Unchecked_Deallocation (Index_List, = Index_List_Pointer); subtype Dimensions is Index_List; type Dimensions_Pointer is access Dimensions; procedure Free_Dimensions is new Ada.Unchecked_Deallocation (Dimensions, = Dimensions_Pointer); ... end APL_Types; ---------------------------------------------------------------------------= ----- -- This holds the dimensions of the array, which can change over time -- -- The array elements are handled by child classes since they might either = be -- stored in the array or calculated when required. ---------------------------------------------------------------------------= ----- with Ada.Finalization; with APL_Types; package APL_Arrays is use APL_Types; type APL_Array is new Ada.Finalization.Controlled with private; type APL_Array_Pointer is access APL_Array; function Effective_Rank (array_rank, function_rank : Array_Index) return= Array_Index; procedure Finalize (this : in out APL_Array); function Length (this : in APL_Array; axis : Array_Index) return= Array_Index; function Rank (this : in APL_Array) return Array_Index; function Raveled_Length (this : in APL_Array) return Array_Index; function Raveled_Shape ( shape : Dimensions;=20 function_rank : Array_Index;=20 to_table : in Boolean :=3D false ) return Dimensions_Pointer; function Same_Shape (this, other : in APL_Array) return Boolean; private type APL_Array is new Ada.Finalization.Controlled with record g_shape : Dimensions_Pointer; end record; end APL_Arrays; ---------------------------------------------------------------------------= ----- -- Arrays that store each array element ---------------------------------------------------------------------------= ----- with Ada.Unchecked_Deallocation; with APL_Arrays, APL_Types; generic type Element is private; package APL_Data_Arrays is use APL_Types; type APL_Data_Array is new APL_Arrays.APL_Array with private; type APL_Data_Array_Pointer is access APL_Data_Array; type Scalar_Monadic_Function is access function (right : Element) return = Element; type Scalar_Dyadic_Function is access function (left, right : Element) r= eturn Element; function Apply_Scalar_Dyadic ( left, right : in APL_Data_Array; -- The arrays to be operated on lrank, rrank : Array_Index; -- The left and right function r= ank fn : Scalar_Dyadic_Function -- Function to apply to the arra= ys ) return APL_Data_Array_Pointer; function Apply_Scalar_Monadic ( right : in APL_Data_Array; -- The array to be operated on fn : Scalar_Monadic_Function -- The function to apply to the array ) return APL_Data_Array_Pointer; procedure Finalize (this : in out APL_Data_Array); overriding function Raveled_Length (this : in APL_Data_Array) return Arra= y_Index; private use APL_Types; type Elements is array(Array_Index range <>) of Element; type Elements_Pointer is access Elements; procedure Free_Elements is new Ada.Unchecked_Deallocation (Elements, Elem= ents_Pointer); type APL_Data_Array is new APL_Arrays.APL_Array with record g_data : Elements_Pointer; end record; end APL_Data_Arrays; I am trying to create instances of APL_Data_Array in apl_data_arrays.adb. = I have procedures that perform operations on one or two arrays and generate= a third array with the same dimensions as one of the original arrays, so I= want to create a result array, copying the dimensions from an existing arr= ay and allocating space for the array elements to be calculated. I tried: result : APL_Data_Array_Pointer :=3D new APL_Data_Array'( g_shape =3D> new Dimensions'(right.g_shape.all), g_data =3D> new Elements(right.g_data.all'Range) ); This gives me an error message: apl_data_arrays.adb:180:36: type of aggregate has private ancestor "Control= led" apl_data_arrays.adb:180:36: must use extension aggregate But when I try: result : APL_Data_Array_Pointer :=3D new APL_Data_Array'( APL_Array'(new Dimensions'(right.g_shape.all)) with g_data =3D> new Elements(right.g_data.all'Range) ); I get another error message: apl_data_arrays.adb:180:48: no selector "g_shape" for type "APL_Data_Array"= defined at apl_data_arrays.ads:46 This puzzles me since g_shape is a member of the parent class and should be= visible to the child class. I don't see how to fix the problem. I would appreciate help. --- Brian McGuinness