logoalt Hacker News

vips7Llast Thursday at 7:56 PM1 replyview on HN

I've always seen the visitor pattern as a poor-mans pattern matching. How do you solve the same thing with callbacks?


Replies

zelphirkaltlast Friday at 2:02 AM

Instead of defining a Visitor interface and then making objects to implement the interface and then passing those objects to whatever traverses a graph or iterates through something, you pass the function, that will be called, by whatever traverses a graph or iterates through something.

show 1 reply