#define OR ||

Richard Nuttall richard at torch.co.uk
Sat Feb 10 02:10:55 AEST 1990


wittig at gmdzi.UUCP (Georg Wittig) writes:

<macros defines deleted>

>	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 at torch.co.uk
Torch Technology, Great Shelford,     |    Tel : +44 223 841000 X 308
Cambridge, CB2 5LQ, England           |    Fax : +44 223 840223



More information about the Comp.lang.c mailing list