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,640b65cbfbab7216 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!y22g2000prd.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Ada.Strings.Bounded Date: Mon, 21 Apr 2008 18:02:45 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2b5c47f7-04f6-4530-b8d0-2a0b730a0fbd@y22g2000prd.googlegroups.com> References: <80c6fdca-1a89-4d98-b61d-9a405e57d8e5@s13g2000prd.googlegroups.com> <1wh7cbu67y4wz$.7iu8likx0fct.dlg@40tude.net> <144w648u50r6q.1erjxxu0cplbw.dlg@40tude.net> <611360e0-595c-43a7-b5cb-137a278ec0c1@s13g2000prd.googlegroups.com> <15389tuelo6x6$.1c1a6yixordts$.dlg@40tude.net> <4c1be2a2-0178-4c1f-8c96-526020550f42@w4g2000prd.googlegroups.com> <15514187-d7d0-4650-a058-13ec5684be2c@w5g2000prd.googlegroups.com> <07e98c4f-9b79-412f-9e95-94dd04082355@p39g2000prm.googlegroups.com> <81b0ae55-12a6-44e4-8481-3753b05d4464@f24g2000prh.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1208826166 14560 127.0.0.1 (22 Apr 2008 01:02:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 22 Apr 2008 01:02:46 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y22g2000prd.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:21027 Date: 2008-04-21T18:02:45-07:00 List-Id: On Apr 21, 5:49 pm, Adam Beneschan wrote: > > -- (Example C) > > Z0 : constant := Integer'Last ; > > type Z is range 0 .. Z0 ; > > B : constant Z := ( Z0 + 1 ) - 1 ; > > All the above examples seem to indicate that GNAT, at least, is > > resolving overloaded addition operators. The overload is between the > > declared type, root_integer (or something like it), and possibly even > > universal_integer. With other types, ones where there is no universal > > type, this would be an illegal ambiguity. So it seems that GNAT is > > nondeterministically resolving them. > > There's nothing nondeterministic about this. See 8.6(29). I goofed. This rule doesn't actually apply in this case, since the expected type of the expression is a user-defined integer type, which isn't compatible with root_integer. (If the expected type of an expression is a specific integer type that isn't root_integer, the expression can be of that type or it can be universal_integer, but it can't be root_integer.) I've sometimes made the mistake of confusing root_ and universal_integer, and I got sloppy here. But I think that actually makes the point even moreso that there's no nondeterminism involved. The expected type is Z; therefore, in example C, the only possible meaning for "-" is the function that takes two arguments of type Z and returns Z. That, in turn, applies to "+". So it's 100% clear from the language rules what functions are called by this expression. The reason it doesn't raise Constraint_Error is 4.9(33), as I mentioned earlier. -- Adam