Pascal Costanza | 6 Sep 2009 22:39

Weird CLOS MOP behavior

Hi,

This is on Allegro 8.1 on Mac OS X.

Assume I have the following definitions:

(use-package :clos)

(defclass my-generic-function (standard-generic-function)
   ()
   (:metaclass funcallable-standard-class))

(defmethod compute-discriminating-function ((mf my-generic-function))
   (let ((disc (call-next-method)))
     (lambda (&rest args)
       (print args)
       (apply disc args))))

(defgeneric foo (x y z)
   (:method (x y z) (+ x y z))
   (:generic-function-class my-generic-function))

If I load and test these definitions, I get the following output:

CL-USER(1): (load "clos-test")
; Fast loading /Users/costanza/Muell/clos.fasl

(#<Closure (:INTERNAL
             (METHOD COMPUTE-DISCRIMINATING-FUNCTION
              (MY-GENERIC-FUNCTION))
             0)
     <at>  #x1000aa8bb2>)
T
CL-USER(2): (foo 4 5 6)

(4 5 6)
(#<Function (METHOD FOO (T T T))>)
15
CL-USER(3): (foo 4 5 6)

(4 5 6)
15

Does anybody have an idea where the internal closer and functions come  
from that seem to be passed to the discriminating function? Is there a  
way to suppress that? This makes it hard to write portable extensions  
of generic functions...

Thanks a lot for any hints...

Pascal

--

-- 
Pascal Costanza, mailto:pc <at> p-cos.net, http://p-cos.net
Vrije Universiteit Brussel
Software Languages Lab
Pleinlaan 2, B-1050 Brussel, Belgium


Gmane