Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

11
  • In OOP, I'd say the key determinant is whether you want polymorphism or not. The a in a.m(b, c) is not equal to the a in f(a, b, c). It (solely) determines the implementation of m that gets invoked. Commented Mar 22, 2023 at 3:01
  • @Alexander You can have a scheme where b and/or c get a say in it too. Commented Mar 22, 2023 at 15:44
  • @Caleth Yep, you can hand-roll single (or even multiple) dispatch with a plain function, but the point I was trying to convey is that most OOP languages give privileged behaviour to the a in a.m(b, c), in that it gets single-dispatch automatically without you needing to hand roll anything. Commented Mar 22, 2023 at 16:28
  • @Alexander I meant you can do multiple dynamic dispatch with OO, and dispatch on the static types of a, b, c is still polymorphic Commented Mar 22, 2023 at 16:31
  • @Caleth I'm not sure what you mean. Are you referring to how if you have function overloads all called f, that accept different types, that calling them with a, b, c will pick the correct one according to their static types? That's "ad hoc polymorphism". That's not "multiple dynamic dispatch," because it happens at compile-time, based only on static types, without any runtime consideration of the concrete types being used. I was talking about runtime polymoprhism ("subtype polymorphism"). Commented Mar 22, 2023 at 16:38