From: Daniel Gackle Date: Fri, 8 May 2009 20:59:05 +0000 (-0600) Subject: Extended DESTRUCTURING-BIND to allow NIL bindings to indicate a place should be ignor... X-Git-Url: http://git.hcoop.net/clinton/parenscript.git/commitdiff_plain/6e135d5caec3096c8ce072c8f34a1610e7007bf0 Extended DESTRUCTURING-BIND to allow NIL bindings to indicate a place should be ignored, the way that CL LOOP does. --- diff --git a/src/lib/ps-macro-lib.lisp b/src/lib/ps-macro-lib.lisp index e3341e0..cb413cf 100644 --- a/src/lib/ps-macro-lib.lisp +++ b/src/lib/ps-macro-lib.lisp @@ -137,10 +137,13 @@ `((@ ,fn :apply) this ,arglist))) (defpsmacro destructuring-bind (vars expr &body body) - ;; a simple implementation that for now only supports flat lists + ;; a simple implementation that for now only supports flat lists, + ;; but does allow NIL bindings to indicate ignore (a la LOOP) (let* ((arr (if (complex-js-expr? expr) (ps-gensym) expr)) (n -1) (bindings (append (unless (equal arr expr) `((,arr ,expr))) - (mapcar (lambda (var) `(,var (aref ,arr ,(incf n)))) vars)))) + (mapcan (lambda (var) + (incf n) + (when var `((,var (aref ,arr ,n))))) vars)))) `(let ,bindings ,@body)))