aboutsummaryrefslogtreecommitdiffstats
path: root/util.lisp
diff options
context:
space:
mode:
authorAla'a Mohammad Alawi <amalawi@gmail.com>2012-05-01 21:44:23 +0400
committerAla'a Mohammad Alawi <amalawi@gmail.com>2012-05-01 21:44:23 +0400
commit48516b61ac5ca694486e038b1be45d01ec90178e (patch)
tree7b643a02498bb251b6f654bcecf79690b4b11d89 /util.lisp
parent835fabdfbb7a6b982db2b741375e6bf9d409df78 (diff)
downloadtl-who-48516b61ac5ca694486e038b1be45d01ec90178e.tar.gz
tl-who-48516b61ac5ca694486e038b1be45d01ec90178e.tar.bz2
tl-who-48516b61ac5ca694486e038b1be45d01ec90178e.zip
changed the implementation of extract-declarations as per Hans request - to be more readable/easier to reason about.
Diffstat (limited to 'util.lisp')
-rw-r--r--util.lisp16
1 files changed, 7 insertions, 9 deletions
diff --git a/util.lisp b/util.lisp
index ecfb689..717aa7c 100644
--- a/util.lisp
+++ b/util.lisp
@@ -228,15 +228,13 @@ determine whether CHAR must be escaped."
character set."
(escape-string string :test #'non-7bit-ascii-escape-char-p))
-(defun extract-declarations (body)
+(defun extract-declarations (forms)
"Given a FORM, the declarations - if any - will be extracted
from the head of the FORM, and will return two values the declarations,
and the remaining of FORM"
- (loop for sexp = (first body) then (first forms)
- for forms = (rest body) then (rest forms)
- for declarations = nil
- if (not (eq (first sexp) 'cl:declare))
- do (return (values declarations
- (append (if (null sexp) sexp (list sexp)) forms)))
- else
- do (push sexp declarations))) \ No newline at end of file
+ (loop with declarations
+ for forms on forms
+ for form = (first forms)
+ while (eql (first form) 'cl:declare)
+ do (push form declarations)
+ finally (return (values (nreverse declarations) forms)))) \ No newline at end of file