Visitor pattern. Is void* an acceptable return type for a completely abstract interface?
I have an AST, represented in the usual way (a tree of nodes of an abstract type). I have several uses cases for traversing this tree (an optimizer, which returns another AST; IR code generation, which returns a llvm::Value* ; and a debug analyzer, which simply outputs to stdout and returns nothing). A visitor feels like the right way to go here, but the differing return types through each use case of the visitor make it hard to see how to implement an interface for this. I considered this: class Visitor; class ASTNode { public: virtual void accept(Visitor *visitor); }; class Visitor { public: