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, T_FILL_THIS_FORM_SHORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,894ba04cfcf20b16,start X-Google-Attributes: gid103376,public From: Andrea Coccoli Subject: Using Controlled type objects. Date: 1996/08/01 Message-ID: <32008E75.6A3F@ncl.ac.uk>#1/1 X-Deja-AN: 171401796 content-type: text/plain; charset=us-ascii organization: University of Newcastle upon Tyne mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m) Date: 1996-08-01T00:00:00+00:00 List-Id: 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