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-Thread: 103376,fc52c633190162e0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newshub.stanford.edu!newsfeed.berkeley.edu!ucberkeley!newspeer.monmouth.com!newspeer1.nwr.nac.net!border2.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mail NNTP-Posting-Date: Wed, 04 Apr 2007 03:37:05 -0500 From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Erasing inappropriate operations References: <1172144043.746296.44680@m58g2000cwm.googlegroups.com> <1172161751.573558.24140@h3g2000cwc.googlegroups.com> <546qkhF1tr7dtU1@mid.individual.net> <5ZULh.48$YL5.40@newssvr29.news.prodigy.net> <1175215906.645110.217810@e65g2000hsc.googlegroups.com> <1175230700.925143.28490@n59g2000hsh.googlegroups.com> <1btkgzzj6zimp.acsq8mkzqz1w$.dlg@40tude.net> <1175488143.324741.283480@y80g2000hsf.googlegroups.com> <1lxqyx4ognsed$.ait5qqwujfo8$.dlg@40tude.net> <1175501959.751535.23190@d57g2000hsg.googlegroups.com> <1175604129.583861.40720@q75g2000hsh.googlegroups.com> Date: Wed, 04 Apr 2007 10:34:34 +0200 Message-ID: <87vegcfsh1.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:k5pUWIDjI0TEAlMtQ8INy9zA8VQ= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 62.235.208.6 X-Trace: sv3-qTij5NkOEMM5opGseJPcR58tQuX+Tv/doyrERzlJvHgOPFJXnntOufpquYPK2YmTv0AKtWsoXCRDfs8!7edBDYGqnkdaBLFscK4NFLmwuulxVy+4pRawAvLjUC8cNJ6zUVOsacYfJQkELzf44r9d+10c X-Complaints-To: abuse@scarlet.be X-DMCA-Complaints-To: abuse@scarlet.biz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.34 Xref: g2news1.google.com comp.lang.ada:14782 Date: 2007-04-04T10:34:34+02:00 List-Id: Randy Brukardt writes: > In Ada 95, abstract operators of untagged types are considered in > resolution. So, you still might call them;then get an error message. That is > especially problematical if an appropriate operator is defined somewhere > else, because the expression might be ambiguous. (It's also a problem with > literals). > > The Amendment 1 changed that so that they do not participate in resolution. > Thus, they no longer clog up resolution. > > For instance, if you had: > > type F1 is digits 3; > type F2 is digits 3; > function "*" (Left : F1, Right : F2) return F2; > function "*" (Left, Right : F2) return F2 is abstract; -- Don't want > this operator. > > A : F1 := 1.0; > B : F2 := A * 1.0; -- (1) > > The expression (1) is ambiguous in Ada 95 (even though one of the possible > operators is illegal). But Amendment 1 makes it OK; you'll get the intended > operator without interference from the predefined ones you don't want. Even in Ada 95 mode, GNAT does not consider (1) to be ambiguous because only one of the operators matches the actual parameter profile. Is this a bug? In the absence of the first (non-abstract) operator, it says "cannot call abstract subprogram". Fair enough, I still see no bug here. Or perhaps you meant... with Ada.Text_IO; procedure Proc1 is type F1 is digits 3; type F2 is digits 3; function "*" (Left : F1; Right : F2) return F2; function "*" (Left, Right : F2) return F2 is abstract; -- Don't want this operator. function "*" (Left : F1; Right : F2) return F2 is begin Ada.Text_IO.Put_Line ("* called"); return F2 (Float (Left) * Float (Right)); end "*"; A : F1 := 1.0; B : F2 := 1.0 * F2 (A); -- (1) begin null; end Proc1; which gives me: gcc-4.1 -c -gnatwa -gnat95 proc1.adb proc1.adb:15:18: ambiguous expression (cannot resolve "*") proc1.adb:15:18: possible interpretation at line 6 proc1.adb:15:18: possible interpretation at line 5 The abstract subprogram is indeed considered in overload resolution. But since the resolution fails (the call is ambiguous), there is still no way to call the abstract subprogram. So if I understand correctly, in Amendment 1, the call is no longer ambiguous and the first operator is called. Correct? -- Ludovic Brenta.