(oset symbol "package" *common-lisp-package*)
(oset symbols (symbol-name symbol) symbol)))
- (defun %find-symbol (name package)
+ (defun find-symbol (name &optional (package *package*))
(let* ((package (find-package-or-fail package))
(symbols (%package-symbols package)))
(if (in name symbols)
- (cons (oget symbols name) t)
- (dolist (used (package-use-list package) (cons nil nil))
+ (values (oget symbols name) t)
+ (dolist (used (package-use-list package) (values nil nil))
(let ((exports (%package-external-symbols used)))
(when (in name exports)
- (return (cons (oget exports name) t))))))))
-
- (defun find-symbol (name &optional (package *package*))
- (let ((x (%find-symbol name package)))
- (if (cdr x)
- (values (car x) t)
- (values nil nil))))
+ (return (values (oget exports name) t))))))))
(defun intern (name &optional (package *package*))
(let ((package (find-package-or-fail package)))
(defun prin1-to-string (form)
(cond
((symbolp form)
- (if (cdr (%find-symbol (symbol-name form) *package*))
- (symbol-name form)
- (let ((package (symbol-package form))
- (name (symbol-name form)))
- (concat (cond
- ((null package) "#")
- ((eq package (find-package "KEYWORD")) "")
- (t (package-name package)))
- ":" name))))
+ (multiple-value-bind (symbol foundp)
+ (find-symbol (symbol-name form) *package*)
+ (if (and foundp (eq symbol form))
+ (symbol-name form)
+ (let ((package (symbol-package form))
+ (name (symbol-name form)))
+ (concat (cond
+ ((null package) "#")
+ ((eq package (find-package "KEYWORD")) "")
+ (t (package-name package)))
+ ":" name)))))
((integerp form) (integer-to-string form))
((stringp form) (concat "\"" (escape-string form) "\""))
((functionp form)