More extensions to C (was: Boolean Operators Slighted in C)
Frank Adams
franka at mmintl.UUCP
Wed May 21 08:54:02 AEST 1986
In article <826 at bentley.UUCP> kwh at bentley.UUCP writes:
>In article <2741 at utcsri.UUCP> greg at utcsri.UUCP writes:
>>In article <602 at brl-smoke.ARPA> rbj at icst-cmr (Root Boy Jim) writes:
>>>3) Exchange operator. ...
>>
>>Good stuff. Even machines without an EXG can use a scratch register, which
>>is better than using a user-supplied temp.
>
>This could be considered a special case of my ",," operator: to exchange x
>and y, write "x = (y ,, (y = x))".
I would prefer a syntax like "{x, y} = {y, x};" It's more readable.
(BTW, a really good optimizing compiler can optimize out the temporary. I'm
not fully up on what optimizers are doing these days, but I doubt that there
are many compilers which do this. Optimizing it out is easier if it is
declared locally ("{int temp = x; x = y; y = temp;}") instead of being
declared at the top of the routine.)
Frank Adams ihnp4!philabs!pwa-b!mmintl!franka
Multimate International 52 Oakland Ave North E. Hartford, CT 06108
More information about the Comp.lang.c
mailing list