comp.lang.ada
 help / color / mirror / Atom feed
From: "Hibou57 (Yannick Duchêne)" <yannick_duchene@yahoo.fr>
Subject: Re: Dispatch on the result still does not work?
Date: Sat, 11 Jul 2009 04:32:49 -0700 (PDT)
Date: 2009-07-11T04:32:49-07:00	[thread overview]
Message-ID: <3a2a94a3-91df-411e-b078-498cc7850554@18g2000yqa.googlegroups.com> (raw)
In-Reply-To: ubjkmle9n5pi.1ovhyam5f9lf5$.dlg@40tude.net

On 11 juil, 12:04, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> use P;
>
>    X : T'Class := S'(Value);
> begin
>    X := Value; -- Ambiguous?
>
> I would expect it rather dispatching on the tag of X, i.e. selecting Value,
> which returns S.
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de

Using this main program:

> with P;
> procedure Q is
>    X : P.T'Class := P.S'(P.Value);
> begin
>    X := P.Value;
> end;

I indeed got an ambiguity error. What was predictable.

There is no tagged argument here which controls the dispatching.

This is not like some other language which assume an implicite
argument.

Doing this:

> with P;
> procedure Q is
>    X : P.T'Class := P.S'(P.Value);
> begin
>    X := P.T'(P.Value);
> end;

works fine.

But doing so:
> with P;
> procedure Q is
>    X : P.T'Class := P.S'(P.Value);
> begin
>    X := P.S'(P.Value);
> end;

is rejected, whith a reference to RM 5.2(6), which states:
> RM 5.2 6
> If the target is of a tagged class-wide type T'Class,
> then the expression shall either be dynamically tagged,
> or of type T and tag-indeterminate (see 3.9.2).

In your example, Value is tag-indeterminate, as there is not tagged
argument to control the dispatching (back to the first assertion about
the fact).

Hint: the ARM excerpt makes a reference to 3.9.2, which is titled “
Dispatching Operations of Tagged Types
 ” and seems indeed worth reading in this purpose.

My personal opinion is that there is no trouble here, as there is no
tagged type to control the execution. While in the mean time, I
understand what you mean : you are consedering the return value target
as the out parameter of a procedure. But this is not an out parameter
of a procedure, this is a result returned by a function.




  parent reply	other threads:[~2009-07-11 11:32 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) [this message]
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
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