Style, readability, etc. (long, but IMPORTANT)

Peter da Silva peter at baylor.UUCP
Fri Jul 26 20:57:19 AEST 1985


> ++ is unique to C; I have never seen it in any other language.

	FORTH:		1+!
	PDP-11 as:	mov	(sp)+,port
	6809 as:	leas	,x++

> The symbol
> does not mean anything to anyone not versed in C, rather, it was
> invented by the implementors of C to make things easier to type and
> compile.

	It was invented by the DESIGNER of 'C' because it served
a useful purpose. The syntax "a <- +/array" was invented by the
DESIGNER of apl because it served a useful purpose. The syntax
(cond (t blah...)) was invented by the DESIGNER of LISP because
it served a useful purpose. The syntax "a in ['0'..'9']" was
invented by the DESIGNER or Pascal because it served a useful
purpose.

	Every language has idioms. Why are you picking on a relatively
harmless one in 'C'?

> non-C programmer needs to look at it (which you say never happens, but
> I'm sure it happens more than you think) it is helpful.

	Any non-c programmer is going to have to learn more about the
language than just ++. What about for(init;test;inc)? Does that make
sense without studying Kernighan & Ritchie? Or continue (what does that
do to a Fortran hack)... if we're going to have to comment everything
'C' does that some other language doesn't we might as well write in
COBOL. What do you think about COBOL, by the way?

>   while(ptr++->duck)  /* move pointer to the duck after the next NULL */
>     ;
> 
> That last one is equivalent (in purpose) to
> 
>   while( ptr->duck != NULL )  /* move pointer to next NULL duck */
>     ptr = ptr + 1;
>   ptr = ptr + 1;              /* and increment to the one after it */
> 
> This form is more readable, but if efficiency is your thing, then the
> first one is ok *AS LONG AS THE COMMENT IS THERE*.

I don't find one or the other particularly less readable. The second one
makes me want to scream...

> To demonstrate, I am currently working on a program, written by someone
> else, written in Mesa, a language similar to Pascal, but much more
> modular.  The language is very readable as languages go.  The program
> has very few comments.  (The majority of comments are the kind "END;
> --of DisplayProc"; really helpful, eh?)  I think how much easier the
> program would be to understand if it had comments.  But then I think how
> much harder it would be to understand if it were written in C (without
> comments).

Since some turkey wrote a program in some obscure language that looks like
ADA, and didn't comment it, you got a bee in your bonnet about comments and
decided to take it all out on us.
-- 
	Peter da Silva (the mad Australian)
		UUCP: ...!shell!neuro1!{hyd-ptd,baylor,datafac}!peter
		MCI: PDASILVA; CIS: 70216,1076



More information about the Comp.lang.c mailing list