function overloading

laotseu bdesth at removethis.free.fr
Sat May 24 19:28:25 EDT 2003


Jay O'Connor wrote:
> On Sat, 24 May 2003 17:33:10 +0200, Mirko Koenig <koenig at v-i-t.de>
> wrote:
> 
> 
> 
>>Is it not possible in python to overload fucntion with the same name?
>>How do you do it?
> 
> 
> Function overloading tends not to work in dynamically bound languages.

<HS>
Have a look on multidispatch (generic) methods in CLOS, which is a 
dynamically bound language. It works, and it's really some kind of 
function overloading !-)

> In C you can have
> 
> int myFunc (int a) {};
> int myFunc (char* a) {};
> 
> and the compiler can tell by the types involved which function to
> call.

No you can't. Try to compile this and you'll get two errors :
- conflicting types for 'myFunc'
- previous declaration of 'myFunc'

Your example would work in C++, but C and C++ are two different languages...
</HS>

Laotseu





More information about the Python-list mailing list