The Rewrite Tool is not dynamic. Perhaps this is the key? But I could imagine a Smalltalk function that takes a method, applies a Rewrite Tool syntactic transformation to its source, compiles the method as a Block, then calls this Block with the arguments that would've been send to the original method.
Something like:
perform: methodName
with: arguments
rewriting: aMatchingPattern
as: aRewritePattern
Where aMatchingPattern would be something like: ``@rcv
ifTrue: `Block1
ifFalse: `Block2
Then aRewritePattern could be something like: "Order of Blocks reversed"
``@rcv
ifTrue: `Block2
ifFalse: `Block1
Just be careful to cache the result of the compilation by method name and Class, and this wouldn't be too much slower than a conventional #perform:This particular example would let you dynamically call any method, but with all of the if-then-else equivalents with the then and else clauses swapped.
Would this constitute Smalltalk Macros?