Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: >< swap operator Date: Tue, 14 Aug 2018 10:46:06 -0700 Organization: None to speak of Lines: 26 Message-ID: References: <36d546c5-b471-45fc-b87a-8ebebdc0c0b7@googlegroups.com> <730b028f-e601-4d8b-95ac-1e3c9a11ee89@googlegroups.com> <61b07dd1-2af0-4f82-8ab6-bd831b564c53@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="b6ba810ad714702bc450c66f3c04171d"; logging-data="28283"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19EuuNDmZljOElb9W4Rver9" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:YojjdnprdIb3/7/9PEEzFp4R+K0= sha1:kwCq2J/hLfoVTf+dHc1hCjCDG5A= Xref: csiph.com comp.lang.c:133817 David Brown writes: > On 14/08/18 16:50, bart4858@gmail.com wrote: >> How about just swap(x,y) then you don't need to explain what >< means. > > Or if you don't need to stick to C syntax: > > x, y = y, x The problem is, that *is* C syntax. Due to the low precedence of the comma operator, it's equivalent to x, (y = y), x This: (x, y) = (y, x) is also valid C syntax, but it's a constraint violation because (x, y) is not an lvalue (and the value of y on the RHS would be discarded anyway). -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"