New Features: ++(expr)

Brian Matthews blm at cxsea.UUCP
Fri Feb 12 02:15:40 AEST 1988


Don Comeau (ddc at osupyr.UUCP) writes:
|Since everyone else is suggesting their addtion to C, here is one I
|think would be useful.  Why are ++ and -- still limited to lvalues?  I
|think ++expresion should be an expression which has the value
|expression+1.
|Are there any good reason why this hasn't been done?

Yes.  ++ and -- have the side effect of incrementing or decrementing the
lvalue they're applied to, so they have to be applied to lvalues.  How
does one increment x + y (as in ++(x+y)) or m + 4 (as in ++(m+4))?  If
you want the value of one more than an expression and don't want the
increment side effect, that's easy to do in C also:  expression + 1

-- 
Brian L. Matthews                               "A power tool is not a toy.
...{mnetor,uw-beaver!ssc-vax}!cxsea!blm          Unix is a power tool."
+1 206 251 6811
Computer X Inc. - a division of Motorola New Enterprises



More information about the Comp.lang.c mailing list