I extended DESTRUCTURING-BIND to allow NIL bindings to indicate a place should be ignored, the way that CL LOOP does. The fact that CL's DESTRUCTURING-BIND doesn't do that, but instead forces the user to make up a name and declare it ignored, is a perennial annoyance. Patch is below.
Daniel
From 5d8b60256a70788c0930724e9d3501551a5e1559 Mon Sep 17 00:00:00 2001
From: Daniel Gackle <danielgackle@gmail.com>
Date: Fri, 8 May 2009 14:59:05 -0600
Subject: [PATCH 1/2] Extended DESTRUCTURING-BIND to allow NIL bindings to indicate a place should be ignored, the way that CL LOOP does.
---
src/lib/ps-macro-lib.lisp | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/lib/ps-macro-lib.lisp b/src/lib/ps-macro-lib.lisp
index e6c32be..85a55ea 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)))
--
1.6.1