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,d7ae8269a4ecf7c4 X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Prevalence of Compilers for Which Integer'Size < 32? Date: 1996/07/28 Message-ID: #1/1 X-Deja-AN: 170853279 references: <4tdp24$5h1@news.pacifier.com> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-07-28T00:00:00+00:00 List-Id: Dave Marshall says "My specific question revolves around something such as this example that you'll find in a lot of time-handling packages. type Seconds_In_A_Day is range 0 .. 86_400; This is going to work fine for compilers for which Integer'Size is 32, but it will fail for compilers for which Integer'Size = 16. Of course, this is because the above statement is equivalent to type some_anonymous_integer_type is new Integer; subtype Seconds_In_A_Day is some_anonymous_integer_type range 0 ..86400;" This is technically incorrect. There is no requirement that in the above Seconds_In_A_Day be derived from Integer, it can be derived from any available predefined type in Standard. Yes, in theory you can imagine a compiler that would not accept this, but in practice absolutely every compiler wlil accept the above declaration. The 16-bit PC compilers where integer is 16 bits (from both RR and ALsys) both provided a 32-bit long_integer suitable for the above derivation. I believe the most restrictive compiler available is the Intermetrics Patriot-2 compiler, where the largest integer size is 24 bits, but (a) I might be wrong on this, (b) I doubt you are using this compiler :-) and (c) anyway 86_400 fits in 24 bits. As to never using type Integer, you often see this advice, but like most absolute rules, if you follow this rule absolutely, you will be in trouble. It would mean that you could not use the built in type String, and consequently could not use any library packages depending on string (including unbounded_strings, bounded_strings, all the I/O etc). In addition, you could not use the exponentiation operation on real values. So in practice the rule is not to use Integer where it is easily avoided, but use it where necessary for predefined stuff.