Typedef
Niket K. Patwardhan
lcc.niket at locus.ucla.edu
Sat Aug 10 16:30:12 AEST 1985
Re:
#define variable function()
#define field ptr->fld
I most certainly abhor such constructs! When you want to know precisely what
a piece of code does, the occurrence of such things makes it practically
impossible. Ever tried debugging a device driver that has function calls
macroed, especially when the macro definitions happen to be in an include
file somewhere? INTELs XENIX drivers arre full of it and horribly buggy!
Yeah yeah! the code looks pretty! but I dont know exactly what it does!
What do you mean by readable anyway? Easy to understand precisely? Easy to
look at? Easy to get the general idea? A program should have it all ways,
if possible.
I would suggest the following:
Easy to get the general idea ---- use comments!
Easy to get the precise operation: -- Use only standard conventions, dont
redefine the language! When you need to compact a complicated mess into
something one can hold in his head, make sure you provide an alert that it is
a user defined something. This way if a reader runs across it
he knows he is supposed to look it up. If it has side effects use something
with () ---- that is the language defined way of packaging complicated side
effects!
Easy to look at: Use a decent {} convention and be consistent. Keep functions
on one page if possible and use the paging control (^L if you dont have
anything better). And for god's sake get rid of those nit picking comments
and stick them where they belong - in the dust at the bottom of your
whiteboard. If there are comments indicating the general
idea of what is going on, keep them well separated from the code, preferably
preceding it in one contiguous blotch, since there usually isn't enough space
and is too difficult to nmaintain in a well separated blotch to the right of
the code! If you insist on putting it there take the trouble to line up
the start of all the comments and to fill the space!
More information about the Comp.lang.c
mailing list