Path: utzoo!dciem!nrcaer!cognos!jimp From: jimp@cognos.uucp (Jim Patterson) Newsgroups: comp.lang.c Subject: Re: New Features: ++(expr) Message-ID: <2290@cognos.UUCP> Date: 17 Feb 88 03:34:44 GMT Article-I.D.: cognos.2290 Posted: Tue Feb 16 22:34:44 1988 References: <386@osupyr.UUCP> Reply-To: jimp@cognos.UUCP (Jim Patterson) Organization: Cognos Inc., Ottawa, Canada Lines: 24 In article <386@osupyr.UUCP> ddc@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