New Features: ++(expr)
Jim Patterson
jimp at cognos.uucp
Wed Feb 17 13:34:44 AEST 1988
In article <386 at osupyr.UUCP> ddc at osupyr.UUCP (Don Comeau) writes:
>
>Since everyone else is suggesting their addtion to C,
Actually, the ANSI committee isn't much interested anymore (since they're
trying to get what they already have in a form everyone is happy with), but...
> Why are ++ and -- still limited to lvalues? I
>think ++expresion should be an expression which has the value
>expression+1.
There's a very simple reason. ++x isn't an operator to just return x+1.
It's purpose is to increment x by 1 and then return the new value of
x. If x is an expression, you can't increment it because it would then
be a different expression.
I've seen a lot of confusion over the ++ and -- operators, typically
by novice users who think that ++ is synonymous with "+1". It isn't.
Making it synonymous in the case of expressions but not in the case of
actual lvalues (if that's what you propose) would be very confusing.
It's not always clear even whether an expression is an lvalue or not.
--
Jim Patterson Cognos Incorporated
UUCP:decvax!utzoo!dciem!nrcaer!cognos!jimp P.O. BOX 9707
PHONE:(613)738-1440 3755 Riverside Drive
Ottawa, Ont K1G 3Z4
More information about the Comp.lang.c
mailing list