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,d5b211b0c1ffcf3e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.193.129 with SMTP id ho1mr318517pbc.8.1340300069819; Thu, 21 Jun 2012 10:34:29 -0700 (PDT) MIME-Version: 1.0 Path: l9ni3943pbj.0!nntp.google.com!news2.google.com!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.x-privat.org!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Practicalities of Ada for app development Date: Thu, 21 Jun 2012 12:34:26 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <1c82b5mc3waww.1t6q6vj61u36u.dlg@40tude.net> <42a87cf3ce9bfd6054f78b2b5b356301@dizum.com> <3e8c1c78-31b0-462e-8341-6d661fbc8378@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1340300068 28509 69.95.181.76 (21 Jun 2012 17:34:28 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 21 Jun 2012 17:34:28 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original Date: 2012-06-21T12:34:26-05:00 List-Id: "Adam Beneschan" wrote in message news:3e8c1c78-31b0-462e-8341-6d661fbc8378@googlegroups.com... >On Sunday, June 10, 2012 2:36:46 PM UTC-7, Nomen Nescio wrote: >> "Dmitry A. Kazakov" wrote: >> > >> > > Please, why have you defined Code_Point as a modular type? >> > >> > Because code point is unsigned. When you declare something signed >> > you do that because you want negative inverses. Signed integers have >> > the base type with 0 in the middle of its range. >> >> That's no reason to use mod. You can put boundaries where you want >> them, integer, or mod. > >This isn't quite true because of subtleties of the language. When you >define an integer "type" with > range 0..(2**32-1), the *type* you declare is actually a larger type than > that. It has to be at least > -(2**32-1) .. (2**32-1), which is a type that requires 33 bits (in > practice, it will probably be > -2**64 .. 2**64-1). You then get a subtype with range 0..(2**32-1). But > some calculations > have to be done using the base type, which means that using a signed > integer type can require > some extra conversions, and can require additional processing time on a > machine that doesn't > have 64-bit arithmetic instructions. It probably wouldn't matter much if > the type is being used > to represent a Unicode code point. But in a more general case, you have > to be careful. It's > not really accurate to simply say "you can put boundaries where you want". Right, but the real question here is why is 2**32 being used at all? Unicode specifically limits the code points to 2**21 (or something close to that, I'm not going to look it up right now); anything beyond that is garbage and not allowed in UTF-8 encoding. So the limit of the type ought to be that, and (based on the discussion), the numeric operators should be "removed" by declaring them abstract. In which case there is no problem using either form of declaration. (If you're keeping the numeric operators, then the form of the declaration should be signed, since using mod means you also lose overflow checking -- and that's almost never what you want.) Randy.