From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Dispatching and generics - language lawyer question
Date: 23 Jul 2002 11:42:42 -0400
Date: 2002-07-23T15:51:31+00:00 [thread overview]
Message-ID: <ud6te30y5.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: b4682ab7.0207221513.4eb610de@posting.google.com
adam@irvine.com (Adam Beneschan) writes:
> I have a couple questions about what's supposed to happen when a
> generic is instantiated with a class-wide type as an actual type. I'm
> hoping that someone who really understands the intricacies of the
> language will be kind enough to answer, and provide chapter and verse
> from the RM to explain the correct answer.
>
> (1) What is the correct output of the program below?
GNAT 3.15a1 says "TRUE". Not a definitive answer, but possibly helpful :).
> (2) What would be the correct output if "private" in line [A] is
> changed to "tagged private"?
GNAT 3.15a1 also says "TRUE" for this.
> I'm pretty sure the answer to (1) is FALSE, since the "=" on line
> [B] in the instance denotes the predefined "=" declared for T1 in
> the generic, and not the "=" "defined" for the class-wide type, by
> 8.3(13).
I think the controlling paragraph is 12.5.1 (21). I think the behavior
exhibited by GNAT 3.15a1 agrees with this. Note that both variations
of your formal type declaration are "formal private types"; the
presence of "tagged" does not matter here. There is different behavior
for a "formal derived type", which is indicated by the keyword "new".
There is a problem with "reemergence" of predefined operators for
generic formal types, but I don't have an example of when it occurs. I
didn't see a discussion of this in Cohen's "Ada as a Second Language",
either. Nor in the Rationale. But maybe I just didn't look hard
enough.
You might try reading the Rationale for generics; it has some good
stuff in it. It's online at www.adapower.com; click the "resources"
button (I hate html frames!).
--
-- Stephe
next prev parent reply other threads:[~2002-07-23 15:42 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-22 23:13 Dispatching and generics - language lawyer question Adam Beneschan
2002-07-23 15:42 ` Stephen Leake [this message]
2002-07-24 15:37 ` Stephen Leake
-- strict thread matches above, loose matches on Subject: below --
2002-07-24 5:33 Grein, Christoph
2002-07-24 22:55 ` Robert A Duff
2002-07-25 15:46 ` Ben Brosgol
2002-07-29 20:38 ` Robert A Duff
2002-07-31 22:52 ` Dmitry A.Kazakov
2002-07-31 20:18 ` Robert A Duff
2002-08-02 1:15 ` Dmitry A.Kazakov
2002-08-01 16:30 ` Hyman Rosen
2002-08-02 23:42 ` Dmitry A.Kazakov
2002-08-02 15:49 ` Hyman Rosen
2002-08-02 17:48 ` Stephen Leake
2002-08-10 3:03 ` Warren W. Gay VE3WWG
2002-08-05 11:15 ` Dmitry A. Kazakov
2002-08-12 12:44 ` Robert Dewar
2002-08-13 22:50 ` Randy Brukardt
2002-08-14 0:02 ` Robert A Duff
2002-07-25 0:40 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox