Compilers and programming style (was Re: A question of style)

P E Smee exspes at gdr.bath.ac.uk
Fri Dec 22 21:01:35 AEST 1989


In article <564 at mwtech.UUCP> martin at mwtech.UUCP (Martin Weitzel) writes:
>In article <1989Dec18.113539.10935 at gdt.bath.ac.uk> exspes at gdr.bath.ac.uk (P E Smee) writes:
>
>>though, that someone could put a heuristic into the compiler so that it
>>would be rejected if it is being used because it is 'flash' rather than
>>because it wins something in the context. :-)
>
>Compiler writers look: His smiley tells, he doesn't really mean it!

Well spotted.  Well, really I was only *half* kidding, but Martin is right,
the compiler is not actually the place.  See below.

>There should be other tools than the compiler, to control programming
>style, from 'intelligent' beautifiers to proprietary style checkers,
>but *please* leave the compiler to what K&R and ANSI allows.

Yep.  The compiler should allow anything which is presently legal.  If it
wants to include 'do you really mean it' heuristics, they should only be
applied if you ask for them with some special control argument, and the
default should be not to use them.  (Actually, though, I'd rather see
them in something like an expanded and improved lint, or a totally new
'is-this-sensible' language checker.  How about, maybe, 'cstyle', by
analogy with 'style'?)

A compiler should *never* of its own choice put out gratuitous warnings
about valid constructs, as many places will not allow release of code
unless it compiles with NO messages at all; and because a compiler which
forces you to ignore chatty messages will someday lead you to miss an
important one.

I do think, though, that a compiler which will accept code written to
either of 2 standards (say, K&R-1 and ANSI, or FORTRAN 66 and FORTRAN
77, or whatever) should provide a set of switches so that you can ask
it to enforce compliance with whichever one you prefer.

-- 
Paul Smee, Univ of Bristol Comp Centre, Bristol BS8 1TW, Tel +44 272 303132
 Smee at bristol.ac.uk  :-)  (..!uunet!ukc!gdr.bath.ac.uk!exspes if you MUST)



More information about the Comp.lang.c mailing list