comp.lang.ada
 help / color / mirror / Atom feed
* Ada-trivial !
@ 1999-08-10  0:00 Duncan Woodward
  1999-08-10  0:00 ` Ted Dennison
  1999-08-14  0:00 ` Matthew Heaney
  0 siblings, 2 replies; 3+ messages in thread
From: Duncan Woodward @ 1999-08-10  0:00 UTC (permalink / raw)


hi;
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!

Any ideas please?

Duncan RD.







^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Ada-trivial !
  1999-08-10  0:00 Ada-trivial ! Duncan Woodward
@ 1999-08-10  0:00 ` Ted Dennison
  1999-08-14  0:00 ` Matthew Heaney
  1 sibling, 0 replies; 3+ messages in thread
From: Ted Dennison @ 1999-08-10  0:00 UTC (permalink / raw)


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

> type Container_Matrix is array(POSITIVE range <>,
>                                             POSITIVE range <>,
>                                             POSITIVE range <>) of
Boolean;
>
> procedure1 Set_Container_Size(x,y,z:Integer);

> PROBLEM: How do I create an instance of type Container_Matrix
> that is visible to all procedures in the package.

Off the top of my head, I see two possibilities:
  o  Make the global object an access type. Have Set_Container_Size
deallocte the old one (if its not null), and allocate a new one of the
correct size.
  o  Wrap your global container matrix in a variant record (with
defaults for the index lengths).

--
T.E.D.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Ada-trivial !
  1999-08-10  0:00 Ada-trivial ! Duncan Woodward
  1999-08-10  0:00 ` Ted Dennison
@ 1999-08-14  0:00 ` Matthew Heaney
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Heaney @ 1999-08-14  0:00 UTC (permalink / raw)


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.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-08-14  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-10  0:00 Ada-trivial ! Duncan Woodward
1999-08-10  0:00 ` Ted Dennison
1999-08-14  0:00 ` Matthew Heaney

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