gday folks.
first i will say i am do not consider myself well versed in machine
languages. i have use plain tex for a while, and i use the odd bit of
sh, sed, etc. i recently read K&R because sh disgusts me. i have seen
a bit of some programming languages, but nothing very recent, and i
cant say C or most any other language i have seen seem very sensible.
i am have an account on a timesharing system in the CS school, but
otherwise have nothing to do with them or any computer scholars.
i have seen much comment from openbsd developers about bad C style.
i would be thankful to see examples of `good' style, in case i wish to
write some C for OpenBSD. (right now i am interested in fixing some
bugs in vi.)
also are there places for discussing such things, suitable for a newbie?
cheers,
reuben.
p.s. one particular question i have is on the mandoc/main.c:
i found the following:
if (strcmp(progname, BINM_MAN) == 0)
search.argmode = ARG_NAME;
else if (strcmp(progname, BINM_APROPOS) == 0)
search.argmode = ARG_EXPR;
else if (strcmp(progname, BINM_WHATIS) == 0)
search.argmode = ARG_WORD;
else if (strncmp(progname, "help", 4) == 0)
search.argmode = ARG_NAME;
else
search.argmode = ARG_FILE;
much more readable as:
search.argmode =
strcmp(progname, BINM_MAN) == 0 ? ARG_NAME :
strcmp(progname, BINM_APROPOS) == 0 ? ARG_EXPR :
strcmp(progname, BINM_WHATIS) == 0 ? ARG_WORD :
strncmp(progname, "help", 4) == 0 ? ARG_NAME :
ARG_FILE;
a style i came up with in imitation of some disgusting haskell code.
any comments?
---
ANSI 'K'&'R' is really just 'B' in disguise.
No comments:
Post a Comment