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

intern-function-name



The result returned by intern-function-name should be independent of
the current value of *package* (at least when invoked with names used by the PCL system).
(In fact, the result should depend only on the argument to intern-function-name.)
Otherwise, operations which depend on intern-function-name returning the same symbol 
might not work.  

TRACE-METHOD is an example of a function that depends on the value
returned by intern-function-name and that might be called when 
the value of *package* has changed from its value at method definition time.

The form (format nil "~S" name) uses the value of *package*.
A better definition of intern-function-name is:

;;; I assume that the function-names used by the PCL system are either symbols,
;;; or lists beginning with METHOD.
(defun intern-function-name (name)
  #+Symbolics name
  #-Symbolics (cond ((symbolp name) name)
		    ((listp name)
		     (let ((*package* (if (eq (car name) 'method)
					  (symbol-package (if (listp (cadr name))
							      (cadr (cadr name))
							      (cadr name)))
					  *package*)))
		       (intern (format nil "~S" name))))))

This still isn't quite right if one wants to prevent symbols from being interned
in some package(s) (the LISP package, for example).  If this matters, something like
the following definition could be used:

;; the assumption mentioned above doesn't matter in this definition.


(defvar *name-package* (or (find-package "NAME")
			   (make-package "NAME" :use nil)))

(defun intern-function-name (name)
  #+Symbolics name
  #-Symbolics (cond ((symbolp name) name)
		    ((listp name)
		     (let ((*package* *name-package*))
		       (intern (format nil "~S" name))))))