comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: Ada-trivial !
Date: 1999/08/14
Date: 1999-08-14T00:00:00+00:00	[thread overview]
Message-ID: <37b5a083@news1.us.ibm.net> (raw)
In-Reply-To: 934306032.27513.0.nnrp-10.c2de38ef@news.demon.co.uk

In article <934306032.27513.0.nnrp-10.c2de38ef@news.demon.co.uk> , "Duncan
Woodward" <drdw@synthsoft.demon.co.uk> wrote:

> I want to create a package that handles actions upon
> a multi dimensional unconstrained array.


>
> It is likely that I've approached this problem from the
> wrong direction, but this is where I'm at..
>
> package array_Handler is
>
> type Container_Matrix is array(POSITIVE range <>,
>                                             POSITIVE range <>,
>                                             POSITIVE range <>) of Boolean;
>
> procedure1 Set_Container_Size(x,y,z:Integer);
>
>                 -- this procedure takes in the three axis values for
>                 -- the array index ranges.
>                 -- Creates instance of Container_Matrix using parameters
>                 -- x,y,z.
>
> procedure2 ...etc
> procedure3 ...etc
>
> end array_Handler;
>
> PROBLEM: How do I create an instance of type Container_Matrix
> that is visible to all procedures in the package.
>
> A single global declaration would be fine if the array sizes were know
> in advance!

You could pass in the array bounds as generic formal constants:

generic
  X, Y, Z : in Positive;
package Array_Handler_G is

  subtype X_Range is Positive range 1 .. X;

  subtype Y_Range is Positive range 1 .. Y;

  subtype Z_Range is Positive range 1 .. Z;

  type Container_Matrix
     (X_Range, Y_Range, Z_Range) of Boolean;  --(I haven't compiled this)

  ...
end Array_Handler_G;


Do you want to create only one instance of the matrix in the package body?
Or many, all of the same dimensions?  Or many, with different dimensions.
Your problem statement wasn't clear to me about that.





      parent reply	other threads:[~1999-08-14  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-10  0:00 Ada-trivial ! Duncan Woodward
1999-08-10  0:00 ` Ted Dennison
1999-08-14  0:00 ` Matthew Heaney [this message]
replies disabled

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