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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,56250291936154a0 X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: OS Bindings (was: Where is the elusive jump command?) Date: 2000/04/13 Message-ID: #1/1 X-Deja-AN: 610679511 Sender: bobduff@world.std.com (Robert A Duff) References: <38D771CA.D41AF9B5@port.ac.uk><8bq7ku$mc8$1@nnrp1.deja.com><38E0E723.C39C392@quadruscorp.com><8brfm4$4uc$1@nnrp1.deja.com><8brn4k$p6i$1@slb0.atl.mindspring.net><8brrpj$i04$1@nnrp1.deja.com><38E312F8.78883ACB@icn.siemens.de><8c4rvf$d9k$1@nnrp1.deja.com><2000Apr5.070127.1@eisner><2000Apr6.081305.1@eisner><8ci6vf$r5a$1@nnrp1.deja.com><8ck638$krs3@ftp.kvaerner.com><8cp23c$4gp$1@nnrp1.deja.com><8csjs8$o2p3@ftp.kvaerner.com><8d0su8$bqt$1@nnrp1.deja.com> <8d20bq$o2p4@ftp.kvaerner.com> <8d457u$5n33@ftp.kvaerner.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 2000-04-13T00:00:00+00:00 List-Id: "Tarjei T. Jensen" writes: > Robert A Duff wrote > >Also because System.Max_Int is 2**63-1 or 2**31-1 on most > >implementations, and there's a rule saying that the bounds have to be > >less than or equal to System.Max_Int. > > > >If I made the rules, there would be no Max_Int. > > Then I change the declaration to > > type T is range 0 .. #16#ffff_ffff_ffff_ffff; How about: type T is range 0 .. 16#ffff_ffff_ffff_ffff#; ? ;-) Or, equivalently, ".. 2**64-1". > If the compiler complains because the number is out of range for an integer if > it otherwise supports 64 bit numbers I think the compiler has been poorly > constructed. Then *all* Ada compilers are poorly constructed. ;-) At least, all of the Ada compilers I have seen have Max_Binary_Modulus = 2**N, and Max_Int = 2**(N-1)-1, for some N (generally the word size, or twice the word size, of the hardware). That's what the language designers intended, too. So, if N = 32, then: type Signed is range 0..2**32-1; -- Illegal! type Modular is mod 2**32; -- Legal. Type Signed is illegal on that implementation. This means that you're *forced* to use modular when you want to count up to 2**N-1, even though you don't want wrap-around arithmetic. It also means that you're out of luck if you want to count up to 2**N or more. And, unfortunately, N is not portable. >... As long as the lower bound is 0 or positive then it is quite clear > that it is a unsigned type. It seems pointless to involve max_int in this > unless we are talking about a signed number. But Max_Int is the *definition* of the largest (fully) supported integer! It's fine to complain that Max_Int is too small, but I don't think it makes sense to say Max_Int should be wrong. > I don't care about the T base type. I think that the above definition is > perfectly reasonable even though it may be contrary to the letter of the > standard. You *have* to care about the base subtype, because that determines the range of intermediate expression results. > I think it is a glaring oversight in the standard if it not only allows, but > requires compilers to honour a definition like the one above. I tend to agree. As I said in another note, I think there should be no Max_Int. I think all Ada compilers should be required to support things like: type Huge is range -2**100..2**1000; although, as Robert Dewar pointed out, I might not want to insist that Huge be allowed as an array index type, for example. An Ada implementation that restricted arrays to one or two words would be a joke. I think that integers also should not be restricted to one or two words. >...I don't have the > final version of the RM here, only the June 94 version. This Max_Int stuff hasn't changed since Ada 83. Modular types are of course new in Ada 95, and they changed a lot during the Ada 9X project. There was a version where there was no new syntax for them; there was just a package Unsigned (in the SP annex, I think), which declared a bunch of magical integer types that behaved differently from other integer types. I kind of liked that design, because it makes it clear that the semantics of these types is a low-level machine-oriented hack. You can get the real Ada 95 RM from somewhere in: http://www.adaic.org/ and print out the postscript file. - Bob