Steven>Look at the examples in the wikipedia page you link to

Let me please copy Wikipedia for you.
I agree it is not that easy to spot, however, please pay attention to
Car#accept method.

class Car {
...
    @Override
    public void accept(CarElementVisitor visitor) {
        for (CarElement element : elements) {
            element.accept(visitor);
        }
        visitor.visit(this);
    }
}

The notable difference is that Wikipedia suggests that Car is in charge of
enumerating Car elements.
Of course, trivial car elements just call visitor.visit(this).
However, compound elements should call the visitor and do re-composition or
whatever.

CarElementPrintVisitor in Wikipedia does **not** enumerate Car's elements.
There's no CarElementPrintVisitor#visitElements

In other words, if we want Visitor Pattern, we need to move
RelShuttleImpl#visitChildren(RelNode rel)
into the **default** implementation of RelNode#accept(RelShuttle)

However, as I said, if we consider moving towards the proper visitor
pattern, we might consider
the approach listed in "From Object Algebras to Finally Tagless
Interpreters" article above.

Vladimir

Reply via email to