From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,294c152109d75b4d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-23 08:52:16 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Dispatching and generics - language lawyer question Date: 23 Jul 2002 11:42:42 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1027439491 27361 128.183.220.71 (23 Jul 2002 15:51:31 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 23 Jul 2002 15:51:31 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:27337 Date: 2002-07-23T15:51:31+00:00 List-Id: 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