When it is amoral... (Re: When is a cast not a cast?)

Guy Harris guy at auspex.auspex.com
Fri May 5 17:24:57 AEST 1989


>Normal C, however, allows this sort of thing by telling one to declare
>	
>	int diffa;
>
>and merrily arithmeticise.  No warnings, no complaints, not even a bump
>in the great, grassy field of complacen-C....

Or, even better, "ptrdiff_t diffa", in (p)ANS C at least, where
"ptrdiff_t" is defined in <stddef.h>.

>Mind you, it's real nice to be able to do it this way, and if one
>couldn't, we'd all be screaming for it, but it feels the same as adding
>shorts, longs, and ints together haphazardly.

Well, think of "ptrdiff_t" as syntactic sugar-coating, or syntactic
buffering to prevent an upset stomach (you remember, the little "B"s
bouncing around your stomach, which don't have the sharp points that the
little "A"s do, and thus don't poke into your stomach lining); you now
have objects of various flavors of pointer type, of various flavors of
integral type - and of a type that means "difference between pointers",
although that type happens to be one of the integral types.  Now, while
pointers come in different types, "difference between pointers" happens
to come in only one type - but then, measurements come in different
types (cm, inches, grams, furlongs, fortnights, etc.), but ratios of
measurements come in one type, too.... 



More information about the Comp.lang.c mailing list