Skip to content
Browse files

changed the implementation of extract-declarations as per Hans reques…

…t - to be more readable/easier to reason about.
  • Loading branch information...
1 parent 835fabd commit 48516b61ac5ca694486e038b1be45d01ec90178e @fighting-spirit committed May 1, 2012
Showing with 7 additions and 9 deletions.
  1. +7 −9 util.lisp
View
16 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)))
+ (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))))

0 comments on commit 48516b6

Please sign in to comment.
Something went wrong with that request. Please try again.