our friend "{"

stephen at alberta stephen at alberta
Thu Aug 4 01:58:59 AEST 1983


   The original reason for the following definitions was that my
first ever C program was written on an IBM machine where the
squirley braces were quite the pain to use and where the C
compiler refuses to work.
   Since I wasn't all to sure where the problem was, I wrote the
program using ALGOL/68 constructs and put in the #defines with
what I thought were the corret formats and passed the program to
a friend on the VAX (which I didn't have access to at the time).
  Once I got onto UNIX, I found that the constructs served to
minimize syntax errors and make my programs easier to read.

   The main problem with the constructs is that they are not
understood by "emacs", "cb" etc..
-------------------------------------------------------------

#define begin {
#define end }

#define IF if(
#define THEN ){
#define ELSE } else {
#define ELIF } else IF
#define FI }

#define FOR for(
#define WHILE while(
#define DO ){
#define OD }

#define LOOP do{
#define UNTIL } while(
#define DONE );

#define SWITCH switch(
#define IN ){
#define CASE ;break ;case
#define DEFAULT ;break ; default
#define OUT }
	
#define FOREACH(PARC,PARV,COUNT)\
	for(COUNT = (PARC > 1 ?  0 : --PARV, -1) ; ++COUNT == 0 | (++PARV, --PARC > 0 ; )\

#ifndef DO
#define DO ){
#define OD }
#endif

#define PARNUM(NUM,PARV,COUNT) (PARV+NUM-COUNT)
#define FORNEXT(PARC,PARV,COUNT) (++COUNT, ++PARV, --PARC)
/* PARNUM returns the NUM'th par. FORNEXT moves to the next par */

-----------------------------------------------------------------

   FOREACH was defined to help handle shell pars with a minimum
of fuss. PARC and PARV are (copies of) the values passed by the
shell and COUNT is used to indicate which par is presently
"active" (COUNT==0 indicates no pars).

              Stephen Samuel(alberta!stephen)



More information about the Comp.lang.c mailing list