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,1038b3dc09d106c2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-09 17:50:46 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!netnews.com!newsfeed.nyc.globix.net!newsfeed.sjc.globix.net!cyclone-sf.pbi.net!206.13.28.33!news.pacbell.net.POSTED!not-for-mail From: "Ed Colbert" Newsgroups: comp.lang.ada References: <3B9547D9.BE2CC282@avercom.net> Subject: Re: Dispatching Example Organization: Absolute Software Co., Inc. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Sun, 9 Sep 2001 17:50:44 -0700 NNTP-Posting-Host: 63.193.36.170 X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 1000083045 63.193.36.170 (Sun, 09 Sep 2001 17:50:45 PDT) NNTP-Posting-Date: Sun, 09 Sep 2001 17:50:45 PDT Xref: archiver1.google.com comp.lang.ada:12962 Date: 2001-09-09T17:50:44-07:00 List-Id: Hi Tucker, "Tucker Taft" wrote in message news:3B9547D9.BE2CC282@avercom.net... > Ed Colbert wrote: > > > > Hi All, > > > > Below is a simplified example from Richard Riehle's & my course on Ada. > > GNAT v3.13p says that the call Is_Item is an mbiguous expression, and > > ObjectAda v 7.2 says the statement is illegal based on LRM 5.2(6). Both > > Richard and I thought that the expression is tag indeterminate, LRM > > 3.9.2(6), and would static resolved, LRM 3.9.2(19). Are Richard and I > > missing something or are both compilers wrong? > > The call on Is_Item is ambiguous, even though one of the > possible interpretations (the one returning type T1) violates > 5.2(6). This is one of those cases where the overload > resolution rules are less picky than the legality rules, > which can be a bit confusing. > > ObjectAda is not being very helpful by telling you that one > of the interpretations is illegal, without first telling > you that the expression is considered ambiguous by the > overloading rules. > Why is the expression ambiguous? Isn't the tag of C, which in this case is compile time determinable, used to resolve the call to Is_Item per 5.2(9)? I suppose it could be ambiguous if the expression is evaluated first as allowed by 5.2(7); but then when would 5.2(8-10) apply? > In any case, if only the Is_Item that returned type T1 were > directly visible, the expression would not be ambiguous, and > the call would be legal. It would involve a "dispatching > on result" where the tag of "C" would determine which body > of Is_Item were called. > > In general the overload resolution and legality rules relating > to classwide assignment are confusing at best. We tried other > rules, but they had worse problems, so I suppose the current > rules are the best of a set of unpleasant alternatives. > ObjectAda's error message was unfortunately only adding to > the confusion. > Clearly, there's something that's confusing Richard & I. > > > > package Dispatching_Examples > > is > > type T1 is tagged private; > > function Is_Item return T1; > > > > type T2 is new T1 with private; > > function Is_Item return T2; > > > > private > > -- full definition of T1 and T2 > > type T1 is tagged null record; > > type T2 is new T1 with null record; > > end Dispatching_Examples; > > > > with Dispatching_Examples; > > use Dispatching_Examples; > > procedure Dispatching_Examples_Driver is > > A, B : T1; -- simple variables > > Q, R : T2; -- simple variables > > C : T1'Class := A; -- class-wide variable > > D : T2'Class := R ; -- class-wide variable > > begin > > C := Is_Item ; -- static resolution? > > end Dispatching_Examples_Driver; > > -- > -Tucker Taft stt@avercom.net http://www.avercom.net > Chief Technology Officer, AverCom Corporation (A Titan Company) > Bedford, MA USA (AverCom was formerly the Commercial Division of AverStar: > http://www.averstar.com/~stt) >