comp.lang.ada
 help / color / mirror / Atom feed
* Usefulness of classwide "out" parameter
@ 1999-03-15  0:00 okellogg
  1999-03-15  0:00 ` Matthew Heaney
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: okellogg @ 1999-03-15  0:00 UTC (permalink / 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    




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-03-17  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-15  0:00 Usefulness of classwide "out" parameter okellogg
1999-03-15  0:00 ` Matthew Heaney
1999-03-15  0:00 ` Joachim Schroeer
1999-03-17  0:00 ` Nick Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox