Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!mcsun!ukc!stc!datlog!torch!richard From: richard@torch.co.uk (Richard Nuttall) Newsgroups: comp.lang.c Subject: Re: #define OR || Message-ID: <608@torch.co.uk> Date: 9 Feb 90 15:10:55 GMT References: <5940014@hpcupt1.HP.COM> <33889@ucbvax.BERKELEY.EDU> <1922@gmdzi.UUCP> Organization: Torch Technology Ltd., Cambridge, England Lines: 53 wittig@gmdzi.UUCP (Georg Wittig) writes: > Similar macros I use for the different types of loops. The advantages > are: > - ``IF'' is close enough to ``if'', so it can be understood easily. > - The programmer cannot forget the ``{}'' in the then-part or in the > else-part. > - ``END_IF'' clearly says *what* is finished --- ``}'' doesn't. > The programmer only has to remember: ``IF -- END_IF'' is the secure way > of saying ``if'' --- no problems with {}. > (Please don't tell me that ``END_IF'' are 5 keystrokes more than ``}''. > I hope those times are gone forever.) > I know I can't use bc or indent or the electric c mode of emacs any > more; but I consider that a weakness of those tools :-) > BTW, I often have to use machines and operating systems that don't have > those tools at all. So why worry too much? :-) But *every* system has a > tool called C preprocessor! Rather than defining the macros in C, use your editor to define the macros, so that when you type IF, it inserts (for example) if (X) { } /* end if */ putting your cursor at the X. ELSE can be defined to be } else { X and so on. This has the same 4 'advantages' you quote and doesn't have the disadvantages you mention. In addition, other people can now read your code. -- Richard Nuttall | stc!datlog!torch!richard Manager, X Technology | richard@torch.co.uk Torch Technology, Great Shelford, | Tel : +44 223 841000 X 308 Cambridge, CB2 5LQ, England | Fax : +44 223 840223