comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de>
Subject: Re: Dispatch on the result still does not work?
Date: Sat, 11 Jul 2009 20:54:05 +0200
Date: 2009-07-11T20:54:07+02:00	[thread overview]
Message-ID: <4a58dfcf$0$30232$9b4e6d93@newsspool1.arcor-online.net> (raw)
In-Reply-To: <ubjkmle9n5pi.1ovhyam5f9lf5$.dlg@40tude.net>

Dmitry A. Kazakov wrote:
> Considering this one:

> I would expect it rather dispatching on the tag of X, i.e. selecting Value,
> which returns S.
> 

Another one, I don't like to call this a solution,
and the running program differs per compiler
used. But both compilers compile the units without errors:

package P is

   type T is tagged null record;

   function Value return T;
   function Dispatched(X, V: T) return T'Class;

   type S is new T with null record;

   function Value return S;
   function Dispatched(X, V: S) return T'Class;

end P;

with Ada.Text_IO;
package body P is

   function Dispatched(X, V: T) return T'Class is
   begin
      return V;
   end Dispatched;

   function Dispatched(X, V: S) return T'Class is
   begin
      return V;
   end Dispatched;

   function Value return T is
   begin
      Ada.Text_IO.Put_Line("Value returns a T");
      return T'(null record);
   end Value;

   function Value return S is
   begin
      Ada.Text_IO.Put_Line("Value returns an S");
      return S'(T with null record);
   end Value;

end P;


with P;
procedure Run_P is

   use P;

   X: T'Class := S'(Value);
begin
   X := Dispatched(X, Value);
end Run_P;



  parent reply	other threads:[~2009-07-11 18:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-11 10:04 Dispatch on the result still does not work? Dmitry A. Kazakov
2009-07-11 11:09 ` Chris Moore
2009-07-11 12:05   ` Dmitry A. Kazakov
2009-07-11 17:50     ` Chris Moore
2009-07-11 19:22       ` Dmitry A. Kazakov
2009-07-11 11:32 ` Hibou57 (Yannick Duchêne)
2009-07-11 12:20   ` Dmitry A. Kazakov
2009-07-11 13:36     ` Hibou57 (Yannick Duchêne)
2009-07-11 13:39       ` Hibou57 (Yannick Duchêne)
2009-07-11 15:19       ` Dmitry A. Kazakov
2009-07-11 18:08         ` Hibou57 (Yannick Duchêne)
2009-07-11 19:29           ` Dmitry A. Kazakov
2009-07-11 23:22             ` Hibou57 (Yannick Duchêne)
2009-07-12  9:46               ` Dmitry A. Kazakov
2009-07-11 18:54 ` Georg Bauhaus [this message]
2009-07-11 19:40   ` Dmitry A. Kazakov
2009-07-12 10:40     ` Chris Moore
2009-07-12 11:30       ` Dmitry A. Kazakov
2009-07-12 16:05         ` Chris Moore
2009-07-12 16:38           ` Dmitry A. Kazakov
2009-07-12 17:11             ` AdaMagica
2009-07-12 20:30               ` sjw
2009-07-13 16:55                 ` Adam Beneschan
2009-07-13 21:47                   ` sjw
2009-07-13 22:50                     ` Adam Beneschan
2009-07-14 21:06                       ` sjw
2009-07-13 15:13 ` Adam Beneschan
2009-07-13 15:17   ` Adam Beneschan
2009-07-13 16:33     ` AdaMagica
2009-07-13 18:46   ` Adam Beneschan
replies disabled

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