C style
Keith Bostic
keith at seismo.CSS.GOV
Wed Oct 2 14:40:18 AEST 1985
References: <1556 at brl-tgr.ARPA> <139200011 at uiucdcsb>
In article <139200011 at uiucdcsb>, kenny at uiucdcsb.CS.UIUC.EDU writes:
> For Heaven's sake, the big problem with this code is that the conditional
> is quite unreadable in in-line code like this. I'd prefer
while (illegal (ch = getch()))
beep ();
addch (ch);
refresh ();
...
int illegal (ch)
char ch;
{
return ((ch < 1 || ch > 5)
&& ch != 'E');
}
> which at least separates the test from the action. I realize that it also
> moves the test further away physically in the code, but I think the price
> is worthwhile.
It may enhance readability, but it's not worthwhile. You've just managed
to add a context switch per *character*. Now, imagine what that's going to
do to a program like spell. I'm not arguing that everything in the world
should be inline code, but there are still certain real-world limitations
even applications programmers should be aware of.
--keith
More information about the Comp.lang.c
mailing list