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

That's a neat feature! So my aside about single dispatch was misplaced.

What I'm really after though is somewhat the opposite, which is static dispatch so that the functions called are known at compile time and can be optimized that way (I do a lot of numerics coding), so avoiding any method resolution lookup and even the vtable jumps and resulting target mispredicts. That's a nice feature of both type classes and ML's module system as usually implemented in functional languages. One really nice thing is they can also typically "dispatch" statically on return types of functions too which makes for some neat patterns as well using type inference.

Anyway thanks for pointing to that. It definitely beats the visitor pattern as is necessary in Java. And I assume it would work for more than two parameters too, which is another advantage over standard visitor.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: