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

>the "vtable" (the dictionary of functions) being passed around isn't virtual and is provided per type, not per instance.

This might be nitpicking but vtables in C++ are created per type with instances having a pointer to it.



it is not nitpicking, you are correct to point it out. The only difference is where the vtable is attached to: pointers in Haskell, objects instances in c++.

Although the language does not offer a builtin syntax for it, in C++ is also common to attach the 'vtable' to the 'handle' (a smart pointer or deep copying envelope), in the case of type erased wrappers (std::function, std::any, etc).




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

Search: