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,4ff929aa5c2b2834 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.net!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Ranges and (non)static constraints Date: Fri, 17 Nov 2006 18:58:00 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1pqs0gcno5o2t.1195tm9yap28b.dlg@40tude.net> <160ziiyah2n7g.5k340gtji747.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1163807882 15332 192.74.137.71 (17 Nov 2006 23:58:02 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 17 Nov 2006 23:58:02 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:FEXIajX3LE+g2F9iMFrNL/4GL+U= Xref: g2news2.google.com comp.lang.ada:7544 Date: 2006-11-17T18:58:00-05:00 List-Id: "Jeffrey R. Carter" writes: > Dmitry A. Kazakov wrote: >> Actually it is not the machine which cannot, but the compiler. Why >> should I >> care if an integer would fit a machine word? > > I agree. GNAT has gone a little ways in this direction, providing 64-bit > integers on 32-bit machines. If I ever get around to defining NINA, it > will accept any range for integer types. Of course, if you make them too > big, objects of the type may raise Memory_Exhausted. There would be ways > to create integer types that correspond to those supported by the HW, > where that's important. What's NINA? I think you're on the right track, here. The goal should be (1) the program can use arbitrarily large integers (up to the memory limit), as in Lisp et al, and (2) if you don't need that, you don't pay any efficiency cost (no distributed overhead). I don't know of any language that achieves both. If I say: type T is range 1..1_000_000; X : constant T := ...; Y : constant T := ...; Z : constant T := (X + Y) / 2; it is implementation dependent whether or not the calculation of Z overflows. That's bad. (But no implementations overflow in that case, so nobody cares, and people write such things all the time.) If I say: type T is range 1..1_000_000_000_000; some implementations fail at compile time, and some do not. That's bad, too. I ought to be allowed to say, portably: type T is range 1..10**100; >... And there'd be type Unbounded_Integer, providing > use of the unbounded-integer library used by the compiler. Well, I'll quibble with your names, here. When God created the integers, He didn't say they stop at 2**31-1 or 2**64 or whatever! The term "integer" (or the abbreviation "int") ought to mean the true unbounded integers. Names like Unbounded_Integer and _universal_integer are an abomination. ;-) - Bob