Overloading methods in C API

Grant Edwards grante at visi.com
Sun Jan 19 00:55:57 CET 2003


In article <3CjW9.13022$xx4.4835 at nwrddc01.gnilink.net>, Carl Banks wrote:

>> The language doesn't allow one to declare the types of function/method
>> parameters.  Therefore function/method overloading is not possible.  In my
>> mind, that can be summarized as "the language doesn't allow it."
> 
> His point is that you can write a function that dispatches on type
> manually, like this:
> 
>     def fn(x):
>         if type(x) == type(1):
>             ...
>         elif type(x) == type([]):
>             ...
> 
> I would call that an overloaded function, even if it isn't technically
> an Overloaded Function (tm).  

Fair enough, but I only call it "overloading" when the dispatching is hidden
and automagical.

-- 
Grant Edwards                   grante             Yow!  Where does it go when
                                  at               you flush?
                               visi.com            




More information about the Python-list mailing list