3 ms·
Ooh Python! Check out https://github.com/mrocklin/multipledispatch https://github.com/mrocklin/multipledispatch which is a little more fleshed out than Guido's
by phunge 10y ago
Ooh Python! Check out https://github.com/mrocklin/multipledispatch https://github.com/mrocklin/multipledispatch which is a little more fleshed out than Guido's implementation. From the author of toolz and dask so you know it's good ;)
I also find that multiple dispatch is something that's occasionally handy, but single dispatch is truly everywhere. I think if you broke down multipledispatch uses in languages which embrace it (e.g. CLOS), the mix is like 95% single, 5% >single. For single dispatch in python, check out https://docs.python.org/3/library/functools.html#functools.singledispatch https://docs.python.org/3/library/functools.html#functools.s... which was added in to the Python 3.4 stdlib. The alternative is the OOP subclassing style, which works but IMHO isn't very readable.
- raiph 10y agoMD in Perl 6 is beyond "occasionally handy". A glance at the Perl 6 setting modules[1] revealed something like a 50/50 break down of SD vs MD. Operators in Perl 6 are all MD, so that's likely a significant factor. Additionally it is well designed. While the functionality starting point was CLOS, the UX has the benefit of hindsight and a decade of non-stop language evolution. [1] https://github.com/rakudo/rakudo/tree/nom/src/core https://github.com/rakudo/rakudo/tree/nom/src/core