From 96ecde91350bb5cbd329dcd4657a06317f67941a Mon Sep 17 00:00:00 2001 From: Stelian Ionescu Date: Sun, 13 May 2007 01:15:36 +0200 Subject: [PATCH] Added RETURN-IF and FEATUREP. Signed-off-by: Stelian Ionescu --- utils/misc.lisp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/utils/misc.lisp b/utils/misc.lisp index dbf4bc2..d84b3c8 100644 --- a/utils/misc.lisp +++ b/utils/misc.lisp @@ -30,4 +30,18 @@ (when (> start end) (error "~S ~S wrong sequence bounds" start end)) (values start end)) -(export '(define-constant %check-bounds)) +(defmacro return-if (block form) + (let (($form$ (gensym "FORM-"))) + `(let ((,$form$ ,form)) + (when ,$form$ (return-from ,block ,$form$))))) + +(defun featurep (feature) + (etypecase feature + (symbol (consp (member feature *features* :test #'eq))) + (cons (ecase (first feature) + ((or :or) (some #'featurep (rest feature))) + ((and :and) (every #'featurep (rest feature))) + ((not :not) (and (third feature) (error "Incorrect feature expression: ~S" feature)) + (not (featurep (second feature)))))))) + +(export '(define-constant %check-bounds return-if featurep)) -- 2.11.4.GIT