Method overloading?

placid Bulkan at gmail.com
Thu Feb 15 18:23:18 EST 2007


On Feb 16, 3:37 am, Neil Cerutti <horp... at yahoo.com> wrote:
> On 2007-02-15, Steven D'Aprano <s... 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".

This what i was asking.

>
> What Python provides is dynamic polymorphism of names with
> single-dispatch.
>
> I think. ;-)
>
> --
> Neil Cerutti

Thank you all for the information.





More information about the Python-list mailing list