From: Adrian Hoe <abyhoe@gmail.com>
Subject: Re: Type in allocator has deeper level than designated class-wide type
Date: Mon, 13 Jun 2011 18:11:45 -0700 (PDT)
Date: 2011-06-13T18:11:45-07:00 [thread overview]
Message-ID: <551ab9c5-f3e8-470d-8d11-4d250b1bb0a0@q12g2000prb.googlegroups.com> (raw)
In-Reply-To: 1e38ede5-7df3-46d5-836e-f48cec87628e@v11g2000prk.googlegroups.com
On Jun 14, 9:08 am, Adam Beneschan <a...@irvine.com> wrote:
> On Jun 13, 5:49 pm, Adrian Hoe <aby...@gmail.com> wrote:
>
>
>
>
>
> > On Jun 14, 1:11 am, Adam Beneschan <a...@irvine.com> wrote:
>
> > > On Jun 13, 8:31 am, Adrian Hoe <aby...@gmail.com> wrote:
>
> > > > Hi all,
>
> > > > I have stomped into above error and I am stuck with the error and
> > > > runtime exception PROGRAM_ERROR : accessibility check failed.
>
> > > > Here's the fragment of my codes:
>
> > > > generic
> > > > N : Positive;
> > > > type Item is private;
> > > > package High_Cloud is
>
> > > > package List renames Heterogeneous_Doubly_Link_List;
> > > > use List;
>
> > > > type Data_Array is array ( 1 .. N ) of Item;
>
> > > > type Element_Record is new List.Node with private;
> > > > type Series_Access is new List.Access_List;
>
> > > > private
>
> > > > type Element_Record is new List.Node with
> > > > record
> > > > Name : Unbounded_String;
> > > > Color : Unbounded_String;
> > > > Data : Data_Array;
> > > > end record;
>
> > > > ...
> > > > end High_Cloud;
>
> > > > In the package body of High_Cloud, I have a procedure:
>
> > > > procedure Add
> > > > ( Cloud : in out High_Cloud_Record;
> > > > Name : in Unbounded_String;
> > > > Color : in Unbounded_String;
> > > > Data : in Data_Array )
> > > > is
>
> > > > New_Element : List.Access_Node;
>
> > > > begin
>
> > > > New_Element := new Element_Record'
> > > > <========== Error/Warning here.
> > > > ( Constructor.Init ( Name, Color, Data) ) ;
>
> > > > Concatenate ( Cloud.Series, New_Element ) ;
>
> > > > end Add;
>
> > > > My intention is to use genericity to create a data which is an array
> > > > (1..N) of any_type. This data is then stored in a list. Procedure Add
> > > > instantiate (by calling to Constructor.Init) the list's node with
> > > > data.
>
> > > > I have read the ARM 3.10.2 and 3.10.1 and also John Barnes book yet I
> > > > still have no clue how to solve the problem.
>
> > > > Can you please help? Thanks.
>
> > > I think we need to see the definition of Constructor.Init, at least.
> > > (I'm guessing that Heterogeneous_Doubly_Link_List is a library package
> > > that defines Node as a tagged record and Access_Node as "access all
> > > Node'Class". But I don't have a guess about what Init is.)
>
> > > -- Adam
>
> > Yes, you are right. In Heterogeneous_Doubly_Link_List:
>
> > type List is limited private;
> > type Access_List is access List;
>
> > type Node is tagged private;
> > type Access_Node is access all Node'Class;
>
> > private
>
> > type Node is tagged record
> > Previous : Access_Node;
> > Next : Access_Node;
> > end record;
>
> > type List is limited record
> > Head : Access_Node := null;
> > Tail : Access_Node := null;
> > Current : Access_Node := null;
> > Count : Unsigned := 0;
> > end record;
>
> > And:
>
> > package body Constructor is
>
> > function Init
> > ( New_Name : Unbounded_String;
> > New_Color : Unbounded_String;
> > New_Data : Data_Array )
> > return Element_Record is
> > begin
> > return ( List.Constructor.Init
> > with
> > Name => New_Name,
> > Color => New_Color,
> > Data => New_Data
> > ) ;
> > end Init;
>
> > end Constructor;
>
> > Is the problem lying in the Data : Data_Array in Element_Record or in
> > the return statement of Constructor.Init?
>
> Where is the above Constructor package defined? Is it directly within
> High_Cloud, or is it defined inside a subprogram in the body of
> High_Cloud?
>
> Assuming it's the former, I can't get either our compiler or GNAT
> (4.5.2) to generate an error or warning message. However, I don't
> know if any relevant rules about accessibility have changed in Ada
> 2012. I'd have to study this one further. If you're not using our
> compiler or GNAT, and it's an Ada 2005 compiler, it could well be an
> error in your compiler.
>
> -- Adam
Yes, it is directly within High_Cloud.
I am using GNATMAKE 4.4.0 20080314 on Mac OS X 10.5.8, Xcode 3.0.
--
Adrian Hoe
http://adrianhoe.com/adrianhoe
next prev parent reply other threads:[~2011-06-14 1:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-13 15:31 Type in allocator has deeper level than designated class-wide type Adrian Hoe
2011-06-13 17:11 ` Adam Beneschan
2011-06-14 0:49 ` Adrian Hoe
2011-06-14 1:08 ` Adam Beneschan
2011-06-14 1:11 ` Adrian Hoe [this message]
2011-06-14 1:07 ` Adrian Hoe
2011-06-14 1:24 ` Adam Beneschan
2011-06-14 6:04 ` Adrian Hoe
2011-06-14 8:01 ` Adrian Hoe
2011-06-14 16:01 ` Adam Beneschan
2011-06-15 2:04 ` Adrian Hoe
2011-06-15 15:44 ` Adam Beneschan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox