more on TRUE and FALSE (side-comment)
Felix Lee
flee at dictionopolis.cs.psu.edu
Tue Sep 18 03:01:23 AEST 1990
>Personally I hate 'writing' programs with :
> if (strcmp(name,"hippo")==0) ....
Try writing this instead:
IF(strcmp(name, "hippo"), L10, L20, L10)
L10: printf("%s is not a hippo\n", name);
GOTO(L30)
L20: printf("a hippo\n");
GOTO(L30)
L30: CONTINUE
And here are the macros that make it possible:
#define IF(e,a,b,c) {int _=(e);if(_<0)GOTO(a)else if(_>0)GOTO(c)else GOTO(b)}
#define GOTO(x) goto x;
#define CONTINUE ;
Exercise for the reader:
* The printf statements are ugly. Define FORMAT and WRITE statements.
You will probably need functions (in addition to/instead of) macros.
--
Felix Lee flee at cs.psu.edu
More information about the Comp.lang.c
mailing list