I have nothing against patterns, but it made it harder to follow, so I stopped reading it.
I have nothing against patterns, but it made it harder to follow, so I stopped reading it.
If you do the whole process in one pass like in C you can use the parser evaluation but even a simple feature like lambdas requires more than one pass.
So either you use a Visitor or you develop pattern matching in your language and bootstrap it rapidly to be able to use you language to write the backend of your language.
Visitor is the only way I know of dealing with it in C++. Once you do it enough, Visitor starts to feel like a pretty natural way to extend a class without modifying the class.
Are you talking about traditonal OOP visitor pattern ? It's pretty terrible, when compared to std::variant ; imagine for instance that you want to have a way to draw the rect that contains a given shape without changing your shape class: https://godbolt.org/g/34KyMw
Visitor is nice when some kind of transformation needs to be applied to the visited objects.
https://www.reddit.com/r/ProgrammingLanguages/comments/7w3oe...
The top comment supported the use of the visitor pattern, but I would say that MOST people in the thread did NOT use visitors.
You only really need a visitor if you have more than one traversal. And even then you don't necessarily need it.