From: Clint Hyde
Subject: RE: generic functions to redefine builtin functions - how ?
Date: 
Message-ID: <40arhq$av@info-server.bbn.com>
is it easier in CLOS? well, no.

you can't overload operators like + to accept your defclasses as args.

almost (exactly?) none of the built-in operators are generic functions,
so they can't be overloaded. this is at times a shame, but you can
accomplish the same thing with your own package and then creating your
own defmethods.

that being said, you could do easily as you described and create your
own package, and define your own + function, being careful to call cl:+
when you actually had numbers and only numbers to add.

(defpackage test (:shadow +))

(in-package :test)

(progn 
  (defclass apple  () ())
  (defclass banana () ())

  (defmethod + ((arg1 apple) (arg2 banana))
    'orange)

  (let ((a (make-instance 'apple))
        (b (make-instance 'banana)))
    (+ a b))
  )

 --> test::ORANGE

(defmethod + ((arg1 number) (arg2 number))
  (cl:+ arg1 arg2)
  )

(+ 3 4)

 --> 7

 -- clint