From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: Help needed: Access type to functions in generic package
Date: 1999/09/12
Date: 1999-09-12T00:00:00+00:00 [thread overview]
Message-ID: <37dbe7da@news1.prserv.net> (raw)
In-Reply-To: 37DBA86F.3805AA69@deathsdoor.com
In article <37DBA86F.3805AA69@deathsdoor.com> , Zeiram
<zeiram@deathsdoor.com> wrote:
> generic
> Dim_X, Dim_Y, Dim_Z : Positive;
> package Maze is
> type T_Cell is (Wall, Corridor, Pebble);
> type T_Maze is array(1..Dim_X, 1..Dim_Y, 1..Dim_Z) of T_Cell;
> end Maze;
Why is this package generic? Why don't you declare your array type this
way:
package Maze is
type T_Cell is (Well, Corridor, Pebble);
type T_Maze is
array (Positive range <>, Positive range <>, Positive range <>)
of T_Cell;
end Maze;
Instead of instantiating a generic to get a constrained array subtype, you
can just declare an array object, or declare an array subtype. No generic
is needed.
Maze : T_Maze (1 .. 10, 2 .. 11, 3 .. 12);
or
subtype My_Maze is T_Maze (1 .. 10, 2 .. 11, 3 .. 12);
Maze : My_Maze;
> generic
> package Maze.Display is
> procedure Display_Maze(Maze : in T_Maze);
> end Maze.Display;
I package Maze is non-generic, then this child package doesn't need to be
generic either:
package Maze.Display is
procedure Display_Maze (Maze : in T_Maze);
-- (sub)type T_Maze is now an unconstrained array
end;
> with glut;
> with Win32.GL;
> with Maze.Display.Callback;
> package body Maze.Display is
> package Callback is new Maze.Display.Callback;
> use Callback;
Maze.Display.Callback doesn't need to be generic; see below.
> procedure Display_Maze(Maze : in T_Maze) is
> Menu : Integer;
> begin
> Menu := glutCreateMenu(Main_Menu'access);
> end Display_Maze;
>
> end Maze.Display;
>
> package Maze.Display.Callback is
> procedure Main_Menu(Value : Integer);
> end Maze.Display.Callback;
Again, this doesn't need to be generic either:
package Maze.Display.Callback is
procedure Main_Menu (...);
end Maze.Display.Callback;
Try the changes I've suggested, and see if your problem goes away.
next prev parent reply other threads:[~1999-09-12 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-09-12 0:00 Help needed: Access type to functions in generic package Zeiram
1999-09-12 0:00 ` Matthew Heaney [this message]
1999-09-12 0:00 ` Zeiram
1999-09-12 0:00 ` Matthew Heaney
1999-09-13 0:00 ` zeiram
1999-09-13 0:00 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox