Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wasn't really familiar with this term, but as another comment here said, the only language I use that doesn't have such late binding/dynamic dispatch is C

i.e. it seems natural in Python and C++ (and Java and Rust …)

But I did notice the term "open recursion" in Siek's Essentials of Compilation - https://mitpress.mit.edu/9780262048248/essentials-of-compila...

To make our interpreters extensible we need something called "open recursion", in which the tying of the recursive knot is delayed until the functions are composed. Objected-oriented languages provide open recursion via method overriding

---

I mentioned that here too, on a thread about a type checker: https://news.ycombinator.com/item?id=45151620

To me the open recursion style clearly seems like a better default than VISITORS?

You can still REUSE traversal logic, and you don't "lose the stack", as I pointed out in the comment below: https://news.ycombinator.com/item?id=45160402

Am I missing something? I noticed there is a significant disagreement about style, which seems to not have a clear rationale: MyPy uses visitors all over, while TypeScript uses switch statements

This is a big difference! It affects nearly every line of code, and these projects have a ton of code ...





> the only language I use that doesn't have such late binding/dynamic dispatch is C

It's not that it doesn't support this, it is just explicit.


Also, I’m not 100% sure, but maybe Standard ML doesn’t support the open recursion pattern, but say OCaml does (?). So it could be a relevant distinction in that respect



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: