Ignore:
Timestamp:
10/13/03 18:43:41 (20 years ago)
Author:
piso
Message:

ADD-METHOD, REMOVE-METHOD: return generic function, not method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/defclass.lisp

    r4349 r4350  
    22;;;
    33;;; Copyright (C) 2003 Peter Graves
    4 ;;; $Id: defclass.lisp,v 1.22 2003-10-13 14:12:26 piso Exp $
     4;;; $Id: defclass.lisp,v 1.23 2003-10-13 18:43:41 piso Exp $
    55;;;
    66;;; This program is free software; you can redistribute it and/or
     
    908908    method))
    909909
    910 ;;; add-method
    911 
    912 ;;; N.B. This version first removes any existing method on the generic function
    913 ;;; with the same qualifiers and specializers.  It's a pain to develop
    914 ;;; programs without this feature of full CLOS.
    915 
    916910(defun add-method (gf method)
    917   (let ((old-method
    918          (find-method gf (method-qualifiers method)
    919                       (method-specializers method) nil)))
    920     (when old-method (remove-method gf old-method)))
     911  ;; Remove existing method with same qualifiers and specializers (if any).
     912  (let ((old-method (find-method gf (method-qualifiers method)
     913                                 (method-specializers method) nil)))
     914    (when old-method
     915      (remove-method gf old-method)))
    921916  (setf (method-generic-function method) gf)
    922917  (push method (generic-function-methods gf))
     
    924919    (pushnew method (class-direct-methods specializer)))
    925920  (finalize-generic-function gf)
    926   method)
     921  gf)
    927922
    928923(defun remove-method (gf method)
     
    935930          (remove method (class-direct-methods class))))
    936931  (finalize-generic-function gf)
    937   method)
    938 
    939 (defun find-method (gf qualifiers specializers
    940                        &optional (errorp t))
     932  gf)
     933
     934(defun find-method (gf qualifiers specializers &optional (errorp t))
    941935  (let ((method
    942936         (find-if #'(lambda (method)
     
    947941                  (generic-function-methods gf))))
    948942    (if (and (null method) errorp)
    949         (error "No such method for ~S." (generic-function-name gf))
     943        (error "no such method for ~S" (generic-function-name gf))
    950944        method)))
    951945
Note: See TracChangeset for help on using the changeset viewer.