Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Lisp Macrology

Name: Anonymous 2009-09-12 19:42

Post crazy Lisp macros you've written in this thread.

I'll start off with a quick one I wrote 15minutes ago, PROGK:

Name: Anonymous 2009-09-12 20:22

Maybe like this? Not really tested or debugged. And probably if you actually use this you're writing confusing code. Better to write it out so you can put the SETF visually by the code it actually applies to.
(defmacro progk (k &body forms)
  (let ((vs (gensym "VS")))
    `(let (,vs)
       ,@(loop for f in forms
            for i = 0 then (1+ i)
            collect (if (= i k)
                        `(setf ,vs (multiple-value-list ,f))
                        f))
       (values-list ,vs))))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List