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: 109fba,cd8ed9115942852f X-Google-NewGroupId: yes X-Google-Thread: 103376,b92b95c9b5585075 X-Google-NewGroupId: yes X-Google-Attributes: gid4f1905883f,gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Randy Brukardt" Newsgroups: comp.lang.c++,comp.lang.ada Subject: Re: Why use C++? Date: Wed, 10 Aug 2011 17:37:28 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <1e292299-2cbe-4443-86f3-b19b8af50fff@c29g2000yqd.googlegroups.com> <1fd0cc9b-859d-428e-b68a-11e34de84225@gz10g2000vbb.googlegroups.com> <9ag33sFmuaU1@mid.individual.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1313015851 17704 69.95.181.76 (10 Aug 2011 22:37:31 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 10 Aug 2011 22:37:31 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!feed.ac-versailles.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail Xref: g2news1.google.com comp.lang.c++:82794 comp.lang.ada:20520 Date: 2011-08-10T17:37:28-05:00 List-Id: "Niklas Holsti" wrote in message news:9ag33sFmuaU1@mid.individual.net... ... > In what way does Ada (95, or the current standard 2005) not support your > needs for unsigned types? I'm not the OP, but... > If you dislike the wrapping behaviour of the Ada "modular" unsigned types, > what is wrong with defining your own unsigned integer type in Ada, as in > > type My_Number is range 0 .. 53621; This does not work on the largest unsigned integer type (mod 2**32 in Janus/Ada). Ada 95 requires type My_Number is range 0 .. 2**32-1; to be rejected, as the upper bound exceeds Max_Int. (This is technically a "signed_integer_type_definition", which shows the cause of the problem.) The Janus/Ada intermediate code can generate overflow checks for the largest integer type, but I've failed to find any reasonable way to model such a type in Ada (assuming we want a real integer type, with numeric literals). The closest is the "non-standard integer type" is 3.5.4(26) -- but why should such a basic need be "non-standard"? And having it "non-standard" means that you can't use type declarations like the above to use it. Yuck. There are uses for wrapping types, but they are far less likely than wanting overflow detection. The default should be to catch errors, not turn them into different ones. Too late to fix, unfortunately. Randy. > or whatever range you need. This gives you non-wrapping arithmetic with > run-time checks for overflow, underflow, and range. > > -- > Niklas Holsti > Tidorum Ltd > niklas holsti tidorum fi > . @ .