From: lutz@iks-jena.de (Lutz Donnerhacke)
Subject: Generic abstracts
Date: 1999/11/25
Date: 1999-11-25T00:00:00+00:00 [thread overview]
Message-ID: <slrn83q37i.kn.lutz@taranis.iks-jena.de> (raw)
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?
next reply other threads:[~1999-11-25 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-25 0:00 Lutz Donnerhacke [this message]
1999-11-25 0:00 ` Generic abstracts Lutz Donnerhacke
1999-11-29 0:00 ` Tucker Taft
1999-11-29 0:00 ` Lutz Donnerhacke
1999-11-29 0:00 ` Tucker Taft
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