🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #2575

Re: Report on defect in M2 vs C (Was Modula-2, Modula-3, C or C++)

#2575
From: Robert A Duff
Date: Mon, 02 Oct 1995 15:40
39 lines
2174 bytes
In article <812502101snz@genesis.demon.co.uk>,
Lawrence Kirby  <fred@genesis.demon.co.uk> wrote:
>I see this is cross-posted to comp.lang.ada which I understand has such
>facilities. So I guess ADA users would have useful input on this. Have
>you found exact-width types to be useful, such that using a minimum width
>type instead would have been a problem?

In Ada, you can say:

    type T is range 1..1_000_000;

Then variables of type T will hold values in the range of one to a
million, exactly.  Intermediate expression results are calculated using
some range that is *at least* that big -- probably a 32-bit range on
most computers.

IMHO, this is a huge advantage over worrying about whether 16 bits or 32
bits is enough, and wondering how many bits is an int -- you just
specify whatever range is appropriate to your problem.  There aren't
that many applications that *naturally* map all their integer numbers
into 16 or 32 bit quantities.  (Of course, there are some -- a compiler,
for example, will typically want some integers that reflect what the
hardware does.)

In addition, if you want variables that go *at least* up to a million,
but you're perfectly happy to have larger numbers, then you can say:

    X: T'Base;

Now, X is a variable that will probably have the normal 32-bit range, on
most machines.  But the programmer can be sure that it goes up to a
million, at least.

Also, Ada has types that more-or-less correspond to C's types.  Ada's
type Integer corresponds to C's int -- it's at least 16 bits, and it's
intended to be whatever the machine supports efficiently.  Long_Integer
corresponds to C's long.

- Bob
Technical Details
Message-ID: <DFtvIp.HsJ@world.std.com>
Path: arc1-ca.pugleaf.net!in2.uu.net!world!bobduff
References: <Pine.SUN.3.91.950929043656.23185A-100000@lagrange.uwaterloo.ca> <812502101snz@genesis.demon.co.uk>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.modula2,comp.lang.modula3,comp.lang.c,comp.lang.c++,comp.lang.ada
Path: arc1-ca.pugleaf.net!in2.uu.net!world!bobduff
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Report on defect in M2 vs C (Was Modula-2, Modula-3, C or C++) 
Message-ID: <DFtvIp.HsJ@world.std.com>
Organization: The World Public Access UNIX, Brookline, MA
References: <Pine.SUN.3.91.950929043656.23185A-100000@lagrange.uwaterloo.ca> <812502101snz@genesis.demon.co.uk>
Date: Mon, 2 Oct 1995 15:40:01 GMT