[comp.lang.c] swap - every definition so far is wrong

andy@rocky.STANFORD.EDU (Andy Freeman) (09/07/87)

The pointer definitions do the right thing with swap( i, a[i] ), as
long as i isn't a register variable.  (Rahul Dhesi <dhesi@bsu-cs.UUCP>
mentioned this.)  They also fail on swap( a, b ) when a and b are
arrays.  (Steve Emmerson, steve@umigw.MIAMI.EDU, caught this one;
I hadn't thought of it.)

These problems come from c; cpp causes one additional problem.
Swap should work no matter what names are used outside the
definition.  swap( __t, __x ) should work; all of the proposed
definitions fail if the argument has the "wrong" name.

-andy
-- 
Andy Freeman
UUCP:  {arpa gateways, decwrl, sun, hplabs, rutgers}!sushi.stanford.edu!andy
ARPA:  andy@sushi.stanford.edu
(415) 329-1718/723-3088 home/cubicle