comp.lang.ada
 help / color / mirror / Atom feed
From: sjw <simon.j.wright@mac.com>
Subject: Re: Dispatch on the result still does not work?
Date: Tue, 14 Jul 2009 14:06:42 -0700 (PDT)
Date: 2009-07-14T14:06:42-07:00	[thread overview]
Message-ID: <ec67f6e0-55b8-4dc2-8f2d-de69ee97ace4@h2g2000yqg.googlegroups.com> (raw)
In-Reply-To: ebd5326b-3eba-4d93-8cba-3d58a3211d1a@v15g2000prn.googlegroups.com

On Jul 13, 11:50 pm, Adam Beneschan <a...@irvine.com> wrote:
> On Jul 13, 2:47 pm, sjw <simon.j.wri...@mac.com> wrote:

> > OK, mea culpa. However .. if I say P.S'(whatever) and the compiler
> > tells me it's tag-indeterminate my first reaction is that it must be
> > confused!
>
> Yeah, I can understand why this could be confusing.  The qualifier
> P.S' doesn't say that the expression in parentheses will (dynamically)
> have type P.S; it says that the operand must resolve to be of the type
> P.S, which, I believe, implies that the expression's type will
> actually be P.S **except** when dispatching is involved.
>
> > If I hadn't been too taken with the symmetry I'd have realised that I
> > should have written
>
> > procedure Q is
> >    X : P.T'Class := P.T'(P.Value);
> > begin
> >    X := P.T'Class (P.S'(P.Value));
>
> > (which (I think) is the 'dynamically tagged' alternative in 5.2(6)
> > which wasn't mentioned by GNAT).
>
> I think this will work, but it will not dispatch.  It will always call
> the Value that returns S.  (Putting the dispatching operation inside a
> type conversion will kill any dispatching---see 3.9.2(17-19).)  And,
> in this case, it will result in a Constraint_Error at runtime since X
> is now constrained to values of type T.

Exception name: CONSTRAINT_ERROR
Message: dmitry.ada:26 tag check failed

I was entertained by this:

   X : P.T'Class := P.S'(P.Value);
begin
   X := P.T'(P.Value);

where P.T'(P.Value) dispatched to the S version (in other words the
actual (dynamic?) type of the target was controlling).



  reply	other threads:[~2009-07-14 21:06 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
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 [this message]
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