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: a07f3367d7,d5b211b0c1ffcf3e X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.204.132.81 with SMTP id a17mr380402bkt.4.1339690930708; Thu, 14 Jun 2012 09:22:10 -0700 (PDT) Path: e27ni47859bkw.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Practicalities of Ada for app development Date: Mon, 11 Jun 2012 11:29:47 -0700 (PDT) Organization: http://groups.google.com Message-ID: <3e8c1c78-31b0-462e-8341-6d661fbc8378@googlegroups.com> References: <1c82b5mc3waww.1t6q6vj61u36u.dlg@40tude.net> <42a87cf3ce9bfd6054f78b2b5b356301@dizum.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1339439514 4359 127.0.0.1 (11 Jun 2012 18:31:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 11 Jun 2012 18:31:54 +0000 (UTC) In-Reply-To: <42a87cf3ce9bfd6054f78b2b5b356301@dizum.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-06-11T11:29:47-07:00 List-Id: On Sunday, June 10, 2012 2:36:46 PM UTC-7, Nomen Nescio wrote: > "Dmitry A. Kazakov" wrote: > >=20 > > > Please, why have you defined Code_Point as a modular type? > >=20 > > 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. >=20 > 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 defi= ne an integer "type" with range 0..(2**32-1), the *type* you declare is ac= tually 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 b= e=20 -2**64 .. 2**64-1). You then get a subtype with range 0..(2**32-1). But s= ome calculations have to be done using the base type, which means that usin= g a signed integer type can require some extra conversions, and can require= additional processing time on a machine that doesn't have 64-bit arithmeti= c 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 t= o be careful. It's not really accurate to simply say "you can put boundari= es where you want". IIRC, some people have proposed adding unsigned integer types to the langua= ge; they've argued that modular types aren't good enough for some purposes.= But the idea was turned down. -- Adam