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,3423d40a9e59c457,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-08-15 20:36:45 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: adam@irvine.com (Adam Beneschan) Newsgroups: comp.lang.ada Subject: Is this legal? (Language lawyer question) Date: 15 Aug 2003 20:36:44 -0700 Organization: http://groups.google.com/ Message-ID: NNTP-Posting-Host: 66.126.103.122 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1061005005 11143 127.0.0.1 (16 Aug 2003 03:36:45 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 16 Aug 2003 03:36:45 GMT Xref: archiver1.google.com comp.lang.ada:41551 Date: 2003-08-16T03:36:45+00:00 List-Id: I've run into some Ada code that is publicly available on the Internet that doesn't look legal to me. The rules involved are kind of complex, so I'd like to make sure I haven't missed something. The code declares a generic that starts out like this: generic type Item (<>) is abstract tagged private; with function "=" (L, R : Item'Class) return Boolean is <>; type Item_Ptr is access all Item'Class; [etc.] package Pkg is ... In the body, there's a construct that looks like this: package body Pkg is ... procedure Proc (Elem : Item'Class) is ... begin ... if ZZZ.all = Elem then ... -- Ambiguous? where the type of ZZZ is Item_Ptr. I can't see how this wouldn't be ambiguous. Although ZZZ.all and Elem both have type Item'Class, it appears to me that there are two "=" functions visible at that point: function "=" (L, R : Item) return Boolean; function "=" (L, R : Item'Class) return Boolean; where the first one is the predefined operator of the generic formal type Item (see RM95 12.5(8)), and the second one is the generic formal function declared above. Applying 8.6(22-23), the expected type for the parameters in the first function is Item, and that means that it's acceptable for the actual parameter to resolve either to Item or Item'Class. The consequence is that both of the above functions are acceptable interpretations for the construct, and thus the construct should be ambiguous. So what have I missed? -- thanks, Adam