Instruction:
Generate a defmacro form that transforms code like this:
(pipe common-lisp:nil :key common-lisp:nil)

Pattern to recognize: Macro call that should be transformed by PIPE

Input: (pipe common-lisp:nil :key common-lisp:nil)

Output:
(defmacro pipe (cl:&rest items)
  "A syntactic convenience for function application, sometimes called a \"threading macro\". Transform

    (pipe x h g f)

to

    (f (g (h x)))."
  (cl:assert (cl:<= 2 (cl:list-length items)))
  `(nest ,@(cl:reverse items)))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(dynamic-relet* 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by DYNAMIC-RELET*

Input: (dynamic-relet* 'lol-gen::some-name)

Output: (defmacro DYNAMIC-RELET* ...)


Instruction:
Generate a defmacro form that transforms code like this:
(rem-bops nil (progn))

Pattern to recognize: Macro call that should be transformed by REM-BOPS

Input: (rem-bops nil (progn))

Output: (defmacro REM-BOPS ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(peek nil)

Write a macro that addresses: Macro call that should be transformed by PEEK

Input: (peek nil)

Output:
(defmacro peek (form)
  "Read the value of cells without triggering a recomputation.

FORM is evaluated in a context such that when the value of a cell is
referenced it is not registered as an argument cell of the cell in
which the PEEK form is evaluated. This means that the value of the
cell, in which the PEEK form is evaluated, will not be recomputed when
the values of the cells referenced in FORM change.

In the following example

.. code-block::

   (defcell a 0)
   (defcell b 1)

   (defcell sum (+ a (peek b))

the SUM cell references the value of A directly and *peeks* the value
of B (using PEEK). Changing the value of A will cause the value of the
SUM cell to be recomputed. However, changing the value of B will not
cause the value of SUM to be computed.

.. important::

   This macro has no effect if CELL is referenced outside a PEEK form
   within the same cell definition.

   .. code-block::

      (defcell sum (+ b (peek b))

   In this example, PEEK has no effect because the SUM cell references
   B outside a PEEK form.

"

  (with-gensyms (arg-cell
                 did-change
                 observer-arg
                 tracker
                 update
                 will-update)

    (let* ((key ``(peek ,(argument-key ,arg-cell)))
           (observer-record
             `(make-observer
               :key ,key
               :will-update #',will-update
               :update #',update)))

      `(flet ((,update (,arg-cell ,did-change)
                (declare (ignore ,arg-cell ,did-change)))
              (,will-update (,arg-cell)
                (declare (ignore ,arg-cell))))

         (let ((,tracker *track-cell-callback*))
           (with-tracker
               ((,arg-cell)
                 (let ((*track-cell-callback* ,tracker))
                   (track-argument
                    (make-argument
                     :key ,key
                     :add-observer (lambda (,observer-arg)
                                     (declare (ignore ,observer-arg))
                                     (call-add-observer ,arg-cell ,observer-record))
                     :remove-observer (lambda (,observer-arg)
                                        (declare (ignore ,observer-arg))
                                        (call-remove-observer ,arg-cell ,observer-record))))))

             ,form))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(econd-let nil
  nil)

Write a macro that addresses: Macro call that should be transformed by ECOND-LET

Input:
(econd-let nil
  nil)

Output:
(defmacro econd-let (symbol &body clauses)
  "Like `cond-let' for `econd'."
  `(cond-let ,symbol
     ,@clauses
     (t (error 'econd-failure))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(defconst nil nil)

Issue: Macro call that should be transformed by DEFCONST

Input: (defconst nil nil)

Output:
(defmacro defconst (symbol init &optional docstring)
  "Define a constant, lexically.

`defconst' defines a constant using a strategy similar to `def', so
you don’t have to +cage+ your constants.

The constant is only redefined on re-evaluation if INIT has a
different literal representation than the old value.

A constant defined with `defconst' is guaranteed to be available as
soon as it has been defined (for example, for use with reader macros
later in the same file). This is not guaranteed to be portably true
for `defconstant'.

The name is from Emacs Lisp."
  (let ((backing-var (symbolicate '#:+storage-for-deflex-var- symbol '+)))
    `(eval-when (:compile-toplevel :load-toplevel :execute)
       (define-constant ,backing-var ,init
         :test 'same-literal-p
         :documentation ,docstring)
       (define-symbol-macro ,symbol ,backing-var))))


Instruction:
Generate a defmacro form that transforms code like this:
(with-decoder-simple-clos-semantics
  nil
  (progn))

Pattern to recognize: Macro call that should be transformed by WITH-DECODER-SIMPLE-CLOS-SEMANTICS

Input:
(with-decoder-simple-clos-semantics
  nil
  (progn))

Output:
(defmacro with-decoder-simple-clos-semantics (&body body)
  "Execute BODY in a dynamic environement where the decoder semantics
is such as set by SET-DECODER-SIMPLE-CLOS-SEMANTICS."
  `(with-shadowed-custom-vars
     (set-decoder-simple-clos-semantics)
     ,@body))


Instruction:
Generate a defmacro form that transforms code like this:
(declare-deprecated-operators nil :key nil)

Pattern to recognize: Macro call that should be transformed by DECLARE-DEPRECATED-OPERATORS

Input: (declare-deprecated-operators nil :key nil)

Output: (defmacro DECLARE-DEPRECATED-OPERATORS ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
;; Sorting multiple places requires manual compare-and-swap
(when (> b a) (rotatef a b))
(when (> c a) (rotatef a c))
(when (> c b) (rotatef b c))
;; This is a sorting network but manually written - error-prone
;; For more than 3 elements, the network is complex

What needs to change: Sorting multiple values in-place requires compare-and-swap networks — want automatic sorting network generation

Input:
;; Sorting multiple places requires manual compare-and-swap
(when (> b a) (rotatef a b))
(when (> c a) (rotatef a c))
(when (> c b) (rotatef b c))
;; This is a sorting network but manually written - error-prone
;; For more than 3 elements, the network is complex

Output:
(defun build-batcher-sn (n)
  (let* (network
         (tee (ceiling (log n 2)))
         (p (ash 1 (- tee 1))))
    (loop while (> p 0) do
      (let ((q (ash 1 (- tee 1)))
            (r 0)
            (d p))
        (loop while (> d 0) do
          (loop for i from 0 to (- n d 1) do
            (if (= (logand i p) r)
              (push (list i (+ i d))
                    network)))
          (setf d (- q p)
                q (ash q -1)
                r p)))
      (setf p (ash p -1)))
    (nreverse network)))

(defmacro! sortf (comparator &rest places)
  (if places
    `(tagbody
       ,@(mapcar
           #`(let ((,g!a #1=,(nth (car a1) places))
                   (,g!b #2=,(nth (cadr a1) places)))
               (if (,comparator ,g!b ,g!a)
                 (setf #1# ,g!b
                       #2# ,g!a)))
           (build-batcher-sn (length places))))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(with-object nil)

Problem: Macro call that should be transformed by WITH-OBJECT

Input: (with-object nil)

Output:
(defmacro with-object ((&optional (stream '*json-output*)) &body body)
  "Open a JSON Object, run BODY, then close the Object.  Inside the BODY,
AS-OBJECT-MEMBER or ENCODE-OBJECT-MEMBER should be called to encode
Members of the Object."
  `(with-aggregate (object #\{ #\} ,stream) ,@body))


Instruction:
Generate a defmacro form that transforms code like this:
(do-iterator 'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by DO-ITERATOR

Input: (do-iterator 'lol-gen::some-name)

Output: (defmacro DO-ITERATOR ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(mapping nil :key nil)

What needs to change: Macro call that should be transformed by MAPPING

Input: (mapping nil :key nil)

Output: (defmacro MAPPING ...)


Instruction:
Generate a defmacro form that transforms code like this:
(c?once
  nil
  nil)

Pattern to recognize: Macro call that should be transformed by C?ONCE

Input:
(c?once
  nil
  nil)

Output:
(defmacro c?once (&body body)
  `(make-c-dependent
    :code '(without-c-dependency ,@body)
    :inputp nil
    :value-state :unevaluated
    :rule (c-lambda (without-c-dependency ,@body))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(list-of nil)

Write a macro that addresses: Macro call that should be transformed by LIST-OF

Input: (list-of nil)

Output: (defmacro LIST-OF ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(defjsmacro nil)

Problem: Macro call that should be transformed by DEFJSMACRO

Input: (defjsmacro nil)

Output: (defmacro DEFJSMACRO ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(defun-advisable nil
    nil)

Issue: Macro call that should be transformed by DEFUN-ADVISABLE

Input:
(defun-advisable nil
    nil)

Output: (defmacro DEFUN-ADVISABLE ...)


Instruction:
Generate a defmacro form that transforms code like this:
(if-not nil (progn))

Pattern to recognize: Macro call that should be transformed by IF-NOT

Input: (if-not nil (progn))

Output:
(defmacro if-not (test then &optional else)
  "If TEST evaluates to NIL, evaluate THEN and return its values,
otherwise evaluate ELSE and return its values. ELSE defaults to NIL."
  `(if (not ,test)
       ,then
       ,else))


Instruction:
Generate a defmacro form that transforms code like this:
(local-output
  nil
  :key
  nil)

Pattern to recognize: Macro call that should be transformed by LOCAL-OUTPUT

Input:
(local-output
  nil
  :key
  nil)

Output: (defmacro LOCAL-OUTPUT ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(pass nil)

Write a macro that addresses: Macro call that should be transformed by PASS

Input: (pass nil)

Output:
(defmacro pass (&rest message-args)
  "Simply generate a PASS."
  `(add-result 'test-passed
               :test-expr ',message-args
               ,@(when message-args
                   `(:reason (format nil ,@message-args)))))


Instruction:
Generate a defmacro form that transforms code like this:
(with-contracts-enabled nil
  nil)

Pattern to recognize: Macro call that should be transformed by WITH-CONTRACTS-ENABLED

Input:
(with-contracts-enabled nil
  nil)

Output:
(defmacro with-contracts-enabled
    ((&rest args &key invariants preconditions postconditions) &body body)
  "Enables/disables contracts for the extent of this form, restoring them to
   their prior values upon exit."
  (declare (ignore invariants preconditions postconditions))
  (let ((enabled-contracts (gensym "ENABLED-CONTRACTS-")))
    `(let ((,enabled-contracts (enabled-contracts)))
       (unwind-protect
            (progn (enable-contracts ,@args)
                   ,@body)
         (apply #'enable-contracts ,enabled-contracts)))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(c-lambda
  nil
  :key
  nil)

What needs to change: Macro call that should be transformed by C-LAMBDA

Input:
(c-lambda
  nil
  :key
  nil)

Output:
(defmacro c-lambda (&body body)
  `(c-lambda-var (slot-c) ,@body))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(f nil)

What needs to change: Macro call that should be transformed by F

Input: (f nil)

Output: (defmacro F ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(nor nil)

Problem: Macro call that should be transformed by NOR

Input: (nor nil)

Output:
(defmacro nor (&rest forms)
  "Equivalent to (not (or ...)).

From Arc."
  (if (null forms) t
      (if (null (rest forms))
          `(not ,(first forms))
          `(if ,(first forms)
               nil
               (nor ,@(rest forms))))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(is-condition nil (progn))

Problem: Macro call that should be transformed by IS-CONDITION

Input: (is-condition nil (progn))

Output:
(defmacro is-condition (form condition &optional desc)
  (with-gensyms (error duration)
    `(with-duration ((,duration ,error) (handler-case ,form
                                          (condition (,error) ,error)))
       (test ,error
             ,(if (and (listp condition) (eq 'quote (car condition)))
                  condition
                  `(quote ,condition))
             ,desc
             :duration ,duration
             :got-form ',form
             :test-fn #'typep
             :report-expected-label "raise a condition"))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(cond->> nil)

Issue: Macro call that should be transformed by COND->>

Input: (cond->> nil)

Output: (defmacro COND->> ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(unwind-protect nil
    (progn))

What needs to change: Macro call that should be transformed by UNWIND-PROTECT

Input:
(unwind-protect nil
    (progn))

Output: (defmacro UNWIND-PROTECT ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(undefmessage 'lol-gen::some-name)

Issue: Macro call that should be transformed by UNDEFMESSAGE

Input: (undefmessage 'lol-gen::some-name)

Output: (defmacro UNDEFMESSAGE ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(stypecase nil)

Problem: Macro call that should be transformed by STYPECASE

Input: (stypecase nil)

Output:
(defmacro stypecase (keyform &body cases)
  "Like TYPECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for the
scope of the cases. IT can be set with SETF."
  `(symbolic typecase ,keyform ,@cases))


Instruction:
Define a macro that eliminates this repetitive pattern:
(define-global-parameter* nil nil)

Issue: Macro call that should be transformed by DEFINE-GLOBAL-PARAMETER*

Input: (define-global-parameter* nil nil)

Output: (defmacro DEFINE-GLOBAL-PARAMETER* ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(define-test+run 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by DEFINE-TEST+RUN

Input: (define-test+run 'lol-gen::some-name)

Output:
(defmacro define-test+run (name &body args-and-body)
  `(progn
     (define-test ,name ,@args-and-body)
     (eval-when (:execute)
       (let* ((*silence-plain-compilation-errors-p* nil) ; must be let*! the order matters!
              (report (test ',name :report 'plain)))
         (if (member (status report) '(:passed :skipped))
             report
             (values report
                     (loop for result across (results report)
                           when (and (not (typep result 'test-result))
                                     (eql :failed (status result)))
                           collect (expression result))))))))


Instruction:
Generate a defmacro form that transforms code like this:
(defgeneric* nil
    (progn))

Pattern to recognize: Macro call that should be transformed by DEFGENERIC*

Input:
(defgeneric* nil
    (progn))

Output: (defmacro DEFGENERIC* ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(collect-append nil (progn))

Write a macro that addresses: Macro call that should be transformed by COLLECT-APPEND

Input: (collect-append nil (progn))

Output: (defmacro COLLECT-APPEND ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(with-unknown-first-class-functions-allowed
  nil
  (progn))

What needs to change: Macro call that should be transformed by WITH-UNKNOWN-FIRST-CLASS-FUNCTIONS-ALLOWED

Input:
(with-unknown-first-class-functions-allowed
  nil
  (progn))

Output:
(defmacro with-unknown-first-class-functions-allowed (&body body)
  `(let ((*allow-call-function-signature* t))
     ,@body))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(incf nil (progn))

Problem: Macro call that should be transformed by INCF

Input: (incf nil (progn))

Output: (defmacro INCF ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(defpackage nil)

Issue: Macro call that should be transformed by DEFPACKAGE

Input: (defpackage nil)

Output: (defmacro DEFPACKAGE ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(as~> nil nil)

Issue: Macro call that should be transformed by AS~>

Input: (as~> nil nil)

Output:
(defmacro as~> (expr name &rest exprs)
  "Like `~>' or `~>', but instead of threading by position, threading is
done based on NAME."
  `(let* ,(loop for expr in (cons expr exprs)
                collect (list name expr))
     ,name))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(gen-lambda 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by GEN-LAMBDA

Input: (gen-lambda 'lol-gen::some-name)

Output:
(defmacro gen-lambda (params &body rest)
  "Version of lambda that wraps the anonymous function in an instance of the basic-generator class. This allows the lambda to be identified as a generator by its type. Basic-generator objects are derived from funcallable-standard-class, therefore they can be called as functions."
  `(let ((values-handler (create-values-handler)))
     (declare (ignorable values-handler))
     (make-instance
      'basic-generator
      :function (lambda ,params ,@rest))))


Instruction:
Generate a defmacro form that transforms code like this:
(alter-table nil)

Pattern to recognize: Macro call that should be transformed by ALTER-TABLE

Input: (alter-table nil)

Output:
(defmacro alter-table (table &body clauses)
  `(make-statement :alter-table
                   ,(expand-expression table) ,@clauses))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(unless 'lol-gen::some-name)

Problem: Macro call that should be transformed by UNLESS

Input: (unless 'lol-gen::some-name)

Output: (defmacro UNLESS ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(defrequirement nil
    (progn))

What needs to change: Macro call that should be transformed by DEFREQUIREMENT

Input:
(defrequirement nil
    (progn))

Output:
(defmacro defrequirement (name (&rest lambda-list) &body body)
  "Adds a precondition to the NAMEd function. It can be either a generic or
   non-generic function. If it's the former, then use a specialized lambda list,
   otherwise use an ordinary lambda list. The docstring, if any, will be used in
   failure reports."
  #+qpq-precondition-checks-disabled
  (declare (ignore name lambda-list body))
  #+qpq-precondition-checks-disabled
  (values)
  #-qpq-precondition-checks-disabled
  (multiple-value-bind (remaining-forms declarations doc-string)
      (parse-body body :documentation t)
    (declare (ignore declarations))
    (let* ((stripped-ll (strip-lambda-list lambda-list))
           (lambda-vars (remove-if (rcurry #'member
                                           '(&optional &rest
                                             &key &allow-other-keys &aux))
                                   stripped-ll))
           (method `(progn
                      (ensure-contracted-function ',name',stripped-ll)
                      (defmethod ,name
                          :require
                          ,(format nil "~A"
                            (or doc-string
                             (description<-remaining-forms
                              remaining-forms)))
                        ,lambda-list
                        (declare (ignorable ,@lambda-vars))
                        ,@body))))
      (if (every #'symbolp lambda-list)
          `(if (and (fboundp ',name)
                    (not (typep (fdefinition ',name) 'generic-function)))
               (defcontract ,name :require ,lambda-list
                 (declare (ignorable ,@lambda-vars))
                 ,@body)
               ,method)
          method))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(optional common-lisp:nil common-lisp:nil)

What needs to change: Macro call that should be transformed by OPTIONAL

Input: (optional common-lisp:nil common-lisp:nil)

Output: (defmacro OPTIONAL ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(is nil :key nil)

Problem: Macro call that should be transformed by IS

Input: (is nil :key nil)

Output:
(defmacro is (test &rest reason-args)
  "The DWIM checking operator.

If TEST returns a true value a test-passed result is generated,
otherwise a test-failure result is generated. The reason, unless
REASON-ARGS is provided, is generated based on the form of TEST:

 (predicate expected actual) - Means that we want to check
 whether, according to PREDICATE, the ACTUAL value is
 in fact what we EXPECTED.

 (predicate value) - Means that we want to ensure that VALUE
 satisfies PREDICATE.

 Wrapping the TEST form in a NOT simply produces a negated reason
 string."
  (assert (listp test)
          (test)
          "Argument to IS must be a list, not ~S" test)
  (let (bindings effective-test default-reason-args)
    (with-gensyms (e a v)
      (flet ((process-entry (predicate expected actual &optional negatedp)
               ;; make sure EXPECTED is holding the entry that starts with 'values
               (when (and (consp actual)
                          (eq (car actual) 'values))
                 (assert (not (and (consp expected)
                                   (eq (car expected) 'values))) ()
                                   "Both the expected and actual part is a values expression.")
                 (rotatef expected actual))
               (let ((setf-forms))
                 (if (and (consp expected)
                          (eq (car expected) 'values))
                     (progn
                       (setf expected (copy-list expected))
                       (setf setf-forms (loop for cell = (rest expected) then (cdr cell)
                                              for i from 0
                                              while cell
                                              when (eq (car cell) '*)
                                              collect `(setf (elt ,a ,i) nil)
                                              and do (setf (car cell) nil)))
                       (setf bindings (list (list e `(list ,@(rest expected)))
                                            (list a `(multiple-value-list ,actual)))))
                     (setf bindings (list (list e expected)
                                          (list a actual))))
                 (setf effective-test `(progn
                                         ,@setf-forms
                                         ,(if negatedp
                                              `(not (,predicate ,e ,a))
                                              `(,predicate ,e ,a)))))))
        (list-match-case test
          ((not (?predicate ?expected ?actual))
           (process-entry ?predicate ?expected ?actual t)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is ~2&~S~2%to ~2&~S~2% (it should not be)"
                       `',?actual a `',?predicate e)))
          ((not (?satisfies ?value))
           (setf bindings (list (list v ?value))
                 effective-test `(not (,?satisfies ,v))
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which satisfies ~2&~S~2% (it should not)"
                       `',?value v `',?satisfies)))
          ((?predicate ?expected ?actual)
           (process-entry ?predicate ?expected ?actual)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%"
                       `',?actual a `',?predicate e)))
          ((?satisfies ?value)
           (setf bindings (list (list v ?value))
                 effective-test `(,?satisfies ,v)
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which does not satisfy ~2&~S~2%"
                       `',?value v `',?satisfies)))
          (?_
           (setf bindings '()
                 effective-test test
                 default-reason-args (list "~2&~S~2% was NIL." `',test)))))
      `(let ,bindings
         (if ,effective-test
             (add-result 'test-passed :test-expr ',test)
             (process-failure ',test
                              ,@(or reason-args default-reason-args)))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(is 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by IS

Input: (is 'lol-gen::some-name)

Output:
(defmacro is (test &rest reason-args)
  "The DWIM checking operator.

If TEST returns a true value a test-passed result is generated,
otherwise a test-failure result is generated. The reason, unless
REASON-ARGS is provided, is generated based on the form of TEST:

 (predicate expected actual) - Means that we want to check
 whether, according to PREDICATE, the ACTUAL value is
 in fact what we EXPECTED.

 (predicate value) - Means that we want to ensure that VALUE
 satisfies PREDICATE.

 Wrapping the TEST form in a NOT simply produces a negated reason
 string."
  (assert (listp test)
          (test)
          "Argument to IS must be a list, not ~S" test)
  (let (bindings effective-test default-reason-args)
    (with-gensyms (e a v)
      (flet ((process-entry (predicate expected actual &optional negatedp)
               ;; make sure EXPECTED is holding the entry that starts with 'values
               (when (and (consp actual)
                          (eq (car actual) 'values))
                 (assert (not (and (consp expected)
                                   (eq (car expected) 'values))) ()
                                   "Both the expected and actual part is a values expression.")
                 (rotatef expected actual))
               (let ((setf-forms))
                 (if (and (consp expected)
                          (eq (car expected) 'values))
                     (progn
                       (setf expected (copy-list expected))
                       (setf setf-forms (loop for cell = (rest expected) then (cdr cell)
                                              for i from 0
                                              while cell
                                              when (eq (car cell) '*)
                                              collect `(setf (elt ,a ,i) nil)
                                              and do (setf (car cell) nil)))
                       (setf bindings (list (list e `(list ,@(rest expected)))
                                            (list a `(multiple-value-list ,actual)))))
                     (setf bindings (list (list e expected)
                                          (list a actual))))
                 (setf effective-test `(progn
                                         ,@setf-forms
                                         ,(if negatedp
                                              `(not (,predicate ,e ,a))
                                              `(,predicate ,e ,a)))))))
        (list-match-case test
          ((not (?predicate ?expected ?actual))
           (process-entry ?predicate ?expected ?actual t)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is ~2&~S~2%to ~2&~S~2% (it should not be)"
                       `',?actual a `',?predicate e)))
          ((not (?satisfies ?value))
           (setf bindings (list (list v ?value))
                 effective-test `(not (,?satisfies ,v))
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which satisfies ~2&~S~2% (it should not)"
                       `',?value v `',?satisfies)))
          ((?predicate ?expected ?actual)
           (process-entry ?predicate ?expected ?actual)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%"
                       `',?actual a `',?predicate e)))
          ((?satisfies ?value)
           (setf bindings (list (list v ?value))
                 effective-test `(,?satisfies ,v)
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which does not satisfy ~2&~S~2%"
                       `',?value v `',?satisfies)))
          (?_
           (setf bindings '()
                 effective-test test
                 default-reason-args (list "~2&~S~2% was NIL." `',test)))))
      `(let ,bindings
         (if ,effective-test
             (add-result 'test-passed :test-expr ',test)
             (process-failure ',test
                              ,@(or reason-args default-reason-args)))))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(ensure-transaction
  nil
  :key
  nil)

What needs to change: Macro call that should be transformed by ENSURE-TRANSACTION

Input:
(ensure-transaction
  nil
  :key
  nil)

Output:
(defmacro ensure-transaction (&body body)
  "Ensures that body is executed within a transaction, but does not begin a new
transaction if one is already in progress."
  `(call-with-ensured-transaction (lambda () ,@body)))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(handler-case nil)

Problem: Macro call that should be transformed by HANDLER-CASE

Input: (handler-case nil)

Output: (defmacro HANDLER-CASE ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(defmethod nil)

Write a macro that addresses: Macro call that should be transformed by DEFMETHOD

Input: (defmethod nil)

Output:
(defmacro defmethod (name &rest args)
  (handler-case
      (multiple-value-bind (qualifiers specializers lambda-list body)
          (parse-method args)

        (declare (ignore qualifiers))

        (with-gensyms (method)
          (let ((fn-name (gentemp (symbol-name (block-name name)) *method-function-package*)))
            `(progn
               ,(make-method-function name fn-name lambda-list body)

               (let ((,method
                      (walk-environment
                        (c2mop:defmethod ,name ,@args))))

                 (when (combination-options ',name)
                   ,(make-add-method-info name method fn-name body)
                   ,(make-static-dispatch name lambda-list specializers))

                 ,method)))))

    (error (e)
      (simple-style-warning "Error parsing DEFMETHOD form:~%~2T~a" e)
      `(walk-environment
         (c2mop:defmethod ,name ,@args)))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(all-values
  nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by ALL-VALUES

Input:
(all-values
  nil
  (progn))

Output: (defmacro ALL-VALUES ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(is nil (progn))

Issue: Macro call that should be transformed by IS

Input: (is nil (progn))

Output:
(defmacro is (got expected &rest args)
  (with-gensyms (duration result new-args desc)
    (once-only (expected)
      `(let* ((,new-args (list ,@args))
              (,desc (parse-description-and-test ,new-args)))
         (with-catching-errors (:description ,desc :expected ,expected)
           (with-duration ((,duration ,result) ,got)
             (test ,result ,expected ,new-args
                   :duration ,duration)))))))


Instruction:
Generate a defmacro form that transforms code like this:
(c_in)

Pattern to recognize: Macro call that should be transformed by C_IN

Output:
(defmacro c_in (&body body)
  `(c-input (:lazy :once-asked) (progn ,@body)))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(c?dbg
  nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by C?DBG

Input:
(c?dbg
  nil
  (progn))

Output:
(defmacro c?dbg (&body body)
  `(make-c-dependent
    :code ',body
    :value-state :unevaluated
    :debug t
    :rule (c-lambda ,@body)))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(make-$instance nil (progn))

What needs to change: Macro call that should be transformed by MAKE-$INSTANCE

Input: (make-$instance nil (progn))

Output: (defmacro MAKE-$INSTANCE ...)


Instruction:
Generate a defmacro form that transforms code like this:
(->* nil nil)

Pattern to recognize: Macro call that should be transformed by ->*

Input: (->* nil nil)

Output: (defmacro ->* ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-gensyms nil)

Issue: Macro call that should be transformed by WITH-GENSYMS

Input: (with-gensyms nil)

Output:
(defmacro with-gensyms (names &body forms)
  "Binds a set of variables to gensyms and evaluates the implicit progn FORMS.

Each element within NAMES is either a symbol SYMBOL or a pair (SYMBOL
STRING-DESIGNATOR). Bare symbols are equivalent to the pair (SYMBOL SYMBOL).

Each pair (SYMBOL STRING-DESIGNATOR) specifies that the variable named by SYMBOL
should be bound to a symbol constructed using GENSYM with the string designated
by STRING-DESIGNATOR being its first argument."
  `(let ,(mapcar (lambda (name)
                   (multiple-value-bind (symbol string)
                       (etypecase name
                         (symbol
                          (values name (symbol-name name)))
                         ((cons symbol (cons string-designator null))
                          (values (first name) (string (second name)))))
                     `(,symbol (gensym ,string))))
                 names)
     ,@forms))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(without-c-dependency
  nil
  :key
  nil)

Problem: Macro call that should be transformed by WITHOUT-C-DEPENDENCY

Input:
(without-c-dependency
  nil
  :key
  nil)

Output:
(defmacro without-c-dependency (&body body)
  ` (let (*depender*)
      ,@body))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(nsib)

Problem: Macro call that should be transformed by NSIB

Input: (nsib)

Output:
(defmacro nsib (&optional (self-form 'self))
  (let ((self (gensym)))
    `(bwhen (,self ,self-form)
        (cadr (member ,self (kids (fm-parent ,self)))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(-<> nil
  (progn))

Issue: Macro call that should be transformed by -<>

Input:
(-<> nil
  (progn))

Output: (defmacro -<> (init &body exps) (diamond-wand init exps))


Instruction:
Define a macro that eliminates this repetitive pattern:
(nth-value-or nil)

Issue: Macro call that should be transformed by NTH-VALUE-OR

Input: (nth-value-or nil)

Output:
(defmacro nth-value-or (nth-value &body forms)
  "Evaluates FORM arguments one at a time, until the NTH-VALUE returned by one
of the forms is true. It then returns all the values returned by evaluating
that form. If none of the forms return a true nth value, this form returns
NIL."
  (once-only (nth-value)
    (with-gensyms (values)
      `(let ((,values (multiple-value-list ,(first forms))))
         (if (nth ,nth-value ,values)
             (values-list ,values)
             ,(if (rest forms)
                  `(nth-value-or ,nth-value ,@(rest forms))
                  nil))))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(with* nil)

What needs to change: Macro call that should be transformed by WITH*

Input: (with* nil)

Output: (defmacro WITH* ...)


Instruction:
Generate a defmacro form that transforms code like this:
(defjsmacro nil nil)

Pattern to recognize: Macro call that should be transformed by DEFJSMACRO

Input: (defjsmacro nil nil)

Output: (defmacro DEFJSMACRO ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(ignore common-lisp:nil
  (common-lisp:progn))

Write a macro that addresses: Macro call that should be transformed by IGNORE

Input:
(ignore common-lisp:nil
  (common-lisp:progn))

Output: (defmacro IGNORE ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(cmatch 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by CMATCH

Input: (cmatch 'lol-gen::some-name)

Output:
(defmacro cmatch (arg &body clauses)
  "Same as MATCH, except a continuable MATCH-ERROR will be raised if none of the
clauses match."
  (once-only (arg)
    (let ((else `(cerror "Continue."
                         'match-error
                         :values (list ,arg)
                         :patterns ',(mapcar (lambda (c) (list (car c))) clauses))))
      (compile-match-1 arg clauses else))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(destructuring-ecase-of nil
    nil)

Write a macro that addresses: Macro call that should be transformed by DESTRUCTURING-ECASE-OF

Input:
(destructuring-ecase-of nil
    nil)

Output:
(defmacro destructuring-ecase-of (type expr &body body)
  "Like `destructuring-ecase', from Alexandria, but with exhaustivness
checking.

TYPE is a designator for a type, which should be defined as `(member
...)'. At compile time, the macro checks that, taken together, the
symbol at the head of each of the destructuring lists in BODY form an
exhaustive partition of TYPE, and warns if it is not so."
  (expand-destructuring-case-of type expr body 'ecase-of))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(with-pointer-to-vector-data 'lol-gen::some-name)

Problem: Macro call that should be transformed by WITH-POINTER-TO-VECTOR-DATA

Input: (with-pointer-to-vector-data 'lol-gen::some-name)

Output:
(defmacro with-pointer-to-vector-data ((ptr-var vector) &body body)
  "Bind 'ptr-var to a foreign pointer to the data in 'vector."
  (let ((vector-var (gensym (symbol-name '#:vector))))
    `(let ((,vector-var ,vector))
       (ext:with-pinned-object (,vector-var)
         (let ((,ptr-var (sys:vector-sap ,vector-var)))
           ,@body)))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(without-c-dependency
  nil
  nil)

Problem: Macro call that should be transformed by WITHOUT-C-DEPENDENCY

Input:
(without-c-dependency
  nil
  nil)

Output:
(defmacro without-c-dependency (&body body)
  ` (let (*depender*)
      ,@body))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(minf nil nil)

What needs to change: Macro call that should be transformed by MINF

Input: (minf nil nil)

Output: (defmacro MINF ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(defunwalker-handler nil
    nil)

What needs to change: Macro call that should be transformed by DEFUNWALKER-HANDLER

Input:
(defunwalker-handler nil
    nil)

Output: (defmacro DEFUNWALKER-HANDLER ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(class-stealth-mixins nil)

What needs to change: Macro call that should be transformed by CLASS-STEALTH-MIXINS

Input: (class-stealth-mixins nil)

Output: (defmacro CLASS-STEALTH-MIXINS ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(fgatherlet nil
  :key
  nil)

Issue: Macro call that should be transformed by FGATHERLET

Input:
(fgatherlet nil
  :key
  nil)

Output: (defmacro FGATHERLET ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(removef nil nil)

What needs to change: Macro call that should be transformed by REMOVEF

Input: (removef nil nil)

Output: (defmacro REMOVEF ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(declaim)

Write a macro that addresses: Macro call that should be transformed by DECLAIM

Input: (declaim)

Output: (defmacro DECLAIM ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(with-took-usec nil
  (progn))

What needs to change: Macro call that should be transformed by WITH-TOOK-USEC

Input:
(with-took-usec nil
  (progn))

Output:
(defmacro with-took-usec (var &body body)
  (let ((before (gensym "BEFORE")))
    `(let ((,before (get-internal-real-time)))
       (multiple-value-prog1 (progn ,@body)
         (setf ,var (ceiling
                      (* (- (get-internal-real-time) ,before)
                         #.(/ 1000000 internal-time-units-per-second))))))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(lambda-cmatch*
  common-lisp:nil
  (common-lisp:progn))

What needs to change: Macro call that should be transformed by LAMBDA-CMATCH*

Input:
(lambda-cmatch*
  common-lisp:nil
  (common-lisp:progn))

Output:
(defmacro lambda-cmatch* (&body body)
  "Equivalent to (lambda (args...) (cmatch* (args...) BODY...))."
  (multiple-value-bind (preamble clauses) (parse-matcher-body body)
    (let ((gensyms (make-gensyms (caar clauses))))
      `(lambda ,gensyms
         ,@preamble
         (cmatch* ,gensyms
           ,@clauses)))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(f0
  nil
  nil)

Problem: Macro call that should be transformed by F0

Input:
(f0
  nil
  nil)

Output: (defmacro F0 ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(*let nil
  (progn))

Problem: Macro call that should be transformed by *LET

Input:
(*let nil
  (progn))

Output: (defmacro *LET ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(fbindrec nil)

Problem: Macro call that should be transformed by FBINDREC

Input: (fbindrec nil)

Output:
(defmacro fbindrec (bindings &body body &environment *lexenv*)
  "Like `fbind', but creates recursive bindings.

The consequences of referring to one binding in the expression that
generates another are undefined."
  (setf bindings (expand-fbindings bindings))
  (unless bindings
    (return-from fbindrec `(locally ,@body)))
  (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))
           (body decls (parse-body body))
           (simple complex lambda unref
            (partition-fbinds (append bindings lambdas)
                              body))
           (temps (mapcar (op (gensym (string (first _)))) complex))
           (simple-decls complex-decls lambda-decls others
            (partition-declarations-by-kind simple complex lambda decls)))
    `(let ,env
       ,@(unsplice (and env-decls `(declare ,@env-decls)))
       ;; Simple expressions reference functions already defined
       ;; outside of the letrec, so we can handle them with fbind.
       (comment "fbind: Simple")
       (fbind ,simple
         ,@simple-decls
         (comment "fbind: Temps for complex bindings")
         (let ,(loop for temp in temps collect `(,temp #'invalid))
           (declare ,@(loop for temp in temps collect `(function ,temp)))
           (flet ,(loop for (name nil) in complex
                        for temp in temps
                        collect (build-bind/ftype name temp complex-decls env))
             ,@complex-decls
             (comment "fbind: Lambdas")
             (labels (,@(loop for (name lambda) in lambda
                              collect `(,name ,@(cdr lambda))))
               ,@lambda-decls
               (comment "fbind: Unreferenced")
               (progn ,@(mapcar #'second unref))
               (comment "fbind: Complex")
               (psetf ,@(loop for temp in temps
                              for (nil expr) in complex
                              append `(,temp (ensure-function ,expr))))
               (locally ,@others
                 ,@body))))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(ccase-of nil
    :key
  nil)

Write a macro that addresses: Macro call that should be transformed by CCASE-OF

Input:
(ccase-of nil
    :key
  nil)

Output:
(defmacro ccase-of (type keyplace &body body &environment env)
  "Like `ecase-of', but providing a `store-value' restart to correct KEYPLACE and try again."
  (check-exhaustiveness 'case type body env)
  `(ccase ,keyplace ,@body))


Instruction:
Generate a defmacro form that transforms code like this:
(rg? 'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by RG?

Input: (rg? 'lol-gen::some-name)

Output:
(defmacro rg? (id)
  `(fm-find-registered ,id self nil))


Instruction:
Define a macro that eliminates this repetitive pattern:
(metaclass common-lisp:nil)

Issue: Macro call that should be transformed by METACLASS

Input: (metaclass common-lisp:nil)

Output: (defmacro METACLASS ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(callback nil)

Write a macro that addresses: Macro call that should be transformed by CALLBACK

Input: (callback nil)

Output:
(defmacro callback (name)
  `(%callback ',name))


Instruction:
Generate a defmacro form that transforms code like this:
(match common-lisp:nil
  :key
  common-lisp:nil)

Pattern to recognize: Macro call that should be transformed by MATCH

Input:
(match common-lisp:nil
  :key
  common-lisp:nil)

Output:
(defmacro match (what &body clauses)
  #.+match-doc+
  `(match2 ,what
     ,@clauses
     (_ nil)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(collect-max nil nil)

Issue: Macro call that should be transformed by COLLECT-MAX

Input: (collect-max nil nil)

Output: (defmacro COLLECT-MAX ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(some->> nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by SOME->>

Input:
(some->> nil
  (progn))

Output: (defmacro some->> (init &body exps) (arrow-macro init exps t t))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(pushnew nil :key nil)

What needs to change: Macro call that should be transformed by PUSHNEW

Input: (pushnew nil :key nil)

Output: (defmacro PUSHNEW ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(def-launched-iter nil
    (progn))

Problem: Macro call that should be transformed by DEF-LAUNCHED-ITER

Input:
(def-launched-iter nil
    (progn))

Output: (defmacro DEF-LAUNCHED-ITER ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(econd-let nil)

Write a macro that addresses: Macro call that should be transformed by ECOND-LET

Input: (econd-let nil)

Output:
(defmacro econd-let (symbol &body clauses)
  "Like `cond-let' for `econd'."
  `(cond-let ,symbol
     ,@clauses
     (t (error 'econd-failure))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(coexit!)

Issue: Macro call that should be transformed by COEXIT!

Input: (coexit!)

Output: (defmacro COEXIT! ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(class-stealth-mixins 'lol-gen::some-name)

Issue: Macro call that should be transformed by CLASS-STEALTH-MIXINS

Input: (class-stealth-mixins 'lol-gen::some-name)

Output: (defmacro CLASS-STEALTH-MIXINS ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(drelet* nil
  nil)

Issue: Macro call that should be transformed by DRELET*

Input:
(drelet* nil
  nil)

Output: (defmacro DRELET* ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(with-c-syntax common-lisp:nil
  (common-lisp:progn))

Write a macro that addresses: Macro call that should be transformed by WITH-C-SYNTAX

Input:
(with-c-syntax common-lisp:nil
  (common-lisp:progn))

Output:
(defmacro with-c-syntax ((&rest options
			  &key (preprocess t)
                            (reader-level *with-c-syntax-reader-level*)
                            (readtable-case (or *with-c-syntax-reader-case*
                                                (readtable-case *readtable*)))
                            (input-file-pathname nil)
			    (try-add-{} t))
			 &environment *wcs-expanding-environment*
			 &body body)
  "This macro is a entry point of the with-c-syntax system. BODY will be
interpreted as C syntax, executed, and return values.

This macro returns the last form's value if BODY is a compound
statement, or returns NIL if BODY is a compilation unit.

PREPROCESS specifies how to do preprocess. If nil, this macro compiles
BODY without preprocessing. If t, preprocesses and compiles BODY. If
`:preprocess-only', this macro preprocesses BODY and returns the
result as-is.

READER-LEVEL specifies the reader level (see `*with-c-syntax-reader-level*').
This is used when '#include' or '_Pragma()' was used.

READTABLE-CASE specifies the readtable case of symbols in BODY when it
was read.  This affects how to intern C keywords by the preprocessor.

INPUT-FILE-PATHNAME is passed to the preprocessor and used when
'__FILE__' macro was used.

If TRY-ADD-{} is t and an error occurred at parsing, `with-c-syntax'
adds '{' and '}' into the head and tail of FORM respectively, and
tries to parse again."
  (cond
    ((null body)
     nil)
    ((and (length= 1 (the list body))	; with-c-syntax is nested.
	  (starts-with 'with-c-syntax (first body)))
     (destructuring-bind (op_ options2 &body body2)
	 (first body)
       (declare (ignore op_))
       `(with-c-syntax (,@options ,@options2) ,@body2)))
    (t
     (ecase preprocess
       (:preprocess-only
        (preprocessor body reader-level readtable-case input-file-pathname))
       (t
        `(with-c-syntax (:preprocess nil :try-add-{} ,try-add-{})
           ,@(preprocessor body reader-level readtable-case input-file-pathname)))
       ((nil)
        (expand-c-syntax body
		         try-add-{}))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(aprog1 nil
  (progn))

Issue: Macro call that should be transformed by APROG1

Input:
(aprog1 nil
  (progn))

Output:
(defmacro aprog1 (first &body rest)
  "Binds IT to the first form so that it can be used in the rest of the
forms. The whole thing returns IT."
  `(anaphoric prog1 ,first ,@rest))


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-decoder-simple-clos-semantics
  nil)

Issue: Macro call that should be transformed by WITH-DECODER-SIMPLE-CLOS-SEMANTICS

Input:
(with-decoder-simple-clos-semantics
  nil)

Output:
(defmacro with-decoder-simple-clos-semantics (&body body)
  "Execute BODY in a dynamic environement where the decoder semantics
is such as set by SET-DECODER-SIMPLE-CLOS-SEMANTICS."
  `(with-shadowed-custom-vars
     (set-decoder-simple-clos-semantics)
     ,@body))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(nest common-lisp:nil :key common-lisp:nil)

Write a macro that addresses: Macro call that should be transformed by NEST

Input: (nest common-lisp:nil :key common-lisp:nil)

Output:
(defmacro nest (cl:&rest items)
  "A syntactic convenience for function application. Transform

    (nest f g h x)

to

    (f (g (h x)))."
  (cl:assert (cl:<= 2 (cl:list-length items)))
  (cl:let ((last (cl:last items))
           (butlast (cl:butlast items)))
    (cl:reduce (cl:lambda (x acc)
                 (cl:list x acc))
               butlast :from-end cl:t :initial-value (cl:first last))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(create-table nil
    nil)

Problem: Macro call that should be transformed by CREATE-TABLE

Input:
(create-table nil
    nil)

Output:
(defmacro create-table (table column-definitions &body options)
  `(make-statement :create-table
                   ',(expand-expression table)
                   ,(if (listp (car column-definitions))
                        `(list ,@(if column-definitions
                                     (mapcar
                                      (lambda (column)
                                        `(make-column-definition-clause ',(car column) ,@(cdr column)))
                                      column-definitions)
                                     nil))
                        `,column-definitions)
                   ,@(if (and (null (cdr options))
                              (null (car options)))
                         nil
                         options)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(fgathering nil
  nil)

Issue: Macro call that should be transformed by FGATHERING

Input:
(fgathering nil
  nil)

Output: (defmacro FGATHERING ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(collect-min nil)

Problem: Macro call that should be transformed by COLLECT-MIN

Input: (collect-min nil)

Output: (defmacro COLLECT-MIN ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(resolving
  'lol-gen::some-name)

Issue: Macro call that should be transformed by RESOLVING

Input:
(resolving
  'lol-gen::some-name)

Output: (defmacro RESOLVING ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(define-symbol-macro nil nil)

Problem: Macro call that should be transformed by DEFINE-SYMBOL-MACRO

Input: (define-symbol-macro nil nil)

Output: (defmacro DEFINE-SYMBOL-MACRO ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(accumulating-to-and-returning 'lol-gen::some-name)

Issue: Macro call that should be transformed by ACCUMULATING-TO-AND-RETURNING

Input: (accumulating-to-and-returning 'lol-gen::some-name)

Output: (defmacro ACCUMULATING-TO-AND-RETURNING ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(receive nil
    :key
  nil)

Problem: Macro call that should be transformed by RECEIVE

Input:
(receive nil
    :key
  nil)

Output:
(defmacro receive (formals expr &body body)
  "Stricter version of `multiple-value-bind'.

Use `receive' when you want to enforce that EXPR should return a
certain number of values, or a minimum number of values.

If FORMALS is a proper list, then EXPR must return exactly as many
values -- no more and no less -- as there are variables in FORMALS.

If FORMALS is an improper list (VARS . REST), then EXPR must return at
least as many values as there are VARS, and any further values are
bound, as a list, to REST.

Lastly, if FORMALS is a symbol, bind that symbol to all the values
returned by EXPR, as if by `multiple-value-list'.

From Scheme (SRFI-8)."
  ;; It's probably not worth stack-allocating the thunk.
  (cond ((null formals)
         `(multiple-value-call
              (lambda ()
                ,@body)
            ,expr))
        ((atom formals)
         ;; This could also be written:
         #+(or) `(let ((,formals (multiple-value-list ,expr)))
                   ,@body)
         ;; But I want it to be possible to declare FORMALS to have
         ;; dynamic extent, and most Lisps support that for &rest
         ;; lists.
         `(multiple-value-call
              (lambda (&rest ,formals)
                ,@body)
            ,expr))
        ((proper-list-p formals)
         (when (intersection formals lambda-list-keywords)
           (error "Lambda list keywords in formals: ~a" formals))
         `(multiple-value-call
              (lambda ,formals
                ,@body)
            ,expr))
        (t (let* ((last (last formals))
                  (vars (append (butlast formals)
                                (list (car last))))
                  (rest (cdr last)))
             (when (intersection (cons rest vars) lambda-list-keywords)
               (error "Lambda list keywords in formals: ~a" formals))
             `(multiple-value-call
                  (lambda (,@vars &rest ,rest)
                    ,@body)
                ,expr)))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(make* nil :key nil)

Problem: Macro call that should be transformed by MAKE*

Input: (make* nil :key nil)

Output: (defmacro MAKE* ...)


Instruction:
Generate a defmacro form that transforms code like this:
(ensure nil)

Pattern to recognize: Macro call that should be transformed by ENSURE

Input: (ensure nil)

Output:
(defmacro ensure (place &body newval
                        &environment env)
  "Essentially (or place (setf place newval)).

PLACE is treated as unbound if it returns `nil', signals
`unbound-slot', or signals `unbound-variable'.

Note that ENSURE is `setf'-able, so you can do things like
     (incf (ensure x 0))

Cf. `ensure2'."
  (multiple-value-bind (vars vals stores setter getter)
      (get-setf-expansion place env)
    `(let* ,(mapcar #'list vars vals)
       (or (ignore-some-conditions (unbound-slot unbound-variable)
             ,getter)
           (multiple-value-bind ,stores
               (progn ,@newval)
             (when ,(first stores)
               ,setter))))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(min-of 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by MIN-OF

Input: (min-of 'lol-gen::some-name)

Output: (defmacro MIN-OF ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-integrity nil)

Issue: Macro call that should be transformed by WITH-INTEGRITY

Input: (with-integrity nil)

Output:
(defmacro with-integrity ((&optional opcode defer-info debug) &rest body)
  (declare (ignorable debug))
  (when opcode
    (assert (find opcode *ufb-opcodes*) ()
      "Invalid opcode for with-integrity: ~a. Allowed values: ~a" opcode *ufb-opcodes*))
  `(call-with-integrity ,opcode ,defer-info
     (lambda (opcode defer-info)
       (declare (ignorable opcode defer-info))
       ;;;       ,(when debug
       ;;;          `(trc "integrity action entry" opcode defer-info ',body))
       ;;;       (when *c-debug*
       ;;;         (when (eq opcode :change)
       ;;;           (trc "-------w/integ :change go--------------->:" defer-info)))
       ,@body)
     nil
     #+noway (when *c-debug* ',body)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(econd-let nil
  (progn))

Issue: Macro call that should be transformed by ECOND-LET

Input:
(econd-let nil
  (progn))

Output:
(defmacro econd-let (symbol &body clauses)
  "Like `cond-let' for `econd'."
  `(cond-let ,symbol
     ,@clauses
     (t (error 'econd-failure))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(fm-other? nil nil)

Write a macro that addresses: Macro call that should be transformed by FM-OTHER?

Input: (fm-other? nil nil)

Output:
(defmacro fm-other? (md-name &optional (starting 'self) (global-search t))
    `(fm-find-one ,starting ,(if (consp md-name)
                                               `(list ',(car md-name) ,(cadr md-name))
                                               `',md-name)
          :must-find nil
          :global-search ,global-search))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(|^K2|)

Write a macro that addresses: Macro call that should be transformed by ^K2

Output: (defmacro ^k2 () `(kid2 self))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(pass 'lol-gen::some-name)

Problem: Macro call that should be transformed by PASS

Input: (pass 'lol-gen::some-name)

Output:
(defmacro pass (&rest message-args)
  "Simply generate a PASS."
  `(add-result 'test-passed
               :test-expr ',message-args
               ,@(when message-args
                   `(:reason (format nil ,@message-args)))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(nsib 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by NSIB

Input: (nsib 'lol-gen::some-name)

Output:
(defmacro nsib (&optional (self-form 'self))
  (let ((self (gensym)))
    `(bwhen (,self ,self-form)
        (cadr (member ,self (kids (fm-parent ,self)))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(update nil
  :key
  nil)

Write a macro that addresses: Macro call that should be transformed by UPDATE

Input:
(update nil
  :key
  nil)

Output:
(defmacro update (table &body clauses)
  `(make-statement :update
                   ,(expand-expression table) ,@clauses))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(sql nil)

Write a macro that addresses: Macro call that should be transformed by SQL

Input: (sql nil)

Output:
(defmacro sql (form)
  "Convert the given form (a list starting with a keyword) to an SQL query
string at compile time, according to the rules described here. For example:

    (sql (:select '* :from 'country :where (:= 'a 1)))
     \"(SELECT * FROM country WHERE (a = 1))\"

but

    (sql '(:select '* :from 'country :where (:= 'a 1)))

would throw an error. For the later case you need to use sql-compile."
  (let ((list (reduce-strings (sql-expand form))))
    (if (= 1 (length list))
        (car list)
        `(strcat (list ,@list)))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(nth-value nil (progn))

Issue: Macro call that should be transformed by NTH-VALUE

Input: (nth-value nil (progn))

Output: (defmacro NTH-VALUE ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(enable-markup-syntax)

Issue: Macro call that should be transformed by ENABLE-MARKUP-SYNTAX

Input: (enable-markup-syntax)

Output:
(defmacro enable-markup-syntax ()
  '(eval-when (:compile-toplevel :load-toplevel :execute)
    (%enable-markup-syntax)))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(def-suite* 'lol-gen::some-name)

Problem: Macro call that should be transformed by DEF-SUITE*

Input: (def-suite* 'lol-gen::some-name)

Output:
(defmacro def-suite* (name &rest def-suite-args)
  `(progn
     (def-suite ,name ,@def-suite-args)
     (in-suite ,name)))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(defgeneric nil nil)

Write a macro that addresses: Macro call that should be transformed by DEFGENERIC

Input: (defgeneric nil nil)

Output: (defmacro DEFGENERIC ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(old 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by OLD

Input: (old 'lol-gen::some-name)

Output:
(defmacro old (expression)
  "Only available in postconditions, OLD evaluates its expression before the
   primary method is executed and stores it for use in the postcondition."
  (let ((value (gensym)))
    `(if *preparing-postconditions*
         (let ((,value ,expression))
           (push ,value *postcondition-values*)
           ,value)
         (pop *postcondition-values*))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(define-global-var nil (progn))

Problem: Macro call that should be transformed by DEFINE-GLOBAL-VAR

Input: (define-global-var nil (progn))

Output: (defmacro DEFINE-GLOBAL-VAR ...)


Instruction:
Generate a defmacro form that transforms code like this:
(ps-doc
  'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by PS-DOC

Input:
(ps-doc
  'lol-gen::some-name)

Output: (defmacro PS-DOC ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(destructuring-methods nil
    nil)

Issue: Macro call that should be transformed by DESTRUCTURING-METHODS

Input:
(destructuring-methods nil
    nil)

Output: (defmacro DESTRUCTURING-METHODS ...)


Instruction:
Generate a defmacro form that transforms code like this:
(w/uniqs 'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by W/UNIQS

Input: (w/uniqs 'lol-gen::some-name)

Output: (defmacro W/UNIQS ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(iterate
  nil
  :key
  nil)

Problem: Macro call that should be transformed by ITERATE

Input:
(iterate
  nil
  :key
  nil)

Output:
(defmacro iterate (&body body)
  "Jonathan Amsterdam's powerful iteration facility"
  `(iter .,body))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(resolve
  nil
  :key
  nil)

What needs to change: Macro call that should be transformed by RESOLVE

Input:
(resolve
  nil
  :key
  nil)

Output: (defmacro RESOLVE ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(inext 'lol-gen::some-name)

Problem: Macro call that should be transformed by INEXT

Input: (inext 'lol-gen::some-name)

Output: (defmacro INEXT ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(max-of 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by MAX-OF

Input: (max-of 'lol-gen::some-name)

Output: (defmacro MAX-OF ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(v-define-compiler-macro nil
    (progn))

Write a macro that addresses: Macro call that should be transformed by V-DEFINE-COMPILER-MACRO

Input:
(v-define-compiler-macro nil
    (progn))

Output:
(defmacro v-define-compiler-macro (name lambda-list &body body)
  `(define-vari-compiler-macro ,name ,lambda-list ,@body))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(with-yield
  nil
  (progn))

Problem: Macro call that should be transformed by WITH-YIELD

Input:
(with-yield
  nil
  (progn))

Output:
(defmacro with-yield (&body body)
  (let ((point (gensym))
        (current (gensym)))
    `(let (,point ,current)
       (with-call/cc
	 (labels ((yield (&rest values)
		    (setf ,current values)
		    (let/cc k
		      (setf ,point k))))
	   ,@body
	   (setf ,point nil)))
       (gen-lambda ()
	 (cond ((null ,point)
		'generator-stop)
	       (t
		(let ((current ,current))
		  (funcall ,point nil)
		  ;values-handler: see gen-lambda
		  (apply #'values (funcall values-handler current)))))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(alter nil (progn))

Write a macro that addresses: Macro call that should be transformed by ALTER

Input: (alter nil (progn))

Output: (defmacro ALTER ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(with-ps-gensyms nil
  (progn))

What needs to change: Macro call that should be transformed by WITH-PS-GENSYMS

Input:
(with-ps-gensyms nil
  (progn))

Output: (defmacro WITH-PS-GENSYMS ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(who-ps-html)

What needs to change: Macro call that should be transformed by WHO-PS-HTML

Input: (who-ps-html)

Output: (defmacro WHO-PS-HTML ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(upper nil (progn))

What needs to change: Macro call that should be transformed by UPPER

Input: (upper nil (progn))

Output:
(defmacro upper (self &optional (type t))
  `(container-typed ,self ',type))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(iterate nil :key nil)

What needs to change: Macro call that should be transformed by ITERATE

Input: (iterate nil :key nil)

Output: (defmacro ITERATE ...)


Instruction:
Generate a defmacro form that transforms code like this:
(receive nil
    (progn))

Pattern to recognize: Macro call that should be transformed by RECEIVE

Input:
(receive nil
    (progn))

Output:
(defmacro receive (formals expr &body body)
  "Stricter version of `multiple-value-bind'.

Use `receive' when you want to enforce that EXPR should return a
certain number of values, or a minimum number of values.

If FORMALS is a proper list, then EXPR must return exactly as many
values -- no more and no less -- as there are variables in FORMALS.

If FORMALS is an improper list (VARS . REST), then EXPR must return at
least as many values as there are VARS, and any further values are
bound, as a list, to REST.

Lastly, if FORMALS is a symbol, bind that symbol to all the values
returned by EXPR, as if by `multiple-value-list'.

From Scheme (SRFI-8)."
  ;; It's probably not worth stack-allocating the thunk.
  (cond ((null formals)
         `(multiple-value-call
              (lambda ()
                ,@body)
            ,expr))
        ((atom formals)
         ;; This could also be written:
         #+(or) `(let ((,formals (multiple-value-list ,expr)))
                   ,@body)
         ;; But I want it to be possible to declare FORMALS to have
         ;; dynamic extent, and most Lisps support that for &rest
         ;; lists.
         `(multiple-value-call
              (lambda (&rest ,formals)
                ,@body)
            ,expr))
        ((proper-list-p formals)
         (when (intersection formals lambda-list-keywords)
           (error "Lambda list keywords in formals: ~a" formals))
         `(multiple-value-call
              (lambda ,formals
                ,@body)
            ,expr))
        (t (let* ((last (last formals))
                  (vars (append (butlast formals)
                                (list (car last))))
                  (rest (cdr last)))
             (when (intersection (cons rest vars) lambda-list-keywords)
               (error "Lambda list keywords in formals: ~a" formals))
             `(multiple-value-call
                  (lambda (,@vars &rest ,rest)
                    ,@body)
                ,expr)))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(let-match1 common-lisp:nil
    :key
  common-lisp:nil)

What needs to change: Macro call that should be transformed by LET-MATCH1

Input:
(let-match1 common-lisp:nil
    :key
  common-lisp:nil)

Output:
(defmacro let-match1 (pattern arg &body body)
  "Equivalent to (let-match ((PATTERN ARG)) BODY...)."
  `(let-match ((,pattern ,arg)) ,.body))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(finally nil nil)

Write a macro that addresses: Macro call that should be transformed by FINALLY

Input: (finally nil nil)

Output: (defmacro FINALLY ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(collect-append nil nil)

Problem: Macro call that should be transformed by COLLECT-APPEND

Input: (collect-append nil nil)

Output: (defmacro COLLECT-APPEND ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(eval-always
  'lol-gen::some-name)

What needs to change: Macro call that should be transformed by EVAL-ALWAYS

Input:
(eval-always
  'lol-gen::some-name)

Output:
(defmacro eval-always (&body body)
  "Wrap BODY in eval-when with all keys (compile, load and execute) mentioned."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     ,@body))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(alambda nil
  nil)

Write a macro that addresses: Macro call that should be transformed by ALAMBDA

Input:
(alambda nil
  nil)

Output:
(defmacro alambda (lambda-list &body body)
  "Like LAMBDA, except that SELF is bound to the resulting function (via LABELS)
within BODY."
  `(labels ((self ,lambda-list ,@body))
     #'self))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(ftype common-lisp:nil)

What needs to change: Macro call that should be transformed by FTYPE

Input: (ftype common-lisp:nil)

Output: (defmacro FTYPE ...)


Instruction:
Generate a defmacro form that transforms code like this:
(skip-on nil
    nil)

Pattern to recognize: Macro call that should be transformed by SKIP-ON

Input:
(skip-on nil
    nil)

Output:
(defmacro skip-on (features desc &body tests)
  (let ((thunk (gensym "THUNK")))
    `(flet ((,thunk ()
              ,@tests))
       (if (featurep '(or ,@features))
           (with-forced-status (:skipped ,@(if (listp desc) desc (list desc)))
             (,thunk))
           (,thunk)))))


Instruction:
Generate a defmacro form that transforms code like this:
(printing-unreadably nil (progn))

Pattern to recognize: Macro call that should be transformed by PRINTING-UNREADABLY

Input: (printing-unreadably nil (progn))

Output:
(defmacro printing-unreadably (fields-list class-std-form
                               &key (type t) (identity t))
  "Automatically generates the unreadable printing boiler plate to print classes and its fields (from FIELDS-LIST)."
  (let ((g!stream (gensym "STREAM"))
        (name (cadr class-std-form)))
    `(progn ,class-std-form
            (defmethod print-object ((,name ,name) ,g!stream)
              (print-unreadable-object (,name ,g!stream
                                        :type ,type
                                        :identity ,identity)
                (format ,g!stream
                        ,(format nil "~{~a: ~~s~^,~^ ~}" fields-list)
                        ,@(mapcar (lambda (a1)
                                    `(,a1 ,name))
                                  fields-list)))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(eko nil nil)

Issue: Macro call that should be transformed by EKO

Input: (eko nil nil)

Output:
(defmacro eko ((&rest trcargs) &rest body)
  (let ((result (gensym)))
     `(let ((,result ,@body))
        ,(if (stringp (car trcargs))
             `(trc ,(car trcargs) :=> ,result ,@(cdr trcargs))
           `(trc ,(car trcargs) ,(cadr trcargs) :=> ,result ,@(cddr trcargs)))
         ,result)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(lambda-match
  'lol-gen::some-name)

Issue: Macro call that should be transformed by LAMBDA-MATCH

Input:
(lambda-match
  'lol-gen::some-name)

Output: (defmacro LAMBDA-MATCH ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(returning 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by RETURNING

Input: (returning 'lol-gen::some-name)

Output: (defmacro RETURNING ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(make* nil (progn))

Write a macro that addresses: Macro call that should be transformed by MAKE*

Input: (make* nil (progn))

Output: (defmacro MAKE* ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(foreign-funcall nil)

What needs to change: Macro call that should be transformed by FOREIGN-FUNCALL

Input: (foreign-funcall nil)

Output:
(defmacro foreign-funcall (name-and-options &rest args)
  "Wrapper around %FOREIGN-FUNCALL that translates its arguments."
  (let ((name (car (ensure-list name-and-options)))
        (options (cdr (ensure-list name-and-options))))
    (foreign-funcall-form name options args nil)))


Instruction:
Generate a defmacro form that transforms code like this:
(subtest nil
  nil)

Pattern to recognize: Macro call that should be transformed by SUBTEST

Input:
(subtest nil
  nil)

Output:
(defmacro subtest (desc &body body)
  `(%subtest ,desc (lambda () ,@body)))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(collecting
  nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by COLLECTING

Input:
(collecting
  nil
  (progn))

Output:
(defmacro collecting (&body body)
  "Like `with-collector', with the collector bound to the result of
interning `collect' in the current package."
  (with-current-package-symbols (collect)
    `(with-collector (,collect)
       ,@body)))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(newq nil)

Problem: Macro call that should be transformed by NEWQ

Input: (newq nil)

Output: (defmacro NEWQ ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(unless nil (progn))

What needs to change: Macro call that should be transformed by UNLESS

Input: (unless nil (progn))

Output: (defmacro UNLESS ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(c?once
  'lol-gen::some-name)

What needs to change: Macro call that should be transformed by C?ONCE

Input:
(c?once
  'lol-gen::some-name)

Output:
(defmacro c?once (&body body)
  `(make-c-dependent
    :code '(without-c-dependency ,@body)
    :inputp nil
    :value-state :unevaluated
    :rule (c-lambda (without-c-dependency ,@body))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(html5 nil :key nil)

Issue: Macro call that should be transformed by HTML5

Input: (html5 nil :key nil)

Output:
(defmacro html5 (&rest tags)
  `(with-doctype :html5
     (tag->string (cons :html ',tags))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(nest nil :key nil)

Issue: Macro call that should be transformed by NEST

Input: (nest nil :key nil)

Output:
(defmacro nest (&rest things)
  "Like ~>>, but backward.

This is useful when layering `with-x' macros where the order is not
important, and extra indentation would be misleading.

For example:

    (nest
     (with-open-file (in file1 :direction input))
     (with-open-file (in file2 :direction output))
     ...)

Is equivalent to:

    (with-open-file (in file1 :direction input)
      (with-open-file (in file2 :direction output)
        ...))

\(But see `with-open-files').

If the outer macro has no arguments, you may omit the parentheses.

    (nest
      with-standard-io-syntax
      ...)
    ≡ (with-standard-io-syntax
        ...)

From UIOP, based on a suggestion by Marco Baringer."
  (expand-nest things))


Instruction:
Generate a defmacro form that transforms code like this:
(eko-if 'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by EKO-IF

Input: (eko-if 'lol-gen::some-name)

Output:
(defmacro eko-if ((&rest trcargs) &rest body)
  (let ((result (gensym)))
     `(let ((,result ,@body))
         (when ,result
           (trc ,(car trcargs) :res ,result ,@(cdr trcargs)))
         ,result)))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(none-of nil
  nil)

What needs to change: Macro call that should be transformed by NONE-OF

Input:
(none-of nil
  nil)

Output: (defmacro NONE-OF ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(->> 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by ->>

Input: (->> 'lol-gen::some-name)

Output:
(defmacro ->> (x &rest forms)
  "Threads the expr through FORMS. Inserts X as the
   last item in the first form, or in place of % if it is present in the form,
   making a list of it if it is not a list already.
   If there are more forms, inserts the first form
   as the last item in second form, etc."
  (if (first forms)
      (let* ((form (first forms))
             (threaded (if (listp form)
                           (if (member '% form)
                               `(funcall (lambda (%) ,form) ,x)
                               `(,(first form) ,@(rest form) ,x))
                           `(,form ,x))))
        `(->> ,threaded ,@(rest forms)))
      x))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(v-defun nil
    nil)

Problem: Macro call that should be transformed by V-DEFUN

Input:
(v-defun nil
    nil)

Output:
(defmacro v-defun (name args &body body)
  `(define-vari-function ,name ,args ,@body))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(from)

Problem: Macro call that should be transformed by FROM

Input: (from)

Output:
(defmacro from (&rest statements)
  `(make-clause :from ,@(mapcar #'expand-op statements)))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(export-slots
  common-lisp:nil
  :key
  common-lisp:nil)

Write a macro that addresses: Macro call that should be transformed by EXPORT-SLOTS

Input:
(export-slots
  common-lisp:nil
  :key
  common-lisp:nil)

Output: (defmacro EXPORT-SLOTS ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(who-ps-html 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by WHO-PS-HTML

Input: (who-ps-html 'lol-gen::some-name)

Output: (defmacro WHO-PS-HTML ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(dlet* 'lol-gen::some-name)

Issue: Macro call that should be transformed by DLET*

Input: (dlet* 'lol-gen::some-name)

Output: (defmacro DLET* ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(on-conflict-do-update nil (progn))

Write a macro that addresses: Macro call that should be transformed by ON-CONFLICT-DO-UPDATE

Input: (on-conflict-do-update nil (progn))

Output:
(defmacro on-conflict-do-update (conflict-target update-set &optional where-condition)
  `(make-clause :on-conflict-do-update
                ,conflict-target
                ,update-set
                ,where-condition))


Instruction:
Generate a defmacro form that transforms code like this:
(is nil :key nil)

Pattern to recognize: Macro call that should be transformed by IS

Input: (is nil :key nil)

Output:
(defmacro is (comp expected form &optional description &rest format-args)
  `(eval-in-context
    *context*
    (make-instance 'comparison-result
                   :expression '(is ,comp ,expected ,form)
                   :value-form ',form
                   :body (lambda () ,form)
                   :expected ,expected
                   :comparison ,(maybe-quote comp)
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(jand nil (progn))

Write a macro that addresses: Macro call that should be transformed by JAND

Input: (jand nil (progn))

Output:
(defmacro jand (&rest args)
  "JSON-aware version of `cl:and'."
  `(and ,@(loop for arg in args
                collecting `(jwhen ,arg ,arg))))


Instruction:
Generate a defmacro form that transforms code like this:
(prog* ())

Pattern to recognize: Macro call that should be transformed by PROG*

Input: (prog* ())

Output: (defmacro PROG* ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(modf-eval nil nil)

What needs to change: Macro call that should be transformed by MODF-EVAL

Input: (modf-eval nil nil)

Output:
(defmacro modf-eval (&rest args)
  `(progn ,@args))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(when 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by WHEN

Input: (when 'lol-gen::some-name)

Output: (defmacro WHEN ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(def-kid-slots nil nil)

What needs to change: Macro call that should be transformed by DEF-KID-SLOTS

Input: (def-kid-slots nil nil)

Output:
(defmacro def-kid-slots (&rest slot-defs)
  `(lambda (self)
     (declare (ignorable self))
     (list ,@slot-defs)))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(with-column-writers nil
  (progn))

What needs to change: Macro call that should be transformed by WITH-COLUMN-WRITERS

Input:
(with-column-writers nil
  (progn))

Output:
(defmacro with-column-writers ((&rest defs) &body body)
  "Provides control over the way get-dao, select-dao, and query-dao read values
from the database. This is not commonly needed, but can be used to reduce the
amount of queries a system makes. writers should be a list of alternating
column names (strings or symbols) and writers, where writers are either
symbols referring to a slot in the objects, or functions taking two arguments ―
an instance and a value ― which can be used to somehow store the value in the
new instance. When any DAO-fetching function is called in the body, and
columns matching the given names are encountered in the result, the writers
are used instead of the default behaviour (try and store the value in the slot
that matches the column name).

An example of using this is to add some non-column slots to a DAO class, and
use query-dao within a with-column-writers form to pull in extra information
about the objects, and immediately store it in the new instances."
  `(let ((*custom-column-writers*
           (append (list ,@(loop :for (field writer) :on defs :by #'cddr
                                 :collect `(cons (to-sql-name ,field nil) ,writer)))
                   *custom-column-writers*)))
     ,@body))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(the-part nil nil)

Write a macro that addresses: Macro call that should be transformed by THE-PART

Input: (the-part nil nil)

Output: (defmacro THE-PART ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(cond-let nil
  nil)

What needs to change: Macro call that should be transformed by COND-LET

Input:
(cond-let nil
  nil)

Output:
(defmacro cond-let (var &body body)
  "Like COND. VAR will be bound to the passed COND test."
  `(let (,var)
     (cond
       ,@(mapcar #``((setf ,var ,(car %)) ,(cadr %))
                 ;; uses the fact, that SETF returns the value set
                 body))))


Instruction:
Generate a defmacro form that transforms code like this:
(bind-custom-vars nil)

Pattern to recognize: Macro call that should be transformed by BIND-CUSTOM-VARS

Input: (bind-custom-vars nil)

Output:
(defmacro bind-custom-vars ((&rest customizations) &body body)
  `(let ,(loop-on-custom (key var value) customizations
            collect (list var value))
     ,@body))


Instruction:
Generate a defmacro form that transforms code like this:
(lambda-coro
  'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by LAMBDA-CORO

Input:
(lambda-coro
  'lol-gen::some-name)

Output: (defmacro LAMBDA-CORO ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(collect-hash nil :key nil)

What needs to change: Macro call that should be transformed by COLLECT-HASH

Input: (collect-hash nil :key nil)

Output: (defmacro COLLECT-HASH ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(defconstant nil nil)

Problem: Macro call that should be transformed by DEFCONSTANT

Input: (defconstant nil nil)

Output: (defmacro DEFCONSTANT ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(with-column-writers nil)

Problem: Macro call that should be transformed by WITH-COLUMN-WRITERS

Input: (with-column-writers nil)

Output:
(defmacro with-column-writers ((&rest defs) &body body)
  "Provides control over the way get-dao, select-dao, and query-dao read values
from the database. This is not commonly needed, but can be used to reduce the
amount of queries a system makes. writers should be a list of alternating
column names (strings or symbols) and writers, where writers are either
symbols referring to a slot in the objects, or functions taking two arguments ―
an instance and a value ― which can be used to somehow store the value in the
new instance. When any DAO-fetching function is called in the body, and
columns matching the given names are encountered in the result, the writers
are used instead of the default behaviour (try and store the value in the slot
that matches the column name).

An example of using this is to add some non-column slots to a DAO class, and
use query-dao within a with-column-writers form to pull in extra information
about the objects, and immediately store it in the new instances."
  `(let ((*custom-column-writers*
           (append (list ,@(loop :for (field writer) :on defs :by #'cddr
                                 :collect `(cons (to-sql-name ,field nil) ,writer)))
                   *custom-column-writers*)))
     ,@body))


Instruction:
Generate a defmacro form that transforms code like this:
(match nil
    :key
  nil)

Pattern to recognize: Macro call that should be transformed by MATCH

Input:
(match nil
    :key
  nil)

Output:
(defmacro match (adt obj &body clauses)
  "Perform pattern matching on OBJ with (adt-type) ADT.

Each clause must have the following syntax:

<var> := <symbol> | '_'
<lhs> := '_'
       | (<symbol> <var>*)
<clause> := (<lhs> <lisp code>)

The symbol '_' denotes a wildcard, as well as a fallthough.

Note that pattern matching is only shallow (patterns are one-level
deep).
"
  (assert (symbolp adt)
          (adt)
          "MATCH requires a symbol for the first argument. Given ~S."
          adt)

  (let ((ctors (mapcar #'car (get-constructors adt)))
        (types (mapcar (lambda (clause)
                         (ensure-car (car clause)))
                       clauses))
        (once (gensym "OBJ-")))

    ;; Check for duplicate matches.
    (let ((dupes (duplicates types)))
      (when dupes
        (warn "Duplicate matching clauses exist. Duplicate pattern ~
               constructors:~{ ~S~}"
              dupes)))

    ;; Check for match exhaustiveness.
    (unless (some #'wild? types)
      (let ((diff (set-difference ctors types)))
        (when diff
          (warn "Non-exhaustive match on ~A data ~
                 type. Missing cases:~{ ~S~}" adt diff))))

    ;; Generate the matching code.
    `(let ((,once ,obj))
       (check-type ,once ,adt)
       (etypecase ,once
         ,@(loop :for (bindings . body) :in clauses
                 :collect (let ((type (ensure-car bindings)))
                            (if (wild? type)
                                `(t ,@body)
                                `(,type
                                  (with-data ,(ensure-list bindings)
                                             ,once
                                    ,@body)))))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(nconcf nil)

Issue: Macro call that should be transformed by NCONCF

Input: (nconcf nil)

Output: (defmacro NCONCF ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(let-match common-lisp:nil
  :key
  common-lisp:nil)

What needs to change: Macro call that should be transformed by LET-MATCH

Input:
(let-match common-lisp:nil
  :key
  common-lisp:nil)

Output:
(defmacro let-match (bindings &body body)
  "Similar to LET, except not only a variable but also a pattern can
be used in BINDINGS."
  `(ematch* ,(mapcar #'cadr bindings)
     (,(mapcar #'car bindings) ,.body)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(any-of nil
  nil)

Issue: Macro call that should be transformed by ANY-OF

Input:
(any-of nil
  nil)

Output: (defmacro ANY-OF ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-took-usec nil
  nil)

Issue: Macro call that should be transformed by WITH-TOOK-USEC

Input:
(with-took-usec nil
  nil)

Output:
(defmacro with-took-usec (var &body body)
  (let ((before (gensym "BEFORE")))
    `(let ((,before (get-internal-real-time)))
       (multiple-value-prog1 (progn ,@body)
         (setf ,var (ceiling
                      (* (- (get-internal-real-time) ,before)
                         #.(/ 1000000 internal-time-units-per-second))))))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(lambda-cmatch1 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by LAMBDA-CMATCH1

Input: (lambda-cmatch1 'lol-gen::some-name)

Output:
(defmacro lambda-cmatch1 (pattern &body body)
  "Equivalent to (lambda (arg) (cmatch arg (PATTERN BODY...)))."
  `(lambda-cmatch (,pattern ,@body)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-special-initargs nil
  nil)

Issue: Macro call that should be transformed by WITH-SPECIAL-INITARGS

Input:
(with-special-initargs nil
  nil)

Output: (defmacro WITH-SPECIAL-INITARGS ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(in-suite* 'lol-gen::some-name)

Issue: Macro call that should be transformed by IN-SUITE*

Input: (in-suite* 'lol-gen::some-name)

Output:
(defmacro in-suite* (suite-name &key in)
  "Just like in-suite, but silently creates missing suites."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (%in-suite ,suite-name :in ,in :fail-on-error nil)))


Instruction:
Generate a defmacro form that transforms code like this:
(-<> nil nil)

Pattern to recognize: Macro call that should be transformed by -<>

Input: (-<> nil nil)

Output: (defmacro -<> ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(m 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by M

Input: (m 'lol-gen::some-name)

Output: (defmacro M ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(fm^ 'lol-gen::some-name)

Issue: Macro call that should be transformed by FM^

Input: (fm^ 'lol-gen::some-name)

Output:
(defmacro fm^ (md-name &key (skip-tree 'self) (must-find t))
  `(without-c-dependency
    (fm-find-one (fm-parent self) ,md-name
      :skip-tree ,skip-tree
      :must-find ,must-find
      :global-search t)))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(make-nodelist nil)

Problem: Macro call that should be transformed by MAKE-NODELIST

Input: (make-nodelist nil)

Output:
(defmacro make-nodelist (items &key (prepend nil) (quoty nil))
  "Build general or specific nodelist."
  (let ((prepend (if (listp prepend) prepend `(,prepend))))
    `(nodelist
      (list ,@(loop for i in items collect
		(if prepend
		    (if quoty
			`(,@prepend (quoty ,i))
			`(,@prepend ,i))
		    `(make-node-function (quoty ,i))))))))


Instruction:
Generate a defmacro form that transforms code like this:
(lambda-bind nil
  (progn))

Pattern to recognize: Macro call that should be transformed by LAMBDA-BIND

Input:
(lambda-bind nil
  (progn))

Output:
(defmacro lambda-bind ((&rest instrs) &body body)
  "Use `bind' to allow restructuring of argument to lambda expressions.

This lets you funcall and destructure simultaneously. For example

    (let ((fn (lambda-bind ((a b) c) (cons a c))))
      (funcall fn '(1 2) 3))
    ;; => (1 . 3)

Via eschulte (see git://gist.github.com/902174.git).
"
  #+(or)
  (declare (indent 1))
  (let* ((evald-instrs instrs)
         (syms (mapcar (lambda (_)
			 (declare (ignore _))
			 (gensym))
		       evald-instrs)))
    `(lambda ,syms (bind ,(mapcar #'list evald-instrs syms) ,@body))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(dowhile-let 'lol-gen::some-name)

Problem: Macro call that should be transformed by DOWHILE-LET

Input: (dowhile-let 'lol-gen::some-name)

Output:
(defmacro dowhile-let ((var test) &body body)
  "Like DOWHILE. VAR will be bound to TEST."
  `(do ((,var ,test ,test))
       ((not ,var))
     ,@body))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(fm-map nil nil)

Problem: Macro call that should be transformed by FM-MAP

Input: (fm-map nil nil)

Output:
(defmacro fm-map (fn md-name)
         `(mapcar ,fn (fm-find-all self ',md-name)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(fbindrec* nil
  :key
  nil)

Issue: Macro call that should be transformed by FBINDREC*

Input:
(fbindrec* nil
  :key
  nil)

Output:
(defmacro fbindrec* (bindings &body body &environment *lexenv*)
  "Like `fbindrec`, but the function defined in each binding can be
used in successive bindings."
  (setf bindings (expand-fbindings bindings))
  (unless bindings
    (return-from fbindrec* `(locally ,@body)))
  (mvlet* ((env env-decls binds lambdas (analyze-fbinds bindings *lexenv*))
           (simple complex lambda unref
            (partition-fbinds (append binds lambdas)
                              body))
           (temps (mapcar (op (gensym (string (first _)))) complex))
           (body decls (parse-body body))
           (simple-decls complex-decls lambda-decls others
            (partition-declarations-by-kind simple complex lambda decls)))
    `(let
         ;; Use dummies when we can (with ensure-function).
         ,(loop for (var init) in env
                collect (if (and (listp init)
                                 (eql (car init) 'ensure-function))
                            `(,var #'invalid)
                            var))
       ,@(unsplice (and env-decls `(declare ,@env-decls)))
       (comment "fbind: Simple bindings")
       (fbind ,simple
         ,@simple-decls
         (comment "fbind: Temps for complex bindings")
         (let ,(loop for temp in temps collect `(,temp #'invalid))
           (declare ,@(loop for temp in temps collect `(function ,temp)))
           (flet ,(loop for (name nil) in complex
                        for temp in temps
                        collect (build-bind/ftype name temp complex-decls env))
             ,@complex-decls
             (comment "fbind: Lambdas")
             (labels (,@(loop for (name lambda) in lambda
                              collect `(,name ,@(cdr lambda))))
               ,@lambda-decls
               (comment "fbind: Interleave unreferenced and complex bindings in order.")
               ,@(remove nil
                         (loop for (name nil) in bindings
                               append (or (loop for (uname init) in unref
                                                if (eql uname name)
                                                  return (list init))
                                          (loop for (cname init) in complex
                                                for temp in temps
                                                if (eql cname name)
                                                  return `((setf ,temp (ensure-function ,init)))))))
               (comment "fbind: Set the `env` variables for the lambdas")
               (setf ,@(apply #'append env))
               (locally ,@others
                 ,@body))))))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(local*
  nil)

Write a macro that addresses: Macro call that should be transformed by LOCAL*

Input:
(local*
  nil)

Output:
(defmacro local* (&body body)
  "Like `local', but leave the last form in BODY intact.

     (local*
       (defun aux-fn ...)
       (defun entry-point ...))
     =>
     (labels ((aux-fn ...))
       (defun entry-point ...))"
  `(local
     ,@(butlast body)
     (without-internal-definitions ,@(last body))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(w/uniqs nil
  :key
  nil)

What needs to change: Macro call that should be transformed by W/UNIQS

Input:
(w/uniqs nil
  :key
  nil)

Output: (defmacro W/UNIQS ...)


Instruction:
Generate a defmacro form that transforms code like this:
(with-array nil
  nil)

Pattern to recognize: Macro call that should be transformed by WITH-ARRAY

Input:
(with-array nil
  nil)

Output:
(defmacro with-array ((&optional (stream '*json-output*)) &body body)
  "Open a JSON Array, run BODY, then close the Array.  Inside the BODY,
AS-ARRAY-MEMBER or ENCODE-ARRAY-MEMBER should be called to encode
Members of the Array."
  `(with-aggregate (array #\[ #\] ,stream) ,@body))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(defjsmacro 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by DEFJSMACRO

Input: (defjsmacro 'lol-gen::some-name)

Output: (defmacro DEFJSMACRO ...)