From cf4cbdbd7db0584c2b8456bbe6c27a7dbd717979 Mon Sep 17 00:00:00 2001 From: Vladimir Sedach Date: Sun, 5 Apr 2009 17:50:15 -0600 Subject: [PATCH] Made the ignore declaration in define-ps-special-form be generated on the condition that 'expecting is used in the body. While it's not an error to use variables previously declared ignored, it does raise annoying compiler warnings in some Lisps. --- src/compiler.lisp | 5 +++-- src/utils.lisp | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/compiler.lisp b/src/compiler.lisp index a3420ae..aff2e9e 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -22,12 +22,13 @@ 'expecting' automatically added to the arglist) to the special form is a keyword indicating whether the form is expected to produce an :expression or a :statement." - (let ((args (gensym "ps-arglist-"))) + (let ((args (gensym "ps-arglist-")) + (expecting-used-p (member 'expecting (flatten body)))) `(setf (gethash ',name *ps-special-forms*) (lambda (&rest ,args) (destructuring-bind ,(cons 'expecting lambda-list) ,args - (declare (ignore expecting)) + ,(unless expecting-used-p '(declare (ignore expecting))) ,@body))))) (defun undefine-ps-special-form (name) diff --git a/src/utils.lisp b/src/utils.lisp index f87bc59..897305e 100644 --- a/src/utils.lisp +++ b/src/utils.lisp @@ -1,4 +1,4 @@ -(in-package :parenscript) +(in-package "PARENSCRIPT") (defun string-join (strings separator) (format nil "~{~}" (format nil "~~a~~^~a" separator) strings)) @@ -99,3 +99,8 @@ SOMEGLOBAL." (defun ordered-set-difference (list1 list2 &key (test #'eql)) ; because the CL set-difference may not preserve order (reduce (lambda (list el) (remove el list :test test)) (cons list1 list2))) + +(defun flatten (x &optional acc) + (cond ((null x) acc) + ((atom x) (cons x acc)) + (t (flatten (car x) (flatten (cdr x) acc))))) \ No newline at end of file -- 2.20.1