From: Andrea Coccoli <A.M.Coccoli@ncl.ac.uk>
Subject: Using Controlled type objects.
Date: 1996/08/01
Date: 1996-08-01T00:00:00+00:00 [thread overview]
Message-ID: <32008E75.6A3F@ncl.ac.uk> (raw)
Hi everybody,
I'm implementing a recoverable object in Ada95.
For the stack, I'm using the generic one provided by the Lovelace Tutor
GENSTACK.ADS
with Ada.Finalization; use Ada.Finalization;
generic
type Item is private;
package GenStack is
-- This implements a simple generic stack of Items.
-- (C) 1996 David A. Wheeler.
type Stack is new Controlled with private;
#
type Stack_Access is access all Stack'Class;
function ..
...
private
type Stack_Node;
type Stack_Node_Access is access Stack_Node;
type Stack is new Controlled with record
#
Start : Stack_Node_Access;
end record;
procedure Adjust(Object : in out Stack);
procedure Finalize(Object : in out Stack);
end Generic_Stack;
GENSTACK.ADB
package body GenStack is
type Stack_Node is record
Data : Item;
Next : Stack_Node_Access;
end record;
....
What I want to do is to create an object which could give me the chances
to save and to restore its state. My first idea was to have a generic
package, in order to achieve reusability. So I defined:
REUSABLE.ADS
with genstack;
generic
type item is private;
package reusable is
package lstack is new genstack(Item);
--use lstack;
type local is tagged limited private;
...
private
type local is tagged limited
record
state : Item;
stc : lstack.stack;
end record;
...
The problems arise when I want to declare an instantiation of this
package:
EXAMPLE.ADB
with reusable;
procedure example is
package myreusable is new reusable(character);
...
When I compile it, I receive this message:
genstack.ads:#: controlled type must be declared at the library level
(I've marked with # the point indicated by the compiler).
The question is: how can I keep on using the same structure and the
controlled type without such an error message?
Or, is there another solution?
I hope I didn't annoy you with silly questions,
Cheers,
Andrea
next reply other threads:[~1996-08-01 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-08-01 0:00 Andrea Coccoli [this message]
1996-08-01 0:00 ` Using Controlled type objects Pascal Ledru
1996-08-01 0:00 ` Andre Spiegel
1996-08-01 0:00 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox