WJ wrote:
> Kaz Kylheku wrote:
>
> > How would we write this language feature?
> >
> > (defmacro dolist-destructured ((destructuring-lambda-list
> > list &optional result-form)
> > &rest body)
> > (let ((list-item-sym (gensym "LIST-ITEM-")))
> > `(dolist (,list-item-sym ,list ,result-form)
> > (destructuring-bind ,destructuring-lambda-list ,list-item-sym
> > ,@body))))
> >
> > (defvar list '((1 2) (3 4))
> >
> > (dolist-destructured ((i j) list)
> > (format t "~a - ~a~%" i j))
> >
> > Output:
> > 1 - 2
> > 3 - 4
Gauche Scheme:
(use util.match)
(define-syntax match-dolist
(syntax-rules ()
[(_ (pattern the-list) body ...)
(dolist (x the-list)
(match-let1 pattern x
body ...))]))
(define stuff '((1 2) (3 4)))
(match-dolist ((i j) stuff)
(format #t "~a - ~a~%" i j))
===>