[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Remarks



    Date: 21 Jan 88 14:28 PST
    From: Dick Gabriel <RPG@SAIL.Stanford.EDU>

    On ADD-METHOD:

	       Since there are ways of getting methods, and moving methods is
	       a reasonable thing to do, I think it is still reasonable to
	       have add-method in chapter 2.

    I know one can get methods, but I thought it was not possible to take a
    method from one generic function and move it to another - that all one
    could do is grab a method, grab its method function, make up a method
    object from that, and then put that on a generic function. The step of
    making the method object is achieved by make-instance of standard-method,
    which is in chapter 3. Therefore, I believe it belongs in chapter 3.

I sort of agree except that there is a simple documented way to create a
method.

(get-method (generic-function (x)
              (:method ((x position))
                (with-slots (x y)
                            position
                  (incf x)
                  (incf y))))
            ()
            (list (class-named 'position)))

Given that method, one could use remove-method and add-method to move it
around.

This example brings up an interesting question.  Should CLtL specify a
way to compile a method function if it is not already compiled?  Sure
one could do:

  (setf (method-function (get-method ..))
        (compile ni (method-function (get-method ..))))

but perhaps we should specify that compile with a method object as its
first (and only) argument compiles that methods function if it is
uncompiled.  Compile with a method as its first argument and a lambda as
its second would compile and install the lambda?
-------