[cl-utilities-cvs] CVS update: cl-utilities/once-only.lisp
Peter Scott
pscott at common-lisp.net
Thu May 26 19:09:06 UTC 2005
Update of /project/cl-utilities/cvsroot/cl-utilities
In directory common-lisp.net:/tmp/cvs-serv3083
Modified Files:
once-only.lisp
Log Message:
Factored out error checking
Date: Thu May 26 21:09:05 2005
Author: pscott
Index: cl-utilities/once-only.lisp
diff -u cl-utilities/once-only.lisp:1.1.1.1 cl-utilities/once-only.lisp:1.2
--- cl-utilities/once-only.lisp:1.1.1.1 Mon May 9 23:26:29 2005
+++ cl-utilities/once-only.lisp Thu May 26 21:09:05 2005
@@ -7,11 +7,18 @@
(in-package :cl-utilities)
-(defmacro once-only ((&rest names) &body body)
- ;; Check that all of the NAMES are symbols. If not, raise an error.
+(defun check-once-only-names (names)
+ "Check that all of the NAMES are symbols. If not, raise an error."
+ ;; This only raises an error for the first non-symbol argument
+ ;; found. While this won't report multiple errors, it is probably
+ ;; more convenient to only report one.
(let ((bad-name (find-if-not #'symbolp names)))
(when bad-name
- (error "ONCE-ONLY expected a symbol but got ~S" bad-name)))
+ (error "ONCE-ONLY expected a symbol but got ~S" bad-name))))
+
+(defmacro once-only (names &body body)
+ ;; Check the NAMES list for validity.
+ (check-once-only-names names)
;; Do not touch this code unless you really know what you're doing.
(let ((gensyms (loop for name in names collect (gensym (string name)))))
`(let (,@(loop for g in gensyms
More information about the Cl-utilities-cvs
mailing list