fink/macro-utils.lisp

43 lines
1005 B
Common Lisp
Raw Normal View History

2008-05-21 18:46:32 +00:00
(in-package macro-utils)
;(defun test-while (n)
; (let ((i 0))
; (while (< i n)
; (format t "~a~%" i)
; (incf i))))
;(defun test-until (n)
; (let ((i 0))
; (until (= i n)
; (format t "~a~%" i)
; (incf i))))
(defparameter *print-debug* t)
(defmacro pdebug (&body body)
`(if macro-utils:*print-debug*
(format *error-output* ,@body)))
2008-06-21 06:03:06 +00:00
(defmacro while (test-case &body body)
`(do ()
((not ,test-case) t)
,@body))
(defmacro until (test-case &body body)
`(do ()
(,test-case t)
,@body))
2008-05-21 18:46:32 +00:00
(defmacro with-gensyms ((&rest names) &body body)
`(let ,(loop for n in names collect `(,n (gensym)))
,@body))
2008-05-21 19:18:47 +00:00
(defmacro once-only ((&rest names) &body body)
2008-05-21 18:46:32 +00:00
(let ((gensyms (loop for n in names collect (gensym))))
`(let (,@(loop for g in gensyms collect `(,g (gensym))))
`(let (,,@(loop for g in gensyms for n in names collect ``(,,g ,,n)))
,(let (,@(loop for n in names for g in gensyms collect `(,n ,g)))
,@body)))))