From: Alexander Boucke <alexb@lufmech.rwth-aachen.de>
Subject: What is wrong here? (Generic and controlled types)
Date: 2000/04/03
Date: 2000-04-03T10:26:47+00:00 [thread overview]
Message-ID: <38E871E6.8D9EBE71@lufmech.rwth-aachen.de> (raw)
Hello!
I am writing a vector-package using controlled types.
I implemented some sort of reference-counting to access
the arrays. This is why I used the controlled types and
do not access the arrays directly. A non-generic version
of the packge is running fine and giving good
improvements in speed and memory-usage against the
"trivial" implementation.
While converting the package to be generic I encounter
an error while compiling my test-program. I must admit,
that my routine using Ada is not very big yet, so I
did not find the cause for the error. Here comes a bit
of code and the error gnat3.12p reports on my HP-UX 10.20:
-----
with Ada.Finalization;
with Unchecked_Deallocation;
generic
type Real is private;
type Index is (<>);
Zero : in Real;
package Generic_Vectors is
type Vector is new Ada.Finalization.Controlled with private;
private
Variable_Counter : Natural := 0;
Object_Counter : Natural := 0;
type Value_Vector is array (Index range <>) of Real;
type Handled_Vector(First,Last: Index) is
record
Value : Value_Vector(First..Last);
Count : Natural := 1;
Object_No : Natural;
end record;
type Handled_Vector_Access is access Handled_Vector;
type Vector is new Ada.Finalization.Controlled with
record
Variable_Id : Natural := 0;
The_Vector : Handled_Vector_Access := null;
end record;
end Generic_Vectors;
---
In the test-program:
type Real is digits 10;
subtype Index is Integer;
Zero: constant Real := 0.0;
package Real_Vectors is new Generic_Vectors(Real, Index, Zero);
Of course there are more things around these lines...
gnat reports while compiling:
29. package Real_Vectors is new Generic_Vectors(Real, Index, Zero);
|
>>> instantiation error at generic_vectors.ads:23
>>> controlled type must be declared at the library level
>>> instantiation error at generic_vectors.ads:75
>>> controlled type must be declared at the library level
Lines 23 and 75 are the lines defining the type Vector.
It would be nice if anybody could point where to find the
solution for doing it right.
Kind regards,
Alexander Boucke
--
"I try to write idiot proof code, but they keep making better idiots."
A. Stanley in comp.sys.sgi.admin
next reply other threads:[~2000-04-03 0:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-04-03 0:00 Alexander Boucke [this message]
2000-04-03 0:00 ` What is wrong here? (Generic and controlled types) Ted Dennison
2000-04-03 0:00 ` Ehud Lamm
2000-04-03 0:00 ` Robert Dewar
2000-04-03 0:00 ` Ted Dennison
2000-04-03 0:00 ` swhalen
2000-04-06 0:00 ` Robert Dewar
2000-04-03 0:00 ` Florian Weimer
2000-04-03 0:00 ` tmoran
2000-04-04 0:00 ` Alexander Boucke
2000-04-06 0:00 ` Robert Dewar
2000-04-21 0:00 ` Florian Weimer
2000-04-04 0:00 ` Robert A Duff
2000-04-06 0:00 ` Robert Dewar
2000-04-06 0:00 ` Mats Weber
2000-04-06 0:00 ` Robert Dewar
2000-04-06 0:00 ` Robert A Duff
2000-04-06 0:00 ` Robert Dewar
2000-04-21 0:00 ` Vincent Marciante
2000-04-21 0:00 ` Robert Dewar
2000-04-21 0:00 ` Robert Dewar
2000-04-22 0:00 ` Vincent Marciante
2000-04-22 0:00 ` Robert Dewar
2000-04-04 0:00 ` Alexander Boucke
2000-04-06 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox