From: David Vazquez Date: Fri, 1 Feb 2013 12:27:35 +0000 (+0000) Subject: Remove auxiliar %FIND-SYMBOL function X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=616032207c3032ca45568ad6b40314f480e056c0;p=jscl.git Remove auxiliar %FIND-SYMBOL function --- diff --git a/ecmalisp.lisp b/ecmalisp.lisp index d705668..8ce69d5 100644 --- a/ecmalisp.lisp +++ b/ecmalisp.lisp @@ -591,21 +591,15 @@ (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))) @@ -780,15 +774,17 @@ (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)