From: "Joachim Schroeer" <schroeer@amst.co.at>
Subject: Re: Usefulness of classwide "out" parameter
Date: 1999/03/15
Date: 1999-03-15T12:35:53+00:00 [thread overview]
Message-ID: <7ciur9$p89$1@fleetstreet.Austria.EU.net> (raw)
In-Reply-To: 7cikku$d4k$1@nnrp1.dejanews.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1341 bytes --]
okellogg@my-dejanews.com schrieb in Nachricht
<7cikku$d4k$1@nnrp1.dejanews.com>...
Your logic may be implemented by a function (func below) returning a
classwide type or by using a classwide access type for the out
parameter of procedure proc. Then the 2 objects in base.adb have to
be aliased.
The attached modified code compiles with ObjectAda and GNAT.
J. Schr�er
-- base.ads
package Base is
type Mytype is tagged null record;
function Func return Mytype'Class;
type Mytype_Access is access all Mytype'Class;
procedure Proc (Result : out Mytype_Access);
end Base;
-- base-derived1.ads
package Base.Derived1 is
type Deriv1 is new Mytype with null record;
end Base.Derived1;
-- base-derived2.ads
package Base.Derived2 is
type Deriv2 is new Mytype with null record;
end Base.Derived2;
-- base.adb
with Base.Derived1, Base.Derived2;
package body Base is
V1 : aliased Base.Derived1.Deriv1;
V2 : aliased Base.Derived2.Deriv2;
Some_Flag : Boolean := False;
function Func return Mytype'Class is
begin
if Some_Flag then
return V1;
else
return V2;
end if;
end Func;
procedure Proc (Result : out Mytype_Access) is
begin
if Some_Flag then
Result := V1'access;
else
Result := V2'access;
end if;
end Proc;
end Base;
next prev parent reply other threads:[~1999-03-15 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-15 0:00 Usefulness of classwide "out" parameter okellogg
1999-03-15 0:00 ` Joachim Schroeer [this message]
1999-03-15 0:00 ` Matthew Heaney
1999-03-17 0:00 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox