Path: utzoo!attcan!uunet!lll-winken!uwm.edu!psuvax1!news From: flee@dictionopolis.cs.psu.edu (Felix Lee) Newsgroups: comp.lang.c Subject: Re: more on TRUE and FALSE (side-comment) Message-ID: Date: 17 Sep 90 17:01:23 GMT References: <9@christmas.UUCP> Sender: news@cs.psu.edu (Usenet) Organization: Penn State Computer Science Lines: 22 Nntp-Posting-Host: dictionopolis.cs.psu.edu >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@cs.psu.edu