[munich-lisp] multimethods, generic functions, multiple dispatch, ...

Andreas Hauser andy at splashground.de
Sat Sep 10 08:32:56 UTC 2005


Christian.Schuhegger wrote @ Sat, 10 Sep 2005 10:07:09 +0200:
> Andreas Hauser wrote:
> > Christian.Schuhegger wrote @ Sat, 10 Sep 2005 08:58:48 +0200:
> > 
> > You seem to have forgotten to show the actual Lisp code.
> 
> sorry :)
> 
> (defmethod do-shapes-collide-p ((shape1 Triangle) (shape2 Circle))
>    (...))
> (defmethod do-shapes-collide-p ((shape1 Circle)   (shape2 Triangle))
>    (do-shapes-collide-p shape2 shape1))
> (defmethod do-shapes-collide-p ((shape1 Triange)  (shape2 Square))
>    (...))
> ...

And why don't you need:
(defmethod do-shapes-collide-p ((shape1 Circle) (shape2 Triangle))
?

> and what do you do if you talk about vector objects and not pixel objects :)

It must be serialized somewhere (in Object World ?). Do the collision there.

But it seems Java can do methods with different sigantures:


public class foo
{
    public foo()
    {
    }

    public void bar(int i)
    {
        System.out.println(i + 1);
    }

    public void  bar(String s)
    {
        System.out.println(s + " world");
    }

    public static void main(String args[])
    {
        foo f = new foo();
        f.bar(12);
        f.bar("Hello");
    }
}


Andy



More information about the munich-lisp mailing list