Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!inuxc!pur-ee!uiucdcs!ccvaxa!aglew From: aglew@ccvaxa.UUCP Newsgroups: net.lang.c Subject: Re: What should be added to C Message-ID: <2600053@ccvaxa> Date: Thu, 22-May-86 10:39:00 EDT Article-I.D.: ccvaxa.2600053 Posted: Thu May 22 10:39:00 1986 Date-Received: Sun, 25-May-86 14:18:33 EDT References: <1463@mmintl.UUCP> Lines: 27 Nf-ID: #R:mmintl.UUCP:1463:ccvaxa:2600053:000:1161 Nf-From: ccvaxa.UUCP!aglew May 22 09:39:00 1986 >/* Written 8:04 pm May 16, 1986 by franka@mmintl.UUCP in ccvaxa:net.lang.c */ >/* ---------- "Re: What should be added to C" ---------- */ >Something which got forgotten in my original article: I would favor an >exchange operator. This one is quite frequently useful, and the >alternatives are ugly. > >Frank Adams ihnp4!philabs!pwa-b!mmintl!franka >Multimate International 52 Oakland Ave North E. Hartford, CT 06108 >/* End of text from ccvaxa:net.lang.c */ Why not go all the way and implement Dijkstra's concurrent assignment? i,j := j,i for a swap. Course, couldn't use commas, but you get the idea. Compilers can generate good code for this, and it makes programs with complicated pointer manipulations much clearer; I used to teach it, and the associated code generation algorithm, to U1s in classes I TAed, and it greatly reduced the noise level of assignments in the wrong order. #define swap(a,b) a,b := b,a does the exchange without having to type the name twice. Andy "Krazy" Glew. Gould CSD-Urbana. USEnet: ihnp4!uiucdcs!ccvaxa!aglew 1101 E. University, Urbana, IL 61801 ARPAnet: aglew@gswd-vms