declaring multimethods [Was: Re: PEP 318]

Michele Simionato michele.simionato at
Thu Mar 25 09:29:18 CET 2004

Skip Montanaro <skip at> wrote in message news:<mailman.348.1080142389.742.python-list at>...
> Still, I'd like to follow this thread just a little further, mostly just to
> see where it goes.  <snip>

As Ville Vainio pointed out in another thread, maybe the source of
the confusion is that we have in mind CLOS-style multimethods, 
implemented as generic functions *outside* classes.
Here is an example, taken from the Goops manual,

(define-method (+ (x <string>) (y <string>))
  (string-append x y))

(+ 1 2) --> 3
(+ "abc" "de") --> "abcde"

In Guile "+" is a generic function and the define-method macro just
adds another method to the list of methods known by "+". 
Yes, there is a little ambiguity since typically "def" means "define"
and not "add to the definition", but since practicality beats purity ...


More information about the Python-list mailing list