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

Forrest Gehrke feg at clyde.ATT.COM
Fri May 5 05:19:48 AEST 1989


In article <2763 at buengc.BU.EDU>, bph at buengc.BU.EDU (Blair P. Houghton) writes:
> 
> The way pointers work implies that they don't refer at all to
> anything physical, even to memory locations.
> 

On some systems, particularly one that does not deal in virtual 
memory, a pointer can be referring to a real memory location.
Which leads me to wonder what you would do, as you insist upon
being able to do, with the sum of two pointers?  If you can 
find a use for this, why stop there?  There's also multiplication
and division......

> It doesn't change the fact that I'd like to be able to add and subtract
                                                         ^^^ 
> pointers regardless of what trouble I _might_ get into.  Considering the
> general level of danger incurred by programming in something so potentially
> obfuscatory as C, it's a small barrier to remove.  The arguments of
> "why would you want to do _that_?" don't hold water.  I counter with
> "Why would you want variadic functions?" and "Why would you want to
> define mathematical routines when you can write your own in assembler
> and link to them?"


Perhaps this question is asked because while we can think of uses
for wanting these things, we haven't thought of what we could do 
with the sum of pointers.  You haven't yet provided any 
motives either.

Forrest Gehrke



More information about the Comp.lang.c mailing list