4 ms·
Python's single dispatch just means that if I do `foo.bar()`, the meaning of bar depends on the type of `foo`. So that is not recent, but a core part of the lan
by jakobnissen 5y ago
Python's single dispatch just means that if I do `foo.bar()`, the meaning of bar depends on the type of `foo`. So that is not recent, but a core part of the language.
Another difference to Python is that you can't add new methods post-hoc to types in Python. That's a big problem, but this has nothing to do with single/multiple dispatch. E.g. Rust has single dispatch but allows post-hoc methods.
- Doxin 5y ago> you can't add new methods post-hoc to types in Python Unless I'm misunderstanding what that means, you totally can: >>> class Foo: ... def bar(self): ... return 3 ... >>> foo = Foo() >>> foo.bar() 3 >>> Foo.baz = lambda self: 6 >>> foo.baz() 6 >>>
- danmur 5y agoSo just to clarify since it perhaps wasn't clear, I'm talking about singledispatch from the standard library: https://docs.python.org/3/library/functools.html#functools.singledispatch https://docs.python.org/3/library/functools.html#functools.s...
- dragonwriter 5y ago> Another difference to Python is that you can't add new methods post-hoc to types in Python. Yes, you can. Heck, you can post-hoc add new methods to instances in python, too.