Python syntax in Lisp and Scheme

Vis Mike visionary25 at _nospam_hotmail.com
Thu Oct 9 03:25:17 EDT 2003


"Erann Gat" <my-first-name.my-last-name at jpl.nasa.gov> wrote in message
news:my-first-name.my-last-name-0810031201410001 at k-137-79-50-101.jpl.nasa.go
v...
> In article <xcvfzi3r2ge.fsf at famine.OCF.Berkeley.EDU>,
> tfb at famine.OCF.Berkeley.EDU (Thomas F. Burdick) wrote:
>
> > > method overloading,
> >
> > How could you have both noncongruent argument lists, and multiple
> > dispatch?
>
> C++ seems to manage it somehow.
>
> #include <stdio.h>
>
> void foo(int x, int y) { printf("1\n"); }
> void foo(double x, int y) { printf("2\n"); }
> void foo(char* x) { printf("3\n"); }
>
> main() {
>   foo(1,2);
>   foo(1.2,2);
>   foo("foo");
> }
>
> compiles and runs without complaint.
>
> E.

Ahh, but overloading only works at compile time:

void foo( SomeBaseObject* object );
void foo( SomeDerivedObject* object );

doesn't work if you're using a base class pointer for all your derived
classes.

Mike






More information about the Python-list mailing list