Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!linus!philabs!cmcl2!seismo!brl-tgr!tgr!lcc.niket@locus.ucla.edu From: lcc.niket@locus.ucla.edu (Niket K. Patwardhan) Newsgroups: net.lang.c Subject: Re: Typedef Message-ID: <592@brl-tgr.ARPA> Date: Sat, 10-Aug-85 02:30:12 EDT Article-I.D.: brl-tgr.592 Posted: Sat Aug 10 02:30:12 1985 Date-Received: Mon, 12-Aug-85 07:35:49 EDT Sender: news@brl-tgr.ARPA Lines: 38 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!