What should be added to C

Davidsen davidsen at steinmetz.UUCP
Tue Jun 10 05:26:32 AEST 1986


In article <852 at bentley.UUCP> kwh at bentley.UUCP (KW Heuer) writes:
>In article <1462 at 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 at ge-crd.ARPA)

"Stupidity, like virtue, is its own reward"



More information about the Comp.lang.c mailing list