Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!husc6!bbn!uwmcsd1!ig!agate!ucbvax!hplabs!sdcrdcf!csun!csuna!aeusesef From: aeusesef@csuna.UUCP (sean fagan) Newsgroups: comp.lang.c Subject: Re: New Features: ++(expr) Keywords: lvalue expression enough already! Message-ID: <1059@csuna.UUCP> Date: 14 Feb 88 21:50:15 GMT References: <386@osupyr.UUCP> <1102@bc-cis.UUCP> <681@devon.UUCP> Reply-To: aeusesef@csuna.UUCP (Sean Eric Fagan) Organization: California State University, Northridge 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. They are limited to lvalues because ++ and -- are, respectively, incrementors and decrementors. It makes no sense to increment an expression (you can increment the value of it, but not the expression itself), whereas incrementing an lvalue makes perfect sense. [++lvalue is redundant] > lvalue = lvalue + 1 > lvalue += 1 yeah, but then you have something like val = .... lvalue++ .... lvalue++ .... lvalue++; (they are, hopefully, different lvalues, but not necessarily) Your way, you have to do val = .... (lvalue += 1) .... (lvalue += 1) .... (lvalue += 1); Hmm.. I think I'd take the ++ operators. Now, if we use ++(expr), we get val = .... ++(a+b+c) ... ++(a+b+c) ... ++(a+b+c); or val = .... (a+b+c+1) ... (a+b+c+1) ... (a+b+c+1); Same amount of typing (but less shifting on my keyboard). The only reason I could see having the '++(expr)' is so that the '1' added would be multiplied by the size of the expression. However, I've never had a need to do that, and overloading this operator in such a foolish fashion is, well, foolish. >Paul Sutcliffe, Jr. >UUCP (smart): paul@devon.UUCP ----- Sean Eric Fagan Office of Computing/Communications Resources (213) 852 5742 Suite 2600 1GTLSEF@CALSTATE.BITNET 5670 Wilshire Boulevard Los Angeles, CA 90036 {litvax, rdlvax, psivax, hplabs, ihnp4}!csun!csuna!aeusesef