zlacker

[parent] [thread] 2 comments
1. the_du+(OP)[view] [source] 2025-12-13 19:21:13
What you are saying is: no, it doesn't.

Of course dynamic dispatch can be implemented in almost every language. The Linux kernel uses dynamic dispatch with C!

But that's a hack, not a language feature.

replies(2): >>lpil+x >>array_+K21
2. lpil+x[view] [source] 2025-12-13 19:24:59
>>the_du+(OP)
I think you might mean “ad hoc polymorphism” rather than “dynamic dispatch”. Gleam, C, Erlang, etc have the latter, not so much the former.
3. array_+K21[view] [source] 2025-12-14 06:06:51
>>the_du+(OP)
It's not a "hack" because many language DO NOT let you store functions with state. Gleam does, I write PHP, and that does as well.

PHP has interfaces and whatnot, but a lot of the time I do polymorphism by just having a class that has Closure members. When you can arbitrarily pass around functions like that, it's basically equivalent to an interface or abstract class, with a bit more flexibility.

[go to top]