New Features: ++(expr)

00704a-Liber nevin1 at ihlpf.ATT.COM
Tue Feb 16 13:05:06 AEST 1988


In article <681 at devon.UUCP> paul at devon.UUCP (Paul Sutcliffe Jr.) writes:
.In article <1102 at bc-cis.UUCP> john at bc-cis.UUCP (John L. Wynstra) writes:
.> In article <386 at osupyr.UUCP> ddc at 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."
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah



More information about the Comp.lang.c mailing list