comp.lang.ada
 help / color / mirror / Atom feed
* pointers and genericity
@ 2005-02-15 12:10 Xavier Serrand
  2005-02-15 13:12 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 8+ messages in thread
From: Xavier Serrand @ 2005-02-15 12:10 UTC (permalink / raw)


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;
   end;
End Pk_User;



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-02-17 23:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-15 12:10 pointers and genericity Xavier Serrand
2005-02-15 13:12 ` Dmitry A. Kazakov
2005-02-16  9:27   ` Xavier Serrand
2005-02-16  9:35     ` Martin Dowie
2005-02-16  9:53     ` Egil H. H�vik
2005-02-16 15:00     ` Robert A Duff
2005-02-17 22:50       ` Xavier Serrand
2005-02-17 23:11       ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox