Re: Overloading function calls

Tim Peters (tim@ksr.com)
Thu, 02 Jun 94 04:49:34 -0400

> [marc w]
> I guess it wouldn't be reasonable to suggest something like dispatching
> on both argument types of operators? Maybe we could even invent it; the
> treatment of syntactic operators is already a special case, anyway ;-)
> [and describes a possibly attractive scheme based on <signature,
> implementing_function> pair registration]

> [steve m, points out that neither multi-method nor signature-analysis
> machinery is available to build on]

I agree with everyone!

Marc, a subtext here that should be made explicit is that I'm trying to
vindicate Guido's original intuition (which matches mine) that there's
some relatively _simple_ way to support all this stuff. For me, that
quest is fun for its own sake, & it does appear to be making progress on
some fronts.

But there's no guarantee this will work out, so do feel encouraged to
flesh out another scheme! The only things I'm a fan of in the end are
things that work.

One basic thing you'd need to address is Python's type system:

>>> class Marc: pass
...
>>> class Steve: pass
...
>>> type(Marc) is type(Steve) and type(Marc()) is type(Steve())
1
>>> type(Marc); type(Steve)
<type 'class'>
<type 'class'>
>>> type(Marc()); type(Steve())
<type 'instance'>
<type 'instance'>
>>>

I.e., it's hard to dispatch on a type you can't name <wink>. This hasn't
been seen as a real problem (with enough "hasattr" and .__class__
incantations you can figure out whatever you need to know), but implies
you'd need to a start at a lower level than you might have hoped.

not-sure-i-added-anything-to-what-steve-said!-ly y'rs - tim

Tim Peters tim@ksr.com
not speaking for Kendall Square Research Corp