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 X-Google-Thread: 103376,c4a14ea3a6faca74,start X-Google-Attributes: gid103376,public From: lutz@iks-jena.de (Lutz Donnerhacke) Subject: Generic abstracts Date: 1999/11/25 Message-ID: #1/1 X-Deja-AN: 552877294 Distribution: world Content-Transfer-Encoding: 8bit Organization: IKS GmbH Jena Content-Type: text/plain; charset=iso-8859-1 User-Agent: slrn/0.9.5.7 (UNIX) Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-25T00:00:00+00:00 List-Id: Somebody might remember a unspecific quotation from the reference manual about prohibiting abstract declarations in generic packages. In my current developemnt I came across this problem again. generic type S (<>) is abstract tagged limited private; package X is type T is abstract new S with private; type T_Class is access all T'Class; type Bla is limited private; type Position is private; procedure Set (B : in out Bla; E : in T_Class); function Get (B : in Bla) return T_Class; generic with procedure On_Item (E : in out S); procedure Iterate (B : in Bla); generic with function Is_Match (E : in S) return Boolean; function Find (B : in Bla) return Position; end X; I will guarantee this interface (Set/Get) over several implementations. The na�ve approach fails: generic type S (<>) is abstract tagged limited private; package X is type T is abstract new S null record; type T_Class is access all T'Class; type Bla is abstract tagged limited null record; procedure Set (B : in out Bla; E : in T_Class) is abstract; function Get (B : in Bla) return T_Class is abstract; generic with procedure On_Item (E : in out S); procedure Iterate (B : in Bla) is abstract; -- ^ missing ';'. -- Providing a sensless dummy function works. generic with function Is_Match (E : in S) return Boolean; function Find (B : in Bla) return Position is abstract; -- ^ missing ';'. -- Providing a dummy function is not possible, because no return value exists. end X; The abstract definition should be used to ensure a consistent inteface. 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. Any hints?