[Openmcl-devel] Seeking beta testers for destructuring-match

Tim Bradshaw tfb at tfeb.org
Tue Jul 19 03:03:13 PDT 2022


[Sorry to anyone who is also on the Lisp-HUG mailing list: you'll have seen this before.  FWIW I know it 'works' in CCL: it passes its tests and simple cases work.  I just can't believe it's not buggy in complicated cases.]

I've finally written the macro I've wanted for about 20 years, which is destructuring-match:

(destructuring-match x
 (((var init) &body forms)
  (:when (symbolp var))
  ...)
 (((var) &body forms)
  (:when (symbolp var))
  ...)
 (otherwise
  (error ...)))

Which allows you to write, for instance, define-matching-macro (included as an example, 11 lines).

(define-matching-macro with-scrot
  ((_ (s) &body forms)
   (:when (symbolp s))
   `(call-with-simple-scrot (lambda (,s) , at forms)))
  ((_ (s v) &body forms)
   (:when (symbolp s))
   `(call-with-general-scrot (lambda (,s) , at forms) (ensure-scrot ,v)))
  (badness
   (error "~S is bad" badness)))

dsm necessarily involves its own lambda list parser & compiler, which means lots of corner cases I probably don't understand.

Disturbingly it seems to work quite well, but it's necessarily had rather limited testing (there is a test suite, but there are so many odd cases in lambda lists I'm certain I do not have them all).

It would be nice if someone else tried it before I make a fool of myself in public.

It would be useful if you write a lot of macros as this is really what it's intended for: I know it works in simple cases, I want to find out if it works in complicated ones.

It would be very useful if you use a Lisp which is not LW, CCL or SBCL, or if you use SBCL or CCL more seriously than I do (it was written entirely using LW of course, and I certainly could not have written it without LW).  It would probably be useful if you know the rules of lambda lists better than me.

You will need to be willing to install some of its dependencies which aren't yet in Quicklisp (this is just a matter of cloning a repo to the QL's local-projects repo).  

It would be useful if you have a github account so I can add you to the currently private repo for it.

Finally, my CL style is probably now very far out of the mainstream (no loop, very little assignment, lots of recursion) so if you're going to look at the sources you need to be willing to deal with that.  destructuring-match *itself* isn't weird in this way, but its implementation (and the code it expands into) probably is.

Finally: it's going to be MIT licensed, so this isn't some proprietary thing.

Thanks

--tim


More information about the Openmcl-devel mailing list