Madhu <eno...@net.meer> wrote:
> It looks like tim bradshaw has published a macro called
> destructring-match which sounds like destructuring bind but looks
> more like elisp's pcase with additional multiple match clauses and
> additional (:when ..) syntax. I would disagree with the name,
> because it doesn't seem to be analogous to lisp's destructuring
Each lambda list in
(destructuring-match <form>
(<lambda-list> ...)
(<lambda-list> ...)
...
(otherwise ...))
is full destructuring-bind lambda list (so, macro lambda list without
environment etc). In that sense yes, it is exactly common lisp's
destructuring.
In fact is easy:
(defmacro destructuring-bind (ll form &body forms)
`(destructuring-match ,form
(,ll ,@forms)
(otherwise (error "fleașcă"))))
Think you may be confuse dsm with spam which is in its implementation (I do
not know pcase you mention). In fact destructuring-bind os more safely
implement using both dsm for the work and spam for toxin prevention
(defmacro destructuring-bind (ll form &body forms)
(matching forms
((head-matches (repeating-list-of (some-of (is ':when)
(is ':unless))
(any)))
(error "futu-i"))
(otherwise
`(destructuring-match ,form
(,ll ,@forms)
(otherwise (error "fleașcă"))))))
Even this is not quite right: really you need to parse forms a little, so:
(defmacro destructuring-bind (ll form &body decls/forms)
(multiple-value-bind (decls forms) (parse-simple-body decls/forms)
`(destructuring-match ,form
(,ll
,@decls
(progn ,@forms)))
(otherwise (error "fleașcă"))))
This still may be wrong but is close.
--
the small snake