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

Method and Generic Function internal names



   From: konstan@hermes.Berkeley.EDU (Joe Konstan)
   (defun get-setf-function-name (name)
     (or (gethash name *setf-function-names*)
	 (setf (gethash name *setf-function-names*)
	       (intern (let* ((pack (symbol-package name))
			      (pack-name (package-name pack))
			      (plain-name (symbol-name name))
			      (*package* (or pack *the-pcl-package*))
			      (*print-case* :upcase)
			      (*print-gensym* t))
			     (format nil "SETF ~A::~A"
				     pack-name
				     plain-name))
		       *the-pcl-package*))))

The SYMBOL-PACKAGE in you version will fail if NAME is an uninterned symbol.
Although your code probably won't name functions using gensyms, you can't safely
assume code in other loaded systems won't do it somewhere.

There are other potential problems which are unlikely to happen unless you use
"unreasonable" package or symbol names, for instance those that contain double
colons in the package or symbol name.  Your function will confuse these two
distinct symbols

   |one::two|::three
   one::|two::three|

because both will print as one::two::three.