Re:Defunctionalisation: An underappreciated tool for writing...
by lidHanteyk on Monday March 09, 2020 @12:18PM
(#22526599)
You're just describing an AST interpreter. Not only do people do this, but it's a reasonable thing to do.
On one hand, it feels similar, especially if the Command class is "sealed".
On the other hand, it feels like completely the opposite since the command classes contain the code they execute and act like lambdas.
I guess you could apply a visitor pattern on top of the command pattern to make it truly like defunctionalization. I hope nobody actually does this.