[comp.lang.misc] Cardinal numbers or unsigned int..

jgk@demo.COM (Joe Keane) (05/31/90)

In article <Ft*!k&2@cs.psu.edu> melling@cs.psu.edu (Michael D Mellinger) writes:
>I guess it's a question of style.  I personally don't like unsigned int
>because it's two words and it's too long.

This is funny.  Do you avoid everything that's two words?  The canonical name
of the type is `unsigned int'.  If you think that's too long, you can call it
what you want.  A common typedef is `u_int', used in the Unix kernel.

Begin tirade...

So what the heck is an `int'?  Accoding to K&R, it's a bit pattern ``of the
natural size for integer arithmetic on a given machine''.  Similarly, a
`float' is a ``single precision floating-point number''.  These types are
explicitly defined and named in terms of low-level machine resources.

I think this is something Pascal and Modula-2 got wrong.  Calling a machine
word an `INTEGER' or `CARDINAL' and a floating-point number a `REAL' is a lie.
I know what an integer is, and when you add two positive ones you better get
another positive one.  Similarly, real numbers obey associativity and similar
laws which floating-point numbers do not.

Furthermore, this naming paves over the distinction between abstract data
types and their implementations.  I think this is a bad thing to teach people
who are learning to program.  The world is full of things that screw up with
more than 32767 (or 255 or 2147483647) of something.  We need less of this,
and Pascal confusing the issue isn't going to help any.

At least C is honest about its type names.  Demand `truth in advertising'.