my first guess is that the GOOPS method combinator accepts the
(. args) method and proceeds to do strange things instead of giving an 
error message (as it should, because you introduce an ambiguity into
the dispatch).

anyway, here is a variant of your code that will work:

(use-modules (oop goops))

;;; an abstract vector class (numbers are a special case)
(define-class <Vector> ())

;;; vector addition
(define-generic vector+)

(define-method vector+ (arg)
  arg)

(define-method vector+ ((x <number>) (y <number>))
  (+ x y))

(define-method vector+ ((x <Vector>) (y <Vector>))
  (error "has to be implemented for each nontrivial vector type"))

;;; method for arbitrary arguments.
(define-method vector+ (first second third . rest)
  (vector+ first
           (apply vector+ second third rest)))

Reply via email to