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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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!u69g2000hse.googlegroups.com!not-for-mail From: Eric Hughes Newsgroups: comp.lang.ada Subject: Re: Ada.Strings.Bounded Date: Tue, 22 Apr 2008 08:25:13 -0700 (PDT) Organization: http://groups.google.com Message-ID: <78a1a55a-6f2b-4ce7-b38c-7fc33e484a5d@u69g2000hse.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: 166.70.57.218 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1208877914 13899 127.0.0.1 (22 Apr 2008 15:25:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 22 Apr 2008 15:25:14 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u69g2000hse.googlegroups.com; posting-host=166.70.57.218; posting-account=5RIiTwoAAACt_Eu87gmPAJMoMTeMz-rn User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:21032 Date: 2008-04-22T08:25:13-07:00 List-Id: On Apr 21, 6:49 pm, Adam Beneschan wrote: > See 4.9(33). Oh. OK. For those insufficiently motivated to look at this section, it says that static expressions are evaluated exactly, without performing overflow checks. To me, that word "exactly" means that static expressions are evaluated as universal_integer, since that's the only way to get them defined exactly. Previously, Bob Duff had said: > An integer literal has type universal_integer, as you said, but > universal_integer has no "+" operator. There is a "+" for root_integer, > and also for user-defined integer types. Universal_integers can be > implicitly converted to various integer types. Something's got to give here. I see the following possibilities: 1) universal_integer actually does have a "+" operator. It would only be available at compile time, since there's no way to declare a variable of type universal_integer. 2) The addition chosen is the context-dependent one, as for dynamic expressions, but when overflow happens, the result is magically converted to universal_integer. 3) The addition of the ordinary type is tried with the base type. If it overflows, a bigger type is tried, and so on up to universal_integer, which will always succeed. 4) The evaluation happens purely mathematically, without regard for the Ada type system. 5) There are different versions of the type and its addition operation for static and run-time use. The static ones have arbitrarily large capacity and exact arithmetic. I'm sure my imagination is not large enough to guess at all the possibilities. What's going on here, really? Eric