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,c4a14ea3a6faca74 X-Google-Attributes: gid103376,public From: Tucker Taft Subject: Re: Generic abstracts Date: 1999/11/29 Message-ID: <3842E945.AFBCCE17@averstar.com>#1/1 X-Deja-AN: 554565377 Content-Transfer-Encoding: 7bit Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.burl.averstar.com References: <3842BFFB.70B08603@averstar.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: AverStar (formerly Intermetrics) Burlington, MA USA Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-29T00:00:00+00:00 List-Id: Lutz Donnerhacke wrote: > > * Tucker Taft wrote: > >Lutz Donnerhacke wrote: > >> The abstract definition should be used to ensure a consistent > >> interface. I have two problems: > >> - A generic procedure which can be missed on implementation. > >> Raising an exception might be acceptable. > >> - It is not possible to predefine a body for a generic function. > >> No return value is available. > >> Raising an exception does not stop the compiler from requiring > >> a return value. > > > >I'm unclear as to what you are trying to accomplish by including > >generic subprograms that are abstract. Generic subprograms are > >not inherited, so there is no point in declaring them on an > >abstract type. > > with Abstract_Lists; > > generic > type Item (<>) is abstract tagged limited private; > package Concrete_Lists is > package Abstract_Template is > new Abstract_Lists (Item => Item); > > type List is new Abstract_Template.List with private; > type List_Item is new Abstract_Template.List_Item with private; > type List_Iterator is new Abstract_Template.List_Iterator with private; > > -- now the compiler requires to implement all abstract functions > -- including the generic Iterate and Delete procedures So you would like a derived type to inherit the generic subprogrmas of its parent type, and if they are abstract, be required to implement them? This seems like a reasonable request, but Ada has never supported inheritance of anything but subprograms and enumerals. One could imagine inheriting other things I suppose, such as exceptions, generics, subpackages, etc. However, at the moment only "overloadable" things (i.e. subprograms and enumerals) are inheritable, and that has some nice properties. Be that as it may, I now understand what you were trying to do and can safely answer that it is not supported by the Ada inheritance model. > > function Is_Empty (L : List) return Boolean; > > generic > with procedure On_Item (E : in out Item); > procedure For_Each (L : in List); > > ... > end Concrete_Lists; > > An solution without (abtract) interfaces can be obtained from > ftp.iks-jena.de:/pub/mitarb/lutz/ada/types/ -- -Tucker Taft stt@averstar.com http://www.averstar.com/~stt/ Technical Director, Distributed IT Solutions (www.averstar.com/tools) AverStar (formerly Intermetrics, Inc.) Burlington, MA USA