rhg@cpsolv.UUCP (Richard H. Gumpertz) (09/24/89)
As long as we are discussing new operators, let me mention one that I have often wanted. The current "," operator is defined, in the context "X , Y" as evaluate X then evaluate Y then return the value computed for Y. I have many times wanted to have an operator such that "X NEWOP Y" would mean evaluate X then evaluate Y then return the value computed for X. That is, it would be equivalent to "T=X, Y, T" except that the temporary would be implicit and there would be no need to declare one having the same type as X. To refer back to previous discussions, note that SWAP(X,Y) would be expressable as X = (Y NEWOP (Y = X)) (assuming evaluation of the lvalue Y had no side- effects). The inner set of parentheses would not be needed assuming the precedence of NEWOP was like that of ",". If there were a NEWOP= assignment operator (which could be defined to be like assignment but return the OLD value of the left operand), then SWAP would be even simpler: X = (Y NEWOP= X). What about three-way compounds, such as "NEWOP+=" (or is it "+NEWOP="?)? Note that X NEWOP+= Y would be similar to X++ in that it returns the old value of X but would differ in that the increment would be Y instead of 1. Why should only +=1 and -=1 be so "special" as to have forms that return the old value of the changed variable? Another example: INT to ASCII conversion might use digit = (n NEWOP/= 10) % 10 or such. Any suggestions for the graphic that might be used to represent NEWOP? Obviously "NEWOP" is hardly the appropriate name or representation! -- ========================================================================== | Richard H. Gumpertz: ...uunet!amgraf!cpsolv!rhg | | Computer Problem Solving, 8905 Mohwak Lane, Leawood, Kansas 66206-1749 | ==========================================================================