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:a5d:9b81:: with SMTP id r1mr1442410iom.38.1547243182413; Fri, 11 Jan 2019 13:46:22 -0800 (PST) X-Received: by 2002:aca:c703:: with SMTP id x3mr14358oif.5.1547243182260; Fri, 11 Jan 2019 13:46:22 -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.215.MISMATCH!k10no112096itk.0!news-out.google.com!v141ni127ita.0!nntp.google.com!k10no112092itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 11 Jan 2019 13:46:22 -0800 (PST) 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 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <167dc83d-daac-49eb-ba79-48866ccde39d@googlegroups.com> Subject: =?UTF-8?Q?Overloading_operator_=E2=80=9C=3D=E2=80=9D_for_anonymous_access_ty?= =?UTF-8?Q?pes=3F?= From: daicrkk@googlemail.com Injection-Date: Fri, 11 Jan 2019 21:46:22 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:55265 Date: 2019-01-11T13:46:22-08:00 List-Id: I am working my way through Barnes' excellent Ada book. This is a code samp= le for deep comparison of linked lists from section 11.7: type Cell is record Next: access Cell; Value: Integer; end record; function "=3D" (L, R: access Cell) return Boolean is begin if L =3D null or R =3D null then -- universal =3D return L =3D R; -- universal =3D (Line A) elsif L.Value =3D R.Value then return L.Next =3D R.Next; -- recurses OK (Line B) else return False; end if; end "=3D"; I can't seem to wrap my head around why in Line A operator "=3D" of the uni= versal_access type is called (because of the preference rule), on Line B, h= owever, the user-defined operator "=3D" is called (which makes recursion po= ssible in the first place), this time with no preference for operator "=3D"= of universal_access. Both L and R, as well as L.Next and R.Next are of the same anonymous type "= access Cell". Why the difference in "dispatching"? Does it have to do with = L and R being access parameters? If so, what is the rule there? I did my best to find anything in the AARM, especially section 4.5.2, but c= ould not make any sense of it. Cheers.