syntax for unary assignment operators (was Re: C history question)

Alan J Rosenthal flaps at dgp.toronto.edu
Mon Sep 18 05:05:04 AEST 1989


rhg at cpsolv.UUCP (Richard H. Gumpertz) writes:
>As long as we are discussing missing "assignment" operators, you might ponder
>the lack of unary assignment operators.  Why should I have to say X = -X or
>X = ~X?  Why not have unary assignment operators (ala ++ and --) for negation
>and complement?  I suppose a new syntax would have to be invented, but it
>might be useful at times.

A somewhat consistent but fairly bizarre syntax would be
	x -=;

The analogy to x -= y is that
	x fn= y;
expands to
	x = fn(x, y);
so
	x fn=;
expands to
	x = fn(x);

ajr



More information about the Comp.lang.c mailing list