From: Georg Bauhaus <bauhaus@futureapps.de>
Subject: Re: generics in Ada 83
Date: Tue, 13 Sep 2005 21:23:22 +0200
Date: 2005-09-13T21:23:22+02:00 [thread overview]
Message-ID: <4327272a$0$27561$9b4e6d93@newsread4.arcor-online.net> (raw)
In-Reply-To: <1126628739.232995.12460@g47g2000cwa.googlegroups.com>
REH wrote:
> Georg Bauhaus wrote:
>
>>REH wrote:
>>
>>
>>>generic
>>> type X is private;
>>> with procedure Y(Z : in X);
>>>package Foo;
>>>
>>>I want to define a default for Y, but how can I without knowing X?
>>
>>Can you make generic stubs?
>
>
> Can you do that in '83? I tried but I kept getting compiler errors.
>
Something like this may work. Unless I misunderstand your problem, i.e..
The generic package Stubs.X_Operations provides default null procedures
for any private type X. You can use these operations as default
values when instantiating Foo.
generic
type X is private;
with procedure Y(Z : in X) is <>;
-- lots of others
package Foo is end Foo;
with Stubs;
with Foo;
package Op_Maker is
type Some_Type is record
data: Natural;
end record;
type Some_Other_Type is record
data: Character;
end record;
package Some_Operations is
new Stubs.X_Operations(X => Some_Type);
package Some_More_Operations is
new Stubs.X_Operations(X => Some_Other_Type);
use Some_Operations, Some_More_Operations;
package A_Foo is new Foo(Some_Type);
package Another_Foo is new Foo(Some_Other_Type);
end Op_Maker;
package Stubs is
generic
type X is private;
package X_Operations is
-- null procedures
procedure Y(Z: in X);
procedure Y2(U, V: in X);
end X_Operations;
end Stubs;
package body Stubs is
package body X_Operations is
procedure Y(Z: in X) is
begin null;
end Y;
procedure Y2(U, V: in X) is
begin null;
end Y2;
end X_Operations;
end Stubs;
next prev parent reply other threads:[~2005-09-13 19:23 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-13 13:26 generics in Ada 83 REH
2005-09-13 13:30 ` Georg Bauhaus
2005-09-13 16:25 ` REH
2005-09-13 19:23 ` Georg Bauhaus [this message]
2005-09-13 13:50 ` Martin Dowie
2005-09-13 16:30 ` REH
2005-09-13 16:41 ` Martin Dowie
2005-09-13 18:43 ` REH
2005-09-13 19:37 ` Ludovic Brenta
2005-09-13 19:53 ` REH
2005-09-13 16:56 ` Jeffrey Carter
2005-09-13 18:53 ` REH
2005-09-13 22:16 ` Jeffrey Carter
2005-09-13 22:44 ` REH
2005-09-14 8:14 ` Jean-Pierre Rosen
2005-09-14 12:40 ` REH
2005-09-14 13:15 ` Hyman Rosen
2005-09-14 14:08 ` Jean-Pierre Rosen
2005-09-14 15:23 ` Hyman Rosen
2005-09-14 15:41 ` Robert A Duff
2005-09-19 17:58 ` REH
2005-09-20 4:58 ` Hyman Rosen
2005-09-20 12:36 ` REH
2005-09-20 1:34 ` adaworks
2005-09-20 4:14 ` Jim Rogers
2005-09-21 22:58 ` Robert A Duff
2005-09-22 15:18 ` adaworks
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox