Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704a-Liber) Newsgroups: comp.lang.c Subject: Re: New Features: ++(expr) Keywords: lvalue expression Message-ID: <3700@ihlpf.ATT.COM> Date: 16 Feb 88 03:05:06 GMT References: <386@osupyr.UUCP> <1102@bc-cis.UUCP> <681@devon.UUCP> Reply-To: nevin1@ihlpf.UUCP (00704a-Liber,N.J.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 38 In article <681@devon.UUCP> paul@devon.UUCP (Paul Sutcliffe Jr.) writes: .In article <1102@bc-cis.UUCP> john@bc-cis.UUCP (John L. Wynstra) writes: .> In article <386@osupyr.UUCP> ddc@osupyr.UUCP (Don Comeau) writes: .> > Since everyone else is suggesting their addition 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. . .Sure, ++expression is redundant. So is ++lvalue. If you dispise the .redundancy, why have ++ and -- at all, since I can easily use . . lvalue = lvalue + 1 . .or . lvalue += 1 . Not quite. lvalue++ is a little bit tougher to come up with an equivalent expression. The following should be equivalent to lvalue++: lvalue += 1 , lvalue - 1 which is something I DON'T want lying around. Also, you would have to parenthesize like crazy. .Of course, for lvaluse, ++ and -- are K&R 'C', so you must have them, .yet you say Don's suggestion is bad. Think about it. I thought about it and I still don't like it (sorry, Don). For consistency's sake, I would rather ++ and -- ALWAYS have a side effect; otherwise, code would be much harder to maintain and little bugs would creep in because many expressions result in lvalues and their values would mysteriously (except to lint :-)) be incremented or decremented. -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_