From: Pascal Costanza
Subject: Discriminating functions
Date: 
Message-ID: <ckubtc$6fo$1@newsreader2.netcologne.de>
Hi,

This is a question related to the CLOS MOP.

I am trying to understand what a discriminating function has to do once 
an effective method has been determined by compute-effective-method. 
Let's assume we have a generic function #'some-fun with arguments (a b c 
&optional d &rest args). (No special reason why to have optional and 
rest arguments here, I am just trying to avoid oversimplifications.)

The discriminating function should roughly look as follows, AFAICS:

(lambda (a b c &optional d &rest args)
   (let ((<org-args> (list* a b c d args)))
     (macrolet ((call-method (method &rest args)
                  `(funcall (method-function ,method) <org-args> ,@args))
                (make-method (form)
                  (multiple-value-bind
                      (method-lambda more-args)
                      (make-method-lambda
                       #'some-fun
                       (class-prototype
                        (generic-function-method-class #'some-fun))
                       `(lambda (a b c &optional d &rest args)
                          (let ((<org-args> (list* a b c d args)))
                            ,form)))
                    `(make-instance
                      (generic-function-method-class #'some-fun)
                      :qualifiers ()
                      :specializers (mapcar #'find-class '(t t t))
                      :lambda-list '(a b c &optional d &rest args)
                      :function ,method-lambda
                      ,@more-args))))
       effective-method)))

I have omitted the code that looks up the effective method. <org-args> 
should of course be an uninterned symbol. I am mostly concerned about 
the correctness of call-method and make-method here. 
(compute-effective-method returns a form that may have calls to 
call-method and make-method which are specified to be local macros in ANSI.)

Is this roughly correct?


Pascal

-- 
Tyler: "How's that working out for you?"
Jack: "Great."
Tyler: "Keep it up, then."