Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantics... #97

Open
brunotag opened this issue Dec 12, 2021 · 1 comment
Open

Semantics... #97

brunotag opened this issue Dec 12, 2021 · 1 comment

Comments

@brunotag
Copy link

brunotag commented Dec 12, 2021

First of all, awesome work guys, very useful and helpful.

Just a comment about semantics if I may.

Your generic "Visitor" is more like an "Iterator".
The "Visitor" pattern usually doesn't decide how to traverse the tree, that's what an Iterator does.

Yes, your visitors also define an output, but you might wanna separate the two concerns: turn the PreOrder and PostOrder visitors into iterators.
The iterator returns the nodes one by one, and then you can pass them to a visitor that does something on them.

That way you'd decouple the traverse algorithm from whatever operation/processing the visitor wants to do.

Makes sense?

@localheinz
Copy link
Collaborator

@brunotag

Is this related to #81?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants