comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@acm.org>
Subject: Re: Q: Hiding the structure of a tagged type using containers
Date: Tue, 09 May 2006 02:43:41 -0400
Date: 2006-05-09T02:43:41-04:00	[thread overview]
Message-ID: <uzmhrr942.fsf@acm.org> (raw)
In-Reply-To: 1147139575.425825.290860@u72g2000cwu.googlegroups.com

brian.b.mcguinness@lmco.com writes:

> I am trying to create a tree of object classes to represent arrays.
> I want to hide the internal representation of the arrays in the
> private sections of the packages for the tagged types. However, I am
> having trouble figuring out how to do this. For example, I have an
> abstract base class called APL_Array, and I am trying to create a
> child class called APL_Array_Dimensioned that contains a list of
> dimensions (which may change over time, say if someone concatenates
> a row or column to a matrix).

I used to use APL! fun language :).

> <snip code> 
>
> but when I try to compile it, I get:
>
> # gnatmake -gnat05 apl-arrays-dimensioned.adb
> gcc -c -gnat05 apl-arrays-dimensioned.adb
> apl-arrays-dimensioned.ads:21:13: operation can be dispatching in only
> one type

The general solution to this error is to make one of the arguments
class-wide; in this case:

procedure Shape
   (A : in APL_Array_Dimensioned; Dimensions : out APL_Shape'class);

or

procedure Shape
   (A : in APL_Array_Dimensioned'class; Dimensions : out APL_Shape);

If children of APL_Array_Dimensioned don't need to override Shape, the
second declaration is more appropriate.

Another solution is to use only one tagged type. Apparently
APL_Dimension_List.Vector is visibly tagged; perhaps it does not need
to be?

-- 
-- Stephe



  reply	other threads:[~2006-05-09  6:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-09  1:52 Q: Hiding the structure of a tagged type using containers brian.b.mcguinness
2006-05-09  6:43 ` Stephen Leake [this message]
2006-05-09 14:52   ` Matthew Heaney
2006-05-10 11:50     ` Craig Carey
2006-05-09 14:47 ` Matthew Heaney
2006-05-09 14:55   ` brian.b.mcguinness
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox