[ANN] Multimethod.py -- multimethods for Python
Carl L. Gay
sigue at thecia.net
Mon Jan 17 15:25:49 EST 2000
Martin von Loewis wrote:
>
> Doug Hellmann <doughellmann at home.com> writes:
>
> > How is this different from function overloading, as implemented in C++?
> > I'm not a C++ user, but my impression is the effect would be the same.
> > Is that the point?
>
> No. Function overloading in C++ is a static thing. You look at the
> static types, and at all statically visible methods, and then chose
> the "best" one (in C++, this considers conversions from argument types
> to parameter types as well).
>
> In multi-methods, lookup is dynamic. You don't do anything statically,
> but defer all decisions to run-time. Then, you care only about the
> dynamic types of the arguments.
I may be taking this post out of context because I didn't see
the previous posts in this thread, but taken on its own the
last paragraph is a bit of an overgeneralization, at least if
intended to refer to more than just Python. In Dylan, for
example, the compiler is frequently able to resolve multi-method
dispatch at compile time if there is enough type information
provided by the programmer. But everything _is_ defined in
terms of run-time semantics, so the effect is the same, modulo
speed.
My apologies if I've taken you out of context.
-Carl (who doesn't normally read this newsgroup)
More information about the Python-list
mailing list