Hacker News new | ask | show | jobs
by kazinator 2667 days ago
The visitor pattern doesn't disappear under CLOS, but all the framework boilerplate code does.

So that is to say, we can still have a situation where we have a tree of objects T with nodes N of different classes (expression, if-statement, ...) and visitor objects of different classses (pretty-printer, evaluator, ...).

Then given some generic function G and visitor object V, we walk the nodes of the tree, and simply (funcall G N V) for each node N that we encounter.

The remaining verbiage is then in all the method specializations we have to write for G for all the N V combinations that occur.

For all the framework brevity, we yet have an additional flexibility relative to the Visitor Pattern: namely, we can not only vary the choice of visitor object V, but also of G. The Visitor Pattern fixes the generic function in terms of some hard-coded some visit()/accept() protocol.