swap(x,y)

Blair P. Houghton bph at buengc.BU.EDU
Fri Sep 15 10:20:57 AEST 1989


In article <604 at rwthbs.UUCP> hls at rwthbs.UUCP (H.L. Stahl) writes:
>In article <10897 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>>In article <1545 at l.cc.purdue.edu> cik at l.cc.purdue.edu (Herman Rubin) writes:
>>>
>>>This is another example of keeping the tools from the programmer.
>>
>>No, this is another example of not knowing how to use the tools that are
>>already provided.
>^^^^^^^^^^^^^^^^^^ VERY TRUE!

Bzzzzzt!  Herm knows how to swap.  He wants super-swapping.

Puts me in the mind of one of these people who've moved from E. Germany
to W. Germany in the past couple of days.  He's a butcher, and the
network news showed him taking a look at the butcher shop in the local
market, and he looked like he would go mad:  everything was automatic,
computer-controlled, had an LED readout, etc.  Now, this fellow may
have been an artist with the tools he had back home, but it's likely
the thought of all the work he could get done and the quality he could
create by employing these machines impressed him no end.

Is it still a matter of skill over availability?

>And by the way: why do you need an operator for swapping?

Because if a machine can do it with a coupla gates and half a cycle,
I'd like to do it with an operator.

Some machines (we've already seen an example involving a DG) have
opcodes to swap two values, and it seems a bit ludicrous to code
some elaborate swapping routine when the optimizer is just going
to throw it all out and insert the single instruction.

At least having the operator ensures that the most efficient swapping
method is systematically defined for any processor.

Still, any good optimizer will catch all the obvious cases, but it's
gotta be harder to write a compiler to do it that way than to implement
just another canned routine.

So why haven't the compiler writers been asking for a swap operator or
keyword?

				--Blair
				  "And don't whine back 'so what
				   are the semantics?' or I'll sic
				   my additive pointer on you."



More information about the Comp.lang.c mailing list