Subject: Re: Time to update KNF?
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Andrew Brown <atatat@atatdot.net>
List: tech-kern
Date: 01/19/2000 15:41:36
>It's not, really, because it - or any mechanical reformatting, for that
>matter - destroys violations of the rules that improve readbility.
totally!
>And yes, such things exist. Consider as a simple example
>
> else if (!strcmp(*av,"-debug"))
> { WANTARG();
> if (!strcasecmp(av[skip],"none")) plevel = P_NONE;
> else if (!strcasecmp(av[skip],"warn")) plevel = P_WARN;
> else if (!strcasecmp(av[skip],"note")) plevel = P_NOTE;
actually...i'd make that
if (!strcasecmp(av[skip],"none")) plevel = P_NONE;
else if (!strcasecmp(av[skip],"warn")) plevel = P_WARN;
else if (!strcasecmp(av[skip],"note")) plevel = P_NOTE;
and then my editor would be much happier. it also looks better to me.
each line begins in the same place. i just moved the whitespace.
>versus what you get if you run that inner if construct through anything
>mechanical. At the very least it will destroy the alignment of the
>then-clauses (which in this case is perhaps not a big deal, but I have
>written cases where making everything line up makes a big difference; I
>just couldn't find one in thirty seconds or so). It'll also pull the
>first if over to the left, thereby obscuring the parallel structure
>even more.
it could be worse. you could insist on
if (!strcasecmp(av[skip],"none"))
plevel = P_NONE;
else
if (!strcasecmp(av[skip],"warn"))
plevel = P_WARN;
else
if (!strcasecmp(av[skip],"note"))
plevel = P_NOTE;
so that the if (clause) and the else have nothing else on their lines.
theyn you're screwed. indenting by 8 then reaches critical mass very
quickly. this is certainly a quick rudimentary style, but very
defendable based on the simplicity of the rules.
--
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
andrew@crossbar.com * "information is power -- share the wealth."