From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4bce46ddadaa9806,start X-Google-Attributes: gid103376,public From: Alexander Boucke Subject: What is wrong here? (Generic and controlled types) Date: 2000/04/03 Message-ID: <38E871E6.8D9EBE71@lufmech.rwth-aachen.de>#1/1 X-Deja-AN: 605992780 Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 954757607 9290 134.130.177.111 (3 Apr 2000 10:26:47 GMT) Organization: RWTH Aachen, Lehr- und Forschungsgebiet fuer Mechanik Mime-Version: 1.0 NNTP-Posting-Date: 3 Apr 2000 10:26:47 GMT Newsgroups: comp.lang.ada Date: 2000-04-03T10:26:47+00:00 List-Id: 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