From: Tucker Taft <stt@averstar.com>
Subject: Re: Generic abstracts
Date: 1999/11/29
Date: 1999-11-29T00:00:00+00:00 [thread overview]
Message-ID: <3842E945.AFBCCE17@averstar.com> (raw)
In-Reply-To: slrn845ifq.18l.lutz@taranis.iks-jena.de
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
next prev parent reply other threads:[~1999-11-29 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-25 0:00 Generic abstracts Lutz Donnerhacke
1999-11-25 0:00 ` Lutz Donnerhacke
1999-11-29 0:00 ` Tucker Taft
1999-11-29 0:00 ` Lutz Donnerhacke
1999-11-29 0:00 ` Tucker Taft [this message]
1999-11-30 0:00 ` Robert A Duff
1999-11-30 0:00 ` Tucker Taft
1999-11-30 0:00 ` Lutz Donnerhacke
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox