From: okellogg@my-dejanews.com
Subject: Usefulness of classwide "out" parameter
Date: 1999/03/15
Date: 1999-03-15T00:00:00+00:00 [thread overview]
Message-ID: <7cikku$d4k$1@nnrp1.dejanews.com> (raw)
Hi,
Has anyone ever used a classwide subprogram parameter with
mode "out" ?
For example,
type Mytype is tagged null record;
procedure Proc (Result : out Mytype'Class);
The problem I have with this is, I cannot assign another variable
to the out parameter (that would change the tag, which is not
possible.)
Am I correct in asserting that classwide parameters of mode "out"
are not terribly useful? What would a practical application of this
look like?
I am appending an example that shows the problem.
Thanks,
O. Kellogg
e-mail: oliver.kellogg@vs.dasa.de
-- base.ads
package Base is
type Mytype is tagged null record;
procedure Proc (Result : out Mytype'Class);
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 : Base.Derived1.Deriv1;
V2 : Base.Derived2.Deriv2;
Some_Flag : Boolean := False;
procedure Proc (Result : out Mytype'Class) is
begin
if Some_Flag then
Result := V1; -- GNAT says:
else
Result := V2; -- dynamically tagged expression required
end if;
end Proc;
end Base;
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
next 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 okellogg [this message]
1999-03-15 0:00 ` Usefulness of classwide "out" parameter Joachim Schroeer
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