Method overloading?

Neil Cerutti horpner at yahoo.com
Thu Feb 15 11:37:18 EST 2007


On 2007-02-15, Steven D'Aprano <steve at REMOVEME.cybersource.com.au> wrote:
>> def multiAccept( argOfVariousTypes ):
>>     if isinstance(argOfVariousTypes,int):
>>         # treat like an int
>>     elif isinstance(argOfVariousTypes,float):
>>         # treat like a float
>>     elif isinstance(argOfVariousTypes,(list,tuple)):
>>         # treat like a container
>
> Is that really called "overloading"? I've never (knowingly)
> come across the term being used in that context before. I've
> always known that as "multiple dispatch" or "polymorphism",
> depending on whether you or the compiler handles the
> dispatching.

It's due to vague terminology that we're using.

What the OP wanted to know about was static polymorphism of names
based on function signatures, often refered to informally in the
context of C++ as "function overloading", though it's really
"identifier overloading where identifier refers to a function or
member function".

What Python provides is dynamic polymorphism of names with
single-dispatch.

I think. ;-)

-- 
Neil Cerutti



More information about the Python-list mailing list