Xref: utzoo comp.lang.c:29950 comp.std.c:3317 Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uwm.edu!bionet!agate!earthquake.Berkeley.EDU!dankg From: dankg@earthquake.Berkeley.EDU (Dan KoGai) Newsgroups: comp.lang.c,comp.std.c Subject: Concurrent assingment (Was No swap needed.....) Summary: Why do you need it? Message-ID: <1990Jun28.162932.14632@agate.berkeley.edu> Date: 28 Jun 90 16:29:32 GMT References: <1990Jun28.143410.6171@cs.utk.edu> Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44) Reply-To: dankg@earthquake.Berkeley.EDU (Dan KoGai) Organization: ucb Lines: 43 In article <1990Jun28.143410.6171@cs.utk.edu> wozniak@utkux1.utk.edu (Bryon Lape) writes: > I finally came to the realization that C needs a concurrent >assignemnt statement. Why? >The syntax would be like the following: > > x,y,z = 1,2,3; > > which would make x=1, y=2, and z=3. This would also be used to >swap values, such as: First this can be achieved by x = 1; y = 2; z = 3; Second this makes C compiler far more comlex because first it has to check the number of assignments and second , in C is also used to as an operator that often appear as int x, y, z = 1; in this case only z is explicity initialized. > x,y = y,x; > This would be equivalent to the following: > z = x; > x = y; > y = z; > > But in implementation it cannot go like x = y; y = x because old x value is discarded in first assignment. It has to store old value of second variable somewhere. and swap(x,y) looks simpler and swap never requres compiler to check the number of assignments. You still haven't explained why it's NEEDED. You just show its pros but it has far more cons than pros. if you still doubt it, try the following case: x, y = (x, y = y, x), (x, y = y, x); How are you going to parse this one? What's the paren supposed to return? two assignments or just one? If one which one? Dan Kogai (dankg@ocf.berkeley.edu)