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,67bb3e29a77c25c6 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,CP1252 Received: by 10.68.8.229 with SMTP id u5mr13140084pba.0.1318038230773; Fri, 07 Oct 2011 18:43:50 -0700 (PDT) Path: lh7ni13972pbb.0!nntp.google.com!news1.google.com!postnews.google.com!x25g2000prg.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: pragma Pure (Ada) Date: Fri, 7 Oct 2011 18:37:53 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1318038230 20091 127.0.0.1 (8 Oct 2011 01:43:50 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 8 Oct 2011 01:43:50 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x25g2000prg.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: news1.google.com comp.lang.ada:18347 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Date: 2011-10-07T18:37:53-07:00 List-Id: On Sep 30, 7:11=A0pm, Yannick Duch=EAne (Hibou57) wrote: > Le Sat, 01 Oct 2011 03:50:36 +0200, Yannick Duch=EAne (Hibou57) =A0 > a =E9crit: > > > In =93A Brief Introduction to Ada 2012=94 (a great paper from John Barn= es) -> > >http://www2.adacore.com/wp-content/uploads/2006/03/Ada2012_Rational_I... > > On page 13, there's something I don't feel to understand > > > Programmers have always moaned about the need for many > > explicit conversions in Ada. Accordingly, implicit > > conversions from anonymous access types to named access > > types are now permitted provided the explicit conversion is > > legal. The idea is that the need for an explicit conversion > > with access types should only arise if the conversion could > > fail. A curious consequence of this change is that a > > preference rule is needed for the equality of anonymous > > access types. > > =93a preference rule is needed for the equality of anonymous access types= =94 ? =A0 > What does that mean ? If you have two objects of an anonymous access type that point to the same type, in Ada 2005 you can test them for equality: X : access My_Record; Y : access My_Record; if X =3D Y then ... This calls a function "=3D" that is defined in the language and takes "universal access types" as parameters. If you define a named access type: type My_Record_Acc is access My_Record; this defines an implicit "=3D" operator: function "=3D" (Left, Right : My_Record_Acc) return Boolean ... [and you can override it with your own operator if you really want to]. In Ada 2005, this didn't pose a problem. But in Ada 2012, if an anonymous access type (access My_Record) could be implicitly converted to a named access type (My_Record_Acc), then in this: if X =3D Y then ... the compiler couldn't tell whether "=3D" means the function on "universal access", or the function on My_Record_Acc (since X and Y can now be implicitly converted to My_Record_Acc). This is ambiguous, and ambiguous function calls are normally an error, but making it an error would make some legal Ada 2005 programs illegal in Ada 2012. So a special rule had to be added to make the language *prefer* the "universal access" equality function over any other function. Hope this helps, -- Adam