comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Ada 83 - avoiding unchecked conversions.
Date: 1996/12/14
Date: 1996-12-14T00:00:00+00:00	[thread overview]
Message-ID: <E2FDt4.G30@world.std.com> (raw)
In-Reply-To: 32B17F46.123B@gsfc.nasa.gov


In article <32B17F46.123B@gsfc.nasa.gov>,
Stephen Leake  <Stephen.Leake@gsfc.nasa.gov> wrote:
>Perhaps there should have been a type "Fast_Integer", with the
>understanding that it was at least 16 bits (this is of course just
>Standard.Integer). Then programmers can use Fast_Integer when they don't
>really care about the size.

Sometimes, you want "an integer of at least so-and-so range, but I don't
mind if it has more range, so long as it doesn't cost me any
efficiency".  To say that in Ada 95:

    type Specific_Range is range -10_000..10_000;
    subtype T is Specific_Range'Base;

Then use T all over.

Other times, you want an integer type that has something to do with the
amount of addressable memory on the machine.  E.g. type String, where
the index type is Integer, and one presumes that Integer is 16 bits on a
16-bit machine, and 32 bits on a 32-bit machine -- that makes sense,
since you won't want to create 10 megabyte strings on the 16-bit
machine, but you might on the 32-bit machine.

- Bob




  reply	other threads:[~1996-12-14  0:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <md5:8B831999BCF200C6E70994BDF6CC529F>
1996-12-11  0:00 ` Ada 83 - avoiding unchecked conversions Chris Sparks (Mr. Ada)
1996-12-11  0:00   ` Matthew Heaney
1996-12-12  0:00     ` Chris Brand
1996-12-13  0:00       ` Stephen Leake
1996-12-14  0:00         ` Robert A Duff [this message]
1996-12-14  0:00     ` BGaffney42
1996-12-11  0:00   ` Dewi Daniels
1996-12-12  0:00     ` Richard Kenner
1996-12-17  0:00       ` Eric Miller
1996-12-18  0:00         ` Robert Dewar
1996-12-18  0:00           ` Robert A Duff
1996-12-19  0:00           ` Keith Thompson
1996-12-26  0:00             ` Robert Dewar
1996-12-19  0:00   ` Robert I. Eachus
1996-11-27  0:00 Ensco Vendor
1996-11-27  0:00 ` Robert I. Eachus
1996-11-29  0:00 ` Robert Dewar
1996-12-01  0:00   ` Darel Cullen
1996-11-30  0:00     ` Robert Dewar
1996-12-11  0:00     ` Richard Riehle
1996-12-02  0:00 ` Ted Dennison
1996-12-10  0:00   ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox