4 ms·
> If you instead use visitor pattern, you will be looking at all the code related to Variable, Function, Literal in those files respectively. I've never organi
by Jtsummers 1y ago
> If you instead use visitor pattern, you will be looking at all the code related to Variable, Function, Literal in those files respectively.
I've never organized visitor pattern code that way. Usually it's something like:
TypeChecker
visitFunction
visitVariable
visitLiteral
PrettyPrinter
visitFunction
visitVariable
visitLiteral
So related functions (across the types you're visiting) are kept together, you're not revisiting the Function module to add a new visitor there. That would almost defeat the purpose of the pattern.
https://en.wikipedia.org/wiki/Visitor_pattern https://en.wikipedia.org/wiki/Visitor_pattern - See the UML diagram here.