;;; Hi,
;;;
;;; I hope this code makes a few functions (like decode-universal-time)
;;; more useful. Each of these functions replaces variables with a
;;; symbol-name of _ with a (declare (ignore))d gensym.
;;;
;;; I'm sure everybody has already written something similar.
;;; "Somebody should write a CLRFI for that" (-:
(require :iterate)
;; Yeah, sorry.. the solution using LOOP was ugly as hell.
(defun replace-binds (binds)
(iterate (for bind in binds)
(typecase bind
(cons
(multiple-value-bind (result* ignore*) (replace-binds bind)
(collecting result* into result)
(appending ignore* into ignore)))
(t
(if (string-equal bind '_)
(let ((sym (gensym)))
(collect sym into result)
(collect sym into ignore))
(collect bind into result))))
(finally (return (values result ignore)))))
(defmacro destructuring-bind* (bind-list obj &rest body)
(multiple-value-bind (binds ignores) (replace-binds bind-list)
`(destructuring-bind ,binds ,obj
(declare (ignore ,@ignores))
,@body)))
(defmacro multiple-value-bind* (bind-list obj &rest body)
(multiple-value-bind (binds ignores) (replace-binds bind-list)
`(multiple-value-bind ,binds ,obj
(declare (ignore ,@ignores))
,@body)))
;;; Have fun,
--
Andreas Fuchs, <asf(a)boinkor.net>, asf(a)jabber.at, antifuchs