Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!ark From: ark@alice.UucP (Andrew Koenig) Newsgroups: net.lang.c Subject: Re: What should be added to C Message-ID: <5521@alice.uUCp> Date: Sun, 25-May-86 02:24:33 EDT Article-I.D.: alice.5521 Posted: Sun May 25 02:24:33 1986 Date-Received: Mon, 26-May-86 01:30:36 EDT References: <2600053@ccvaxa> Organization: Bell Labs, Murray Hill Lines: 35 > 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. Two comments: 1. This is really not the same as a swap. I would like to be able to say something like swap (a[i++], a[j++]); and have it do the right thing, effectively a[i],a[j] = a[j],a[i]; i++, j++; This is definitely not equivalent to a[i++], a[j++] = a[j++], a[i++]; 2. Can you give me a simple code generation algorithm for multiple assignments that gets things like i, a[i] = j, a[j]; correct and never uses extra temporaries? I have this nagging feeling that even without subscripted variables, the problem is NP-complete.