Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site boring.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!boring!jack From: jack@boring.UUCP Newsgroups: net.lang.c Subject: Re: lint, pointers, 0 (what else?) Message-ID: <6324@boring.UUCP> Date: Wed, 20-Feb-85 11:35:10 EST Article-I.D.: boring.6324 Posted: Wed Feb 20 11:35:10 1985 Date-Received: Sun, 24-Feb-85 04:38:25 EST References: <366@harvard.ARPA> <250@cadre.ARPA> <103@timeinc.UUCP> <2023@drutx.UUCP> Reply-To: jack@boring.UUCP (Jack Jansen) Distribution: net Organization: CWI, Amsterdam Lines: 30 Apparently-To: rnews@mcvax.LOCAL In article <2023@drutx.UUCP> qwerty@drutx.UUCP (Brian Jones) writes: >I couldn't help but throw in my $.25 worth - K&R, 14.4: > >"A pointer may be converted to any of the integral types LARGE ENOUGH TO HOLD >IT. Whether an int or a long is required is MACHINE DEPENDENT." (Emphasis is >mine) > >... >I have begun to wish for data types such as int8, int16, int32, etc. so that >programmers could say what they really mean, instead of leaving it as an >"exercise for the student". no, No, NO, NO!!!!! If you use things like 'int16' to store, for instance, the difference between two pointers, you are just replacing one machine dependency with another. Because pointers can only be 2**16 apart on *your* machine does not mean that this is true for all machines! What you should have is a 'pointer_diff' type, in which you can store the difference (signed, probably) between two pointers. Don't get me wrong, I like the 'int8' idea, but only for storing *normal* integers, of which the programmer nows that they will allways fit in 8 bits, *not* for storing pointer differences. (Note that I say 'pointer difference' everywhere. I think this is the only legitimate reason for pointer->int conversion. People who store pointers in ints should be unlink()ed at first sight) -- Jack Jansen, {decvax|philabs|seismo}!mcvax!jack Notice new, improved, faster address ^^^^^