This is a compromise. Let me give you an example. I came across differential execution technique in 1985, and I find this to be a really good tool for programming user interfaces. Basically, this requires simple structured programs:
void Foo(..args..){ x = y; if (..some test..){ Bar(arg1, ...) } while(..another test..){ ... } ... }
and mucks with a management structure like this:
void deFoo(..args..){ if (mode & 1){x = y;} {int svmode = mode; if (deIf(..some test..)){ deBar(((mode & 1) arg1 : 0), ...) } mode = svmode;} {int svmode = mode; while(deIf(..another test..)){ ... } mode = svmode;} ... }
Now a really good way to do this is to write a parser for C or any other base language, and then go through the parse tree, generating the code I want. (When I did this in Lisp, this part was simple.)
But who wants to write a parser for C, C ++ or something else?
So, instead, I just write macros to write code like this:
void deFoo(..args..){ PROTECT(x = y); IF(..some test..) deBar(PROTECT(arg1), ...) END WHILE(..another test..) ... END ... }
However, when I do this in C #, some of their wisdom decided that the macros were bad and I donβt want to write a C # parser, so I have to do the code generation manually. This is a royal pain, but it is still worth what can be compared to the usual way of encoding these things.
Mike dunlavey
source share