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 Path: g2news2.google.com!news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news.in2p3.fr!in2p3.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.c++,comp.lang.ada Subject: Re: Why use C++? Date: Fri, 12 Aug 2011 00:02:55 -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> <1d8wyhvpcmpkd.ggiui9vebmtl.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1313125378 5816 69.95.181.76 (12 Aug 2011 05:02:58 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 12 Aug 2011 05:02:58 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 Xref: g2news2.google.com comp.lang.c++:92592 comp.lang.ada:21518 Date: 2011-08-12T00:02:55-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:1d8wyhvpcmpkd.ggiui9vebmtl.dlg@40tude.net... > On Wed, 10 Aug 2011 17:37:28 -0500, Randy Brukardt wrote: > >> 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. > > The OP mentioned image processing, the behavior frequently needed there is > saturated integer arithmetic, which is nether ranged nor modular. I'm not familar with any hardware on which saturated integer arithmetic is provided. If it was, I would expect direct language support for it (which need not require new kinds of types). > As for modular types, wrapping is the mathematically correct behavior, it > is not an error. Right, but using modular types as a stand-in for unsigned integers doesn't really work. Syntactically, Ada ought to have a way to declare an overflow-checked integer type without any restriction to signed/unsigned representations. Modular types are something altogether different (and in all honesty, rare enough that direct language support is of dubious value -- most of us supported adding them to Ada 95 simply because it was the only way to get any support for the largest unsigned integer type). > You just cannot provide every possible arithmetic at the language level. No, you should have a single general integer type (with no reflection on "bits" or "signs"). The rest should be modeled as libraries. (I think we actually agree on this -- must be something in the water today. ;-) Ada has screwed this up (but not as badly as most languages). Randy.