C Indentation Survey Results (long...)

Jonathan P. Leech jon at cit-vax
Wed May 8 10:47:07 AEST 1985


>   Now, isn't this rendition of the example given earlier **MUCH** easier to
>   read, parse, and understand?...
    Not really. What was  originally  posted  was  NOT	'K&R  orthodox
bracing style', anyway.  It  wasn't  written  very  well  either.  The
following version seems much better to me:

    switch (key) {

    case BACK:
	fprintf(stoout,"BACK\n");
	foo = &(device->s.stroke);
	if (foo->current_editpos > 1) {
	    int cnt = --(foo->current_editpos);
	    foo->editptr = &(foo->header);
	    for (i = 1; foo->editptr->next->next, i < cnt; i++)
		foo->editptr = foo->editptr->next;
	} else {
#ifdef DEBUG

    It's smaller, faster, and I find it far easier to  read.   From  a
religous standpoint, I find empty block bodies	disgusting.   I  think
the indenting style is not anywhere near as important as  applying  at
little thought to the code in this case, anyway.

>   And (as long as we are sharpening axes here) if you were programming in
>   PASCAL you could put the sucker in a WITH DEVICE clause and get rid of all
>   those "device->" references.  AND, it would be more efficient since the
>   reference would only be evaluated once, at the WITH clause (clearly compiler
>   optimization in C compilers would have a bearing on this).

    Big deal. That's exactly what's going on above, with the additional
(to me) advantage that the structure pointer being used is explicit. I sometimes
confuse variables with record members in a PASCAL WITH block.

    -- Jon Leech
    jon at cit-vax.arpa
    __@/



More information about the Comp.lang.c mailing list