Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!mcnc!ncsu!uvacs!edison!steinmetz!davidsen From: davidsen@steinmetz.UUCP (Davidsen) Newsgroups: net.lang.c Subject: Re: What should be added to C Message-ID: <780@steinmetz.UUCP> Date: Mon, 9-Jun-86 15:26:32 EDT Article-I.D.: steinmet.780 Posted: Mon Jun 9 15:26:32 1986 Date-Received: Wed, 11-Jun-86 06:23:47 EDT References: <5498@alice.uUCp> <1462@mmintl.UUCP> <852@bentley.UUCP> Reply-To: davidsen@kbsvax.UUCP (Davidsen) Organization: GE CRD, Schenectady, NY Lines: 46 In article <852@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes: >In article <1462@mmintl.UUCP> mmintl!franka (Frank Adams) proposes: >... >>>exchange operator. This one is quite frequently useful, and the >>>alternatives are ugly. > >Taking into consideration how bad the alternatives are, it *might* be a >good idea to make this a builtin operator; perhaps ":=:". Either Andy's >suggestion of a concurrent assignment operator (could this possibly be >made a variant of struct assignment?) or my ",," operator would be more >powerful, if you don't have to worry about side effects. (How often do >you need "a[i++] SWAP a[j++]" anyway?) > Actually, in sorts I might want a ++ operator on at least one side of the swap operator frequently. Issues which occur to me: 1) The swap operator should correctly handle swap between dirrering types, such that correct type conversion is done in both directions. 2) The swap operator should evaluate the address of both sides only once, like +=, so that self modifying expressions may be used on either or both sides. 3) What would it return? All other binary operators, including assignment, return a defined value and type. Which side of the operator would be returned, and why not the other? I suggest that this is a *perfect* use for the void type, and that the operator not return any value (explicitly). 4) I reject the argument that the same thing can always be done inline. A swap operator would improve readability and (possibly) performance. The people who make this argument probably would have rejected "while", saying that we already have "goto" and "if". I am not really pushing to get this into the current standard, because the time for major changes has passed, and this certainly does not address a burning need or major shortcoming of the language. I *do* think it should be considered for the next standard. -- -bill davidsen ihnp4!seismo!rochester!steinmetz!--\ \ unirot ------------->---> crdos1!davidsen / sixhub ---------------------/ (davidsen@ge-crd.ARPA) "Stupidity, like virtue, is its own reward"