Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!buengc!bph From: bph@buengc.BU.EDU (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: swap(x,y) Message-ID: <4151@buengc.BU.EDU> Date: 15 Sep 89 00:20:57 GMT References: <8350@boring.cwi.nl> <14479@haddock.ima.isc.com> <1545@l.cc.purdue.edu> <10897@smoke.BRL.MIL> <604@rwthbs.UUCP> Reply-To: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Organization: Boston Univ. Col. of Eng. Lines: 47 In article <604@rwthbs.UUCP> hls@rwthbs.UUCP (H.L. Stahl) writes: >In article <10897@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >>In article <1545@l.cc.purdue.edu> cik@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."