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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:5348:: with SMTP id n69mr1783778itb.7.1547542319889; Tue, 15 Jan 2019 00:51:59 -0800 (PST) X-Received: by 2002:a9d:148:: with SMTP id 66mr44077otu.5.1547542319766; Tue, 15 Jan 2019 00:51:59 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.166.216.MISMATCH!q69no29078itb.0!news-out.google.com!v71ni70ita.0!nntp.google.com!k10no29971itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 15 Jan 2019 00:51:59 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2003:da:3712:9e01:d250:99ff:fe54:d2d2; posting-account=UO7etwoAAAD8dZ9XMqp9pq9hGTWlWnZb NNTP-Posting-Host: 2003:da:3712:9e01:d250:99ff:fe54:d2d2 References: <167dc83d-daac-49eb-ba79-48866ccde39d@googlegroups.com> <0c56d9f4-8861-4c74-b170-a973e3789b08@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <23dcd820-d813-4940-a34b-62d9e150f25d@googlegroups.com> Subject: Re: Overloading operator "=" for anonymous access types? From: daicrkk@googlemail.com Injection-Date: Tue, 15 Jan 2019 08:51:59 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:55280 Date: 2019-01-15T00:51:59-08:00 List-Id: Thx for the insight on anonymous access types being somewhat problematic. I= have not yet gotten so far into learning the language as to see this mysel= f. For anyone interested I have tried to summarize my findings with regard to = the example (as I did on SO). Please correct me if I'm wrong: According to the standard, L =3D null, R =3D null, L =3D R as well as L.Nex= t =3D R.Next should each unambiguously call the user-defined operator =3D. = universal_access operator =3D must not kick in at all here. Reason: The operands L, R, L.Next and R.Next violate the precondition in ARM 4.5.2(= 9.1-9.4) for interpreting =3D in these expressions as to mean operator =3D = of the unviversal_access type: All of these operands are of an access-to-object type (access Cell, check) = whose designated type is Cell (check), Cell has a user-defined primitive eq= uality operator (check) such that its result type is Boolean (check); it is declared immediately within the same declaration list as Cell (check)= ; and at least one of its operands is an access parameter with designated type Ce= ll (both operands are, check). The preference rule for operator =3D of the universal_access type in ARM 8.= 6(29.1) does not apply here, since it requires "two acceptable interpretati= ons". But because of 4.5.2, operator =3D of the universal_access type is no= t an acceptable interpretation. So there is no choice: in all cases (even L =3D null) it has to be the user= -defined operator =3D. The example should correctly read: ... if Standard."=3D"(L, null) or Standard."=3D"(R, null) then -- universa= l =3D return Standard."=3D"(L, R); -- universal = =3D elsif L.Value =3D R.Value then return L.Next =3D R.Next; -- recurses O= K ... As Simon Wright pointed out, GNAT seems to run into "unbounded recursion" w= ith the original example, which is actually the correct compiler behavior a= ccording to the standard. However SO user G_Zeus mentioned that GNAT issues= an ambiguity error for L =3D R in a similar example, which is incorrect co= mpiler behavior. It should have unambiguously picked the overloaded operato= r =3D.