🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #2569

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

#2569
From: Lawrence Kirby
Date: Sat, 30 Sep 1995 23:01
49 lines
2896 bytes
In article <Pine.SUN.3.91.950929043656.23185A-100000@lagrange.uwaterloo.ca>
           vluu@lagrange.uwaterloo.ca "Viet-Trung Luu" writes:

>Hmmm... the concept of *long*s is interesting to me. One of C's greatest 
>flaws is the varying size of ints, longs, shorts, etc. (IMHO).

Actually I believe that is one of its strengths that has facilitated its
spread over many platforms and its widespread use.

>Integers 
>should be at least 32 bits long (16 bits just isn't enough),

16 bit values are enough for a surprisingly large number of circunstances.
If you want an integer that is at leas 32 bits wide C provides the long type
which has precisely this definition. If you want a type that is as close
to 32 bits as possible (but no less) and are afraid that longs will be
too long you can trivially set up a suitable typedef using the preprocessor.

>but when you 
>want specific-size numbers, there should be a way of declaring them. When 
>you ask for an int, what you should get is a reasonable integer (whether 
>that be 32-bit or 64-bit... I'm beginning to lean towards the latter).

As stated C provides exactly that - it is called a long.

>If 
>you need 32-bit integers (exactly), then you should be able to ask for 
>that. Furthermore, with all sorts of networks and interoperability 
>questions, such features (for canonical types) are becoming more and more 
>useful.

As yet I have not seen a single valid use for an exact 32 bit integer (at
least not in portable code). This idea seems to come up a lot but nobody
seems to be able to suggest an application for it that can't be reasonably
done in an 'at least 32 bit' type. The nearest seem to be dealing with
external data formats but even these are subject to problems like byte
ordering and there are non-trivial standards and libraries to do this sort
of thing correctly.

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?

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Technical Details
Message-ID: <812502101snz@genesis.demon.co.uk>
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!genesis.demon.co.uk
References: <Pine.SUN.3.91.950929043656.23185A-100000@lagrange.uwaterloo.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!genesis.demon.co.uk
From: Lawrence Kirby <fred@genesis.demon.co.uk>
Newsgroups: comp.lang.modula2,comp.lang.modula3,comp.lang.c,comp.lang.c++,comp.lang.ada
Subject: Re: Report on defect in M2 vs C (Was Modula-2, Modula-3, C or C++) 
Date: Sat, 30 Sep 95 23:01:41 GMT
Organization: none
Message-ID: <812502101snz@genesis.demon.co.uk>
References: <Pine.SUN.3.91.950929043656.23185A-100000@lagrange.uwaterloo.ca>
Reply-To: fred@genesis.demon.co.uk
X-NNTP-Posting-Host: genesis.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.27