swap(x,y)
Chris Torek
chris at mimsy.UUCP
Fri Sep 1 05:48:10 AEST 1989
-In article <14479 at haddock.ima.isc.com> karl at haddock.ima.isc.com
-(Karl Heuer) writes:
->[The xor trick] won't work on float, pointer, struct, etc.
In article <1545 at l.cc.purdue.edu> cik at l.cc.purdue.edu (Herman Rubin) writes:
-If one adds a pseudo-op, say use (I will not object to a more appropriate
-term) so that (use int)x means treat x as type int no matter what it was,
-if possible, then it will work on float and pointer, and even swap between,
-say, float and pointer. If this is modified to allow multiple-word types,
-it could handle double and struct.
-
-This is another example of keeping the tools from the programmer.
And if one uses a wrench as a hammer, it sometimes (actually often) works.
If you want to swap values, you should swap values. Icon has a nice
notation for it: `x:=:y'. C happens not to have a nice notation for it.
(use int) is not very nice either, because it is size dependent.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list