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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6ea9f886a228469c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: pointers and genericity Date: Tue, 15 Feb 2005 14:12:21 +0100 Organization: cbb software GmbH Message-ID: <17cfosskqxdi0$.1ux9v3kndb9kr$.dlg@40tude.net> References: <344d0fee.0502150410.740d5dbd@posting.google.com> Reply-To: mailbox@dmitry-kazakov.de Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: individual.net PtBtBXOGj+iscEk4sn2oaQiBbu7LhvrG8sZU4q1lOy4socLwE= User-Agent: 40tude_Dialog/2.0.14.1 Xref: g2news1.google.com comp.lang.ada:8332 Date: 2005-02-15T14:12:21+01:00 List-Id: On 15 Feb 2005 04:10:38 -0800, Xavier Serrand wrote: > Hello cruel word, > > I would like to use pointers to procedures in a generic package ... ok > no problem > But i want another generic package to use this... and i can't because > the pointer type must be in the body of a generic package... > > I KNOW that I can use genericity to bypass the problem... but is it > possible to change the value of the generic parameters after the > instanciation (as I can do with pointers variables)? > > generic > type T_Elem is private > Null_Elem : in T_Elem; > package Pk_DataSource is > type T_proc_Browse is access procedure (E : in out T_Record; S : > out string); > type T_Record is > Data : T_Elem; > Next : T_Proc_Browse; > Prev : T_Proc_Browse; > end record; > end Pk_DataSource; > > generic > type T_Element is private > Null_Element : in T_Element; > with package Pk_DS is new Pk_DataSource (T_Elem => T_Element, > Null_Elem => Null_Element); > package Pk_User is > type T_User is > Nom : string (1..33) := (others => ' '); > Rec : Pk_DS.T_Record := (Data => Null_Element, Next, Prev => > null); > end record; > procedure Assign (U : in out T_User; > S : in string; E : in T_Element; > Proc_Next, Proc_Prev : in Pk_DS.T_Proc_Browse); > end Pk_User; > > --========================================= > -- All is ok !! > -- But i can't make this in Pk_User's body : > --========================================= > > package Pk_User body is > > procedure Assign (U : in out T_User; > S : in string; E : in T_Element; > Proc_Next, Proc_Prev : in Pk_DS.T_Proc_Browse) is > begin > U.Nom(1..Min(U.Nom'Last, S'Last)) := S(1..Min(U.Nom'Last, > S'Last)); > U.Rec.Data := E; > -- and now some trouble !! > U.Rec.Next := Proc_Next; > U.Rec.Prev := Proc_Prev; So far it is legal, (ignoring some minor errors with missing "record" after "is", misplaced "body" and necessary forward declaration of "T_Record". > end; > End Pk_User; It is not clear what you want to achieve. Should Assign work with T_Record from all possible instances of Pk_DataSource? If so, then you have to switch to tagged types. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de