C programming style

Karl Braun braun at drivax.UUCP
Tue Jul 16 03:04:13 AEST 1985


> Maybe "i++" is clearer to you, but do you only write programs for
> yourself?  To me "i++" is the kind of statement typical of an APL-type
> language, not a language that is supposed to be structured and easy to
> understand.  "i++" could mean something else in another language.  
> ... If I want to distinguish between incrementing
> and adding, then I would define a procedure such as "increment(i)",
> which can be immediately understood.

var++ or ++var is a basic primitive of C.  If you don't immediately comprehend
what var++ means, then you don't know C (as in, haven't even looked at the
manual).  It is exactly equivelant to a procedure 'increment(var)'.

Yes, maintenance costs more than original program development and it's costs 
should be weighed against development costs, but, as I think most C programmers
would agree, this particular statement is so fundemental to the language that
is kind of silly not to use it.  The comment regarding the effeciency of the
produced code is probably applicable to most compilers, but academically, any
reasonable optimizer should optimize 'i = i + 1' to equivelant code.  

I guess the main point is this:  if you don't understand 'var++' then you
probably are not quite ready to be upgrading C code.



More information about the Comp.lang.c mailing list