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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2914089b822a81,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-13 13:41:12 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsxfer.eecs.umich.edu!uwm.edu!htc.honeywell.com!not-for-mail From: Steve Vestal Newsgroups: comp.lang.ada Subject: How do I inherit generic subprograms defined for a parent type? Date: 13 Aug 2001 15:35:44 -0500 Organization: Honeywell Technology Center, Mpls. MN, USA. Sender: vestal@grinch.htc.honeywell.com Message-ID: NNTP-Posting-Host: grinch.htc.honeywell.com X-Newsreader: Gnus v5.4.37/XEmacs 19.16 Xref: archiver1.google.com comp.lang.ada:11870 Date: 2001-08-13T15:35:44-05:00 List-Id: I have a type, and some subprograms that operate on objects of that type, declared in a package specification. I would like to declare another type as a derivation of that (parent) type. "Primitive subprograms" are inherited by a derived type from a parent type, but I can't figure out how to get generic subprograms defined for a parent type to be inherited as well. I would be most appreciative of any suggestions. Here is an example that illustrates my conundrum, with notes on the complaints raised by gnat 3.13p (look at the comments in Main2). Steve ------------------------- package Expression is type access_expression is private; -- This will be used as a parent type. generic -- How do I get this inherited by a derived type? with procedure Data_Operation (D, I: in out integer); procedure Generic_Data_Operation (Exp: in access_expression; Op: in out integer); private type expression is record Datum: integer; end record; type access_expression is access expression; end Expression; package body Expression is procedure Generic_Data_Operation (Exp: in access_expression; Op: in out integer) is begin Data_Operation (Exp.datum, Op); end Generic_Data_Operation; end Expression; with Expression; procedure Main2 is type access_my_expression is new Expression.access_expression; procedure Inc (D, I: in out integer) is begin D := D + I; end Inc; -- Alternative 1, Generic_Data_Operation is not visible. Why isn't -- this inherited, it is a subprogram with a parameter of type -- access_expression declared in the same package specification? procedure Increment is new Generic_Data_Operation (integer, Inc); -- Alternative 2 expects Expression.access_expression, not access_my_expression. --procedure Increment is new Expression.Generic_Data_Operation (integer, Inc); -- I can't declare access_my_expression as a subtype of -- Expression.access_expression; in the actual program, it is itself -- declared as a private type earlier in a package specification. Exp: access_my_expression; begin Increment (Exp, 1); end Main2;