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

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

Input:
(advisable-lambda nil
  (progn))

Output: (defmacro ADVISABLE-LAMBDA ...)


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

Problem: Macro call that should be transformed by C-INPUT

Input: (c-input nil (progn))

Output:
(defmacro c-input ((&rest keys) &optional (value nil valued-p))
  `(make-cell
    :inputp t
    :value-state ,(if valued-p :valid :unbound)
    :value ,value
    ,@keys))


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

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

Input: (vect-of nil :key nil)

Output: (defmacro VECT-OF ...)


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

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

Input: (make-window-or-instance nil)

Output: (defmacro MAKE-WINDOW-OR-INSTANCE ...)


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

Write a macro that addresses: Macro call that should be transformed by ORDER-BY

Input: (order-by)

Output: (defmacro ORDER-BY ...)


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

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

Input: (fm-otherv? 'lol-gen::some-name)

Output:
(defmacro fm-otherv? (md-name &optional (starting 'self) (global-search t))
  `(fm-other-v ,md-name ,starting ,global-search))


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

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

Input: (time nil)

Output: (defmacro TIME ...)


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

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

Input: (for nil nil)

Output: (defmacro FOR ...)


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

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

Input: (with-array 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:
Generate a defmacro form that transforms code like this:
(if-and-let* nil
  nil)

Pattern to recognize: Macro call that should be transformed by IF-AND-LET*

Input:
(if-and-let* nil
  nil)

Output:
(defmacro if-and-let* (bindings &body (then-form &optional else-form))
  "Like `and-let*', but with an `else' clause.
Note that unlike `if-let*', the variables in BINDINGS are only bound
for THEN-FORM."
  (with-unique-names (block-name)
    `(block ,block-name
       (and-let* ,bindings
         (return-from ,block-name ,then-form))
       ,else-form)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(local-output
  nil
  nil)

Issue: Macro call that should be transformed by LOCAL-OUTPUT

Input:
(local-output
  nil
  nil)

Output: (defmacro LOCAL-OUTPUT ...)


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

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

Input: (right nil :key nil)

Output:
(defmacro right (parser &rest parsers)
  "Combination of parsers yielding the result of the rightmost one."
  `(*> ,parser ,@parsers))


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

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

Input:
(lambda-ematch
  common-lisp:nil
  common-lisp:nil)

Output:
(defmacro lambda-ematch (&body body)
  "Equivalent to (lambda (arg) (ematch arg BODY...))."
  (multiple-value-bind (preamble clauses) (parse-matcher-body body)
    (with-gensyms (clause)
      `(lambda (,clause)
         ,@preamble
         (ematch ,clause
           ,@clauses)))))


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

Issue: Macro call that should be transformed by GENERATING

Input: (generating nil nil)

Output: (defmacro GENERATING ...)


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

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

Input:
(defmethod* nil
    :key
  nil)

Output: (defmacro DEFMETHOD* ...)


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

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

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

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


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

Write a macro that addresses: Macro call that should be transformed by POP-ASSOC

Input: (pop-assoc nil :key nil)

Output:
(defmacro pop-assoc (key alist &rest args &environment env)
  "Like `assoc' but, if there was a match, delete it from ALIST.

From Newlisp."
  (multiple-value-bind (vars vals new setter getter)
      (get-setf-expansion alist env)
    (with-gensyms (match)
      `(let* (,@(mapcar #'list vars vals)
              (,(car new) ,getter))
         (let ((,match (assoc ,key ,(car new) ,@args)))
           (declare (list ,match))
           (prog1 ,match
             (when ,match
               (setf ,(car new) (efface ,match ,(car new))))
             ,setter))))))


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

Issue: Macro call that should be transformed by DEFSTORE

Input:
(defstore nil
    nil)

Output:
(defmacro defstore (store-name store-lambda-list &body body &environment env)
  (let* ((store-class-name (second (find :store-class body :key #'first)))
         (store-class (etypecase store-class-name
                        (null (find-class 'standard-store))
                        (symbol (find-class store-class-name))))
         (form (apply #'defstore-using-class store-class store-name store-lambda-list
                      :environment env
                      (mapcan #'(lambda (item)
                                  (cond ((eql (first item) :store-class)
                                         `(:store-class ',store-class-name))
                                        ((and (member (first item) '(:documentation :specialization-class)))
                                         (if (= 2 (length item))
                                             item
                                             (error "Invalid store definition option: ~W." item)))
                                        (t
                                         (list (first item) (rest item)))))
                              body))))
    `(eval-when (:compile-toplevel :load-toplevel :execute)
       ,form)))


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

What needs to change: Macro call that should be transformed by WITH-CONTEXT-VARIABLES

Input: (with-context-variables nil)

Output:
(defmacro with-context-variables ((&rest vars) &body body)
  `(symbol-macrolet
       ,(loop for var in vars
              for form = `(context ,(intern (string var) :keyword))
              collect `(,var ,form))
     ,@body))


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

Problem: Macro call that should be transformed by DOITER

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

Output:
(defmacro doiter (name/iter &body body)
  "Sames as DOITERS however for the special case of iterating over a
   single sequence.

   The macro arguments can be in one of the following two forms:

    1. (NAME (ITER &REST ARGS) &BODY BODY)

    2. ((ITER &REST ARGS) &BODY BODY)

   NAME is the block name, NIL if not given.

   ITER is the variable to which the sequence iterator is bound.

   ARGS are the arguments passed to the ITERATOR function, the result
   of which is bound to ITER.

   BODY is the list of forms in the loop body."

  (let-if ((name name/iter)
           (iter (first body) name/iter)
           (body (rest body) body))
      (symbolp name/iter)

    (destructuring-bind (iter &rest args) iter
      `(doiters ,name ((,iter ,@args)) ,@body))))


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

Issue: Macro call that should be transformed by DO-ITER-VALUES

Input: (do-iter-values 'lol-gen::some-name)

Output:
(defmacro do-iter-values ((&rest iters) &body forms)
  "Iterate over the remaining elements of a sequence pointed to by static iterators.

   Evaluate FORMS at each iteration, for each remaining element, until
   one of the iterators reaches the end of the sequence.

   NOTE: May only be used inside a WITH-ITERATORS form.

   ITERS:

     List of bindings. Each element is of the form (PATTERN ITER),
     interpreted as if to WITH-ITER-VALUE, where PATTERN is a binding
     pattern, for the binding to the sequence element value, and ITER
     is a static iterator identifier symbol, introduced in a parent
     WITH-ITERATORS form.

   FORMS

     List of forms evaluated for each remaining element in the
     sequences pointed to by the static iterators.

     At each evaluation the next element of each sequence, pointed by
     each ITER in ITERS, is bound to the variable(s) specified by the
     corresponding PATTERN. After which the iterators are advanced to
     the next elements.

   If one of the iterators has reached the end of its sequence, a
   non-local jump outside the enclosing WITH-ITERATORS form is
   performed, i.e. any forms following this form, within the enclosing
   WITH-ITERATORS form, will not be evaluated."

  (with-gensyms (start)
    `(tagbody
        ,start
        (with-iter-values ,iters ,@forms)
        (go ,start))))


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

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

Input:
(iterate
  nil
  (progn))

Output: (defmacro ITERATE ...)


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

Problem: Macro call that should be transformed by GLOBAL

Input:
(global
  nil
  :key
  nil)

Output: (defmacro GLOBAL ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(defun-match common-lisp:nil
    (common-lisp:progn))

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

Input:
(defun-match common-lisp:nil
    (common-lisp:progn))

Output:
(defmacro defun-match (name (arg) &body body)
  "Equivalent to (defun (arg) [decl-and-docstring] (match arg (PATTERN BODY...)))."
  (multiple-value-bind (preamble clauses) (parse-matcher-body body)
    `(defun ,name (,arg)
       ,@preamble
       (match ,arg
         ,@clauses))))


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

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

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

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


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

What needs to change: Macro call that should be transformed by SUMMING-TO-AND-RETURNING

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

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


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

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

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

Output:
(defmacro c?1 (&body body)
  `(c?once ,@body))


Instruction:
Generate a defmacro form that transforms code like this:
(declaim (quote lol-gen::some-name))

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

Input: (declaim (quote lol-gen::some-name))

Output: (defmacro DECLAIM ...)


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

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

Input: (dynamic-let* nil)

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


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

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

Input: (<*> nil (progn))

Output:
(defmacro <*> (parser &rest parsers)
  "Combination of parsers yielding all results as a list."
  (let ((offset (gensym "<*>-OFFSET")))
    `(lambda (,offset)
       ,(labels ((recurse (ps i)
                   (if (null ps)
                       `(ok ,i nil)
                       (let ((res  (gensym "<*>-RES"))
                             (next (gensym "<*>-NEXT")))
                         `(multiple-value-bind (,res ,next) (funcall ,(car ps) ,i)
                            (if (failure? ,res)
                                (fail ,next)
                                (fmap (lambda (xs) (cons ,res xs))
                                      ,(recurse (cdr ps) `,next))))))))
          (recurse (cons parser parsers) offset)))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(define-declaration nil
    (progn))

Issue: Macro call that should be transformed by DEFINE-DECLARATION

Input:
(define-declaration nil
    (progn))

Output: (defmacro DEFINE-DECLARATION ...)


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

What needs to change: Macro call that should be transformed by DEF$FRAME

Input: (def$frame nil :key nil)

Output: (defmacro DEF$FRAME ...)


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

Issue: Macro call that should be transformed by PROG

Input: (prog () nil)

Output: (defmacro PROG ...)


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

Write a macro that addresses: Macro call that should be transformed by ITH-VALUE

Input: (ith-value nil :key nil)

Output: (defmacro ITH-VALUE ...)


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

Pattern to recognize: Macro call that should be transformed by DELETE-FROM

Input: (delete-from 'lol-gen::some-name)

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


Instruction:
Define a macro that eliminates this repetitive pattern:
(ensure-transaction
  nil
  (progn))

Issue: Macro call that should be transformed by ENSURE-TRANSACTION

Input:
(ensure-transaction
  nil
  (progn))

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:
Create a Common Lisp macro for the following transformation. Before code:
(drop-table nil)

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

Input: (drop-table nil)

Output:
(defmacro drop-table (table &key if-exists)
  `(make-statement :drop-table
                   ,(expand-expression table) :if-exists ,if-exists))


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

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

Input:
(cond-bind nil
  nil)

Output: (defmacro COND-BIND ...)


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

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

Input: (maxf nil nil)

Output: (defmacro MAXF ...)


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

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

Input: (defmessage nil (progn))

Output: (defmacro DEFMESSAGE ...)


Instruction:
Generate a defmacro form that transforms code like this:
(sum-of nil
  nil)

Pattern to recognize: Macro call that should be transformed by SUM-OF

Input:
(sum-of nil
  nil)

Output: (defmacro SUM-OF ...)


Instruction:
Generate a defmacro form that transforms code like this:
(ensure-arg-list-key-value! nil :key nil)

Pattern to recognize: Macro call that should be transformed by ENSURE-ARG-LIST-KEY-VALUE!

Input: (ensure-arg-list-key-value! nil :key nil)

Output:
(defmacro ensure-arg-list-key-value! (default ids place &key (test '#'equalper) (key '#'identity))
  `(progn
    (iter (for id in (ensure-list ,ids))
      (setf ,place (ensure-arg-list-key-value ,default id ,place :test ,test :key ,key)))
    ,place))


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

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

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

Output: (defmacro DO-ITERATOR ...)


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

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

Input: (with-collectors 'lol-gen::some-name)

Output:
(defmacro with-collectors ((&rest collectors) &body body)
  "Like `with-collector', with multiple collectors.
Returns the final value of each collector as multiple values.

     (with-collectors (x y z)
       (x 1)
       (y 2)
       (z 3))
     => '(1) '(2) '(3)"
  ;; Warn if there are duplications in COLLECTORS.
  (when (> (length collectors)
           (length (remove-duplicates collectors)))
    (warn "Duplicated collectors in with-collectors form: ~s" collectors))
  (with-gensyms (outer)
    `(block ,outer
       ,(reduce (lambda (form collector)
                  `(with-collector (,collector)
                     ,form))
                collectors
                :initial-value
                `(progn
                   ,@body
                   (return-from ,outer
                     (values ,@(mapcar #'list collectors))))))))


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

Problem: Macro call that should be transformed by DEFSUBST

Input:
(defsubst nil
    (progn))

Output:
(defmacro defsubst (name params &body body)
  "Define an inline function.

     (defsubst fn ...)
     ≡ (declaim (inline fn))
       (defun fn ...)

The advantage of a separate defining form for inline functions is that
you can't forget to declaim the function inline before defining it –
without which it may not actually end up being inlined.

From Emacs and other ancient Lisps."
  `(progn
     (declaim (inline ,name))
     (defun ,name ,params
       ,@body)))


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

Problem: Macro call that should be transformed by DEFGENERIC

Input: (defgeneric nil (progn))

Output:
(defmacro defgeneric (name (&rest lambda-list) &rest options)
  (with-gensyms (gf)
    (flet ((make-save-method (args)
             (with-gensyms (method)
               (multiple-value-bind (qualifiers specializers lambda-list body)
                   (parse-method args)

                 (let ((fn-name (gentemp (symbol-name (block-name name)) *method-function-package*)))
                   (list `(let ((,method (find-method% ,gf ',qualifiers ',specializers)))
                            ,(make-add-method-info name method fn-name body :remove-on-redefine-p t))

                         (make-method-function name fn-name lambda-list body)

                         (make-static-dispatch name lambda-list specializers)))))))

      (let ((combination 'standard)
            (combination-options))

        `(progn
           (walk-environment
             (c2mop:defgeneric ,name ,lambda-list ,@options))

           (eval-when (:compile-toplevel :load-toplevel :execute)
             (add-compiler-macro ',name)
             (remove-defined-methods ',name))

           (let ((,gf (fdefinition ',name)))
             (when (typep ,gf 'generic-function)
               ,@(handler-case
                     (append
                      (mappend
                       (lambda-match
                         ((list* :method args)
                          (make-save-method args))

                         ((list* :method-combination name options)
                          (setf combination name)
                          (setf combination-options options)))

                       options)

                      `((setf (combination-options ',name)
                              '(,combination ,combination-options))))

                   (error (e)
                     (simple-style-warning "Error parsing DEFGENERIC form:~%~a" e)
                     nil)))

             ,gf))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(matrix-ecase nil)

Issue: Macro call that should be transformed by MATRIX-ECASE

Input: (matrix-ecase nil)

Output: (defmacro MATRIX-ECASE ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(define-alias-binding nil nil)

Issue: Macro call that should be transformed by DEFINE-ALIAS-BINDING

Input: (define-alias-binding nil nil)

Output:
(defmacro define-alias-binding (name referenced-binding-name)
  `(progn (setf (binding ',name) ',referenced-binding-name)
          ',name))


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

Problem: Macro call that should be transformed by SCASE

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

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


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

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

Input: (iter)

Output:
(defmacro iter (&body body &environment env)
  "Jonathan Amsterdam's powerful and extensible iteration facility,
providing multiple accumulation, generators, memory of previous
iterations, over 50 clauses to start with and a Lisp-like syntax.
Evaluate (iter:display-iter-clauses) for an overview of clauses."
  (let* ((*env* env)
         (*result-var* (genvar 'result))
         (*type-alist* nil)
         (*declare-variables* *always-declare-variables*)
         (*bindings* nil)
         (*internal-variables* nil)
         (*previous-vars-alist* nil)
         (*declarations* nil)
         (*loop-body-wrappers* nil)
         (*accum-var-alist* nil)
         (*shared-bindings-alist* nil)
         (*top-level?* t)
         (*declaration-context?* nil)
         (*temps* nil)
         (*temps-in-use* nil)
         (*driver-info-alist* nil)
         (*block-name* (when (symbolp (car body))
                         (pop body)))
         (*loop-top*  (ensure-symbol *block-name* :format "loop-top-~a"))
         (*loop-step* (ensure-symbol *block-name* :format "loop-step-~a"))
         (*loop-end*  (ensure-symbol *block-name* :format "loop-end-~a"))
         (*loop-step-used?* nil)
         (*loop-end-used?* nil))
    (process-top-level-decls body)
    (multiple-value-bind (body decls init-code steppers final-code final-prot)
        (walk-list body)
      (multiple-value-bind (init step)
          (insert-previous-code)
        (augment init-code init)
        (augment steppers step)
        (prepend (default-driver-code) body)
        (let ((it-bod `(block ,*block-name*
                         (tagbody
                            ,.init-code
                            ,*loop-top*
                            ,.body
                            ,.(when *loop-step-used?* (list *loop-step*))
                            ,.steppers
                            (go ,*loop-top*)
                            ,.(when *loop-end-used?* (list *loop-end*))
                            ,.final-code)
                         ,(if (member *result-var* *bindings* :key #'car)
                              *result-var*
                              nil))))
          (wrap-form *loop-body-wrappers*
                     `(let* ,(nreverse *bindings*)
                        ,.(if *declarations*
                              `((declare .,*declarations*)))
                        ,.decls
                        ,(if final-prot
                             `(unwind-protect ,it-bod .,final-prot)
                             it-bod))))))))


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

Issue: Macro call that should be transformed by DEF-SUITE

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

Output:
(defmacro def-suite (name &key description in)
  "Define a new test-suite named NAME.

IN (a symbol), if provided, causes this suite te be nested in the
suite named by IN. NB: This macro is built on top of make-suite,
as such it, like make-suite, will overrwrite any existing suite
named NAME."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (make-suite ',name
                 ,@(when description `(:description ,description))
                 ,@(when in `(:in ',in)))
     ',name))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(make-name-transformer nil :key nil)

What needs to change: Macro call that should be transformed by MAKE-NAME-TRANSFORMER

Input: (make-name-transformer nil :key nil)

Output:
(defmacro make-name-transformer (&rest elements)
  "Return an accessor name transformer.
The unquoted `name' symbol argument is substituted for the slot name.
Class option examples:

  :accessor-name-transformer (make-name-transformer \"FOO-\" name \"-BAR\")

Use the slot name directly:

  :accessor-name-transformer (make-name-transformer name)"
  `(lambda (name definition)
    (declare (ignorable definition))
    (concatenate-symbol ,@(mapcar (lambda (el)
                                    (if (and (symbolp el)
                                             (string= (symbol-name el) "NAME"))
                                        'name
                                        el))
                                  elements))))


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

Problem: Macro call that should be transformed by WITH-GUESSING-ENCODER

Input:
(with-guessing-encoder
  nil
  nil)

Output:
(defmacro with-guessing-encoder  (&body body)
  `(with-local-encoder (use-guessing-encoder)
     ,@body))


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

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

Input:
(cond-> nil
  nil)

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


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 <* (parser &rest parsers)
  "Combination of parsers yielding the result of the leftmost one."
  (let ((offset (gensym "<*-OFFSET")))
    `(lambda (,offset)
       ,(reduce (lambda (i p)
                  (let ((res0 (gensym "<*-RES"))
                        (next (gensym "<*-NEXT")))
                    `(multiple-value-bind (,res0 ,next) ,i
                       (if (ok? ,res0)
                           (multiple-value-bind (res next) (funcall ,p ,next)
                             (if (ok? res)
                                 (values ,res0 next)
                                 (fail next)))
                           (fail ,next)))))
                parsers
                :initial-value `(funcall ,parser ,offset)))))


Instruction:
Generate a defmacro form that transforms code like this:
(eval-when-compile)

Pattern to recognize: Macro call that should be transformed by EVAL-WHEN-COMPILE

Input: (eval-when-compile)

Output: (defmacro EVAL-WHEN-COMPILE ...)


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

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

Input: (defpackage nil nil)

Output: (defmacro DEFPACKAGE ...)


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

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

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

Output: (defmacro SPECIAL ...)


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

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

Input:
(match2* common-lisp:nil
  :key
  common-lisp:nil)

Output:
(defmacro match2* (whats &body clauses)
  "In match2/match2*, the last clause is not enclosed in a block.
Therefore, using `next' in the last clause results in jumping to the next innermost matching construct,
or results in a compilation error when this is the outermost matching construct."
  `(match2*+ ,whats
       ,(make-list (length whats) :initial-element t)
     ;; ,(mapcar #'form-type whats)
     ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^ TODO: use Bike/compiler-macro
     ,@clauses))


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:
(c?n
  nil
  (progn))

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

Input:
(c?n
  nil
  (progn))

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


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

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

Input:
(-<> nil
  :key
  nil)

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


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

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

Input:
(with-shadowed-custom-vars
  nil
  :key
  nil)

Output:
(defmacro with-shadowed-custom-vars (&body body)
  `(let ,(loop for (var) in *custom-vars*
            collect `(,var (if (boundp ',var) ,var)))
     ,@body))


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

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

Input: (when-let* nil)

Output:
(defmacro when-let* (bindings &body body)
  "Creates new variable bindings, and conditionally executes BODY.

BINDINGS must be either single binding of the form:

 (variable initial-form)

or a list of bindings of the form:

 ((variable-1 initial-form-1)
  (variable-2 initial-form-2)
  ...
  (variable-n initial-form-n))

Each INITIAL-FORM is executed in turn, and the variable bound to the
corresponding value. INITIAL-FORM expressions can refer to variables
previously bound by the WHEN-LET*.

Execution of WHEN-LET* stops immediately if any INITIAL-FORM evaluates to NIL.
If all INITIAL-FORMs evaluate to true, then BODY is executed as an implicit
PROGN."
  (let ((binding-list (if (and (consp bindings) (symbolp (car bindings)))
                          (list bindings)
                          bindings)))
    (labels ((bind (bindings body)
               (if bindings
                   `(let (,(car bindings))
                      (when ,(caar bindings)
                        ,(bind (cdr bindings) body)))
                   `(progn ,@body))))
      (bind binding-list body))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(define-shared-method nil
    (progn))

What needs to change: Macro call that should be transformed by DEFINE-SHARED-METHOD

Input:
(define-shared-method nil
    (progn))

Output: (defmacro DEFINE-SHARED-METHOD ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(match common-lisp:nil
  common-lisp:nil)

Problem: Macro call that should be transformed by MATCH

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

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


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

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

Input: (defmethod nil)

Output: (defmacro DEFMETHOD ...)


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

Write a macro that addresses: Macro call that should be transformed by DO-FOR

Input:
(do-for nil
  nil)

Output: (defmacro DO-FOR ...)


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

Problem: Macro call that should be transformed by DICTQ

Input: (dictq nil nil)

Output:
(defmacro dictq (&rest keys-and-values)
  "A literal hash table.
Like `dict', but the keys and values are implicitly quoted, and the
hash table is inlined as a literal object."
  (apply #'dict keys-and-values))


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

Write a macro that addresses: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-TYPES

Input:
(pprint-coalton-codegen-types
  common-lisp:nil
  (common-lisp:progn))

Output: (defmacro PPRINT-COALTON-CODEGEN-TYPES ...)


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

Problem: Macro call that should be transformed by FORM-ATTRIBUTE

Input: (form-attribute nil nil)

Output: (defmacro FORM-ATTRIBUTE ...)


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

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

Input:
(nlet nil
    nil)

Output:
(defmacro nlet (name (&rest bindings) &body body &environment env)
  "Within BODY, bind NAME as a function, somewhat like LABELS, but
with the guarantee that recursive calls to NAME will not grow the
stack.

`nlet' resembles Scheme’s named let, and is used for the same purpose:
writing loops using tail recursion. You could of course do this with
`labels' as well, at least under some Lisp implementations, but `nlet'
guarantees tail call elimination anywhere and everywhere.

    (nlet rec ((i 1000000))
      (if (= i 0)
          0
          (rec (1- i))))
    => 0

Beware: because of the way it is written (literally, a GOTO with
arguments), `nlet' is limited: self calls must be tail calls. That is,
you cannot use `nlet' for true recursion.

The name comes from `Let Over Lambda', but this is a more careful
implementation: the function is not bound while the initial arguments
are being evaluated, and it is safe to close over the arguments."
  (setf bindings (loop for binding in bindings
                       if (symbolp binding)
                         collect `(,binding ,binding)
                       else collect binding))
  (multiple-value-bind (body decls)
      (parse-body body)
    (let* ((bindings (mapcar #'ensure-list bindings))
           (vars  (mapcar #'first bindings))
           (inits (mapcar #'second bindings))
           (temps (mapcar #'string-gensym vars))
           (alist (pairlis vars temps))
           (decls
             (map-declaration-env
              (lambda (id names env)
                (values id (sublis alist names) env))
              (parse-declarations decls env))))
      (with-gensyms (tag)
        `(block ,name
           (let ,(mapcar #'list temps inits)
             ,@(build-declarations 'declare decls)
             (macrolet ((,name ,vars
                          `(progn
                             (psetq
                              ,@(mapcan #'list
                                        ',temps
                                        (list ,@vars)))
                             (go ,',tag))))
               (tagbody
                  ,tag (return-from ,name
                         (let ,(mapcar #'list vars temps)
                           ,@body))))))))))


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

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

Input:
(lret nil
  (progn))

Output:
(defmacro lret ((&rest bindings) &body body)
  "Return the initial value of the last binding in BINDINGS. The idea
is to create something, initialize it, and then return it.

    (lret ((x 1)
           (y (make-array 1)))
      (setf (aref y 0) x))
    => #(1)

Note that the value returned is the value initially bound. Subsequent
assignments are ignored.

    (lret ((x 1))
      (setf x 2))
    => 1

Furthermore, on Lisps that support it, the variable may be made
read-only, making assignment a compiler-time error.

`lret' may seem trivial, but it fufills the highest purpose a macro
can: it eliminates a whole class of bugs (initializing an object, but
forgetting to return it).

Cf. `aprog1' in Anaphora."
  `(lret-aux let ,bindings
     ,@body))


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

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

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

Output: (defmacro F_N ...)


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

Problem: Macro call that should be transformed by DEFMACRO

Input: (defmacro nil ())

Output: (defmacro DEFMACRO ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(with-column-writers nil
  nil)

Write a macro that addresses: Macro call that should be transformed by WITH-COLUMN-WRITERS

Input:
(with-column-writers nil
  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:
You are a Common Lisp macro expert. Given this code pattern:
(define-alias-binding nil (progn))

Write a macro that addresses: Macro call that should be transformed by DEFINE-ALIAS-BINDING

Input: (define-alias-binding nil (progn))

Output:
(defmacro define-alias-binding (name referenced-binding-name)
  `(progn (setf (binding ',name) ',referenced-binding-name)
          ',name))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(symbol-value-in-$instance nil (progn))

Write a macro that addresses: Macro call that should be transformed by SYMBOL-VALUE-IN-$INSTANCE

Input: (symbol-value-in-$instance nil (progn))

Output: (defmacro SYMBOL-VALUE-IN-$INSTANCE ...)


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

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

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

Output: (defmacro RESOLVE ...)


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

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

Input:
(deftable nil
  nil)

Output:
(defmacro deftable (name &body definitions)
  "Define a table. name can be either a symbol or a (symbol string) list. In the
first case, the table name is derived from the symbol by S-SQL's rules, in the
second case, the name is given explicitly. The body of definitions can contain
anything that evaluates to a string, as well as S-SQL expressions. In this body,
the variables *table-name* and *table-symbol* are bound to the relevant values.
Note that the evaluation of the definition is ordered, so you will generally
want to create your table first and then define indices on it."
  (multiple-value-bind (symbol name)
      (if (consp name) (values-list name) (values name (to-sql-name name nil)))
    (flet ((check-s-sql (form)
             (if (and (consp form) (keywordp (car form))) (list 'sql form) form)))
      `(add-table-definition
        ',symbol
        (lambda ()
          (let ((*table-name* ,name) (*table-symbol* ',symbol))
            (dolist (stat (list ,@(mapcar #'check-s-sql definitions)))
              (execute stat))))))))


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

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

Input: (~> nil (progn))

Output:
(defmacro ~> (needle &rest holes)
  "Threading macro from Clojure (by way of Racket).

Thread NEEDLE through HOLES, where each hole is either a
symbol (equivalent to `(hole needle)`) or a list (equivalent to `(hole
needle args...)`).

As an extension, an underscore in the argument list is replaced with
the needle, so you can pass the needle as an argument other than the
first."
  (thread-aux '~> needle holes
              (lambda (needle hole)
                (list* (car hole) needle (cdr hole)))))


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

Issue: Macro call that should be transformed by LAMBDA*

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

Output: (defmacro LAMBDA* ...)


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

Problem: Macro call that should be transformed by ->>

Input: (->> nil)

Output: (defmacro ->> ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(def-kid-slots)

Problem: Macro call that should be transformed by DEF-KID-SLOTS

Input: (def-kid-slots)

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


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

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

Input:
(with-html
  'lol-gen::some-name)

Output:
(defmacro with-html (&body body &environment env)
  "Interpret BODY as HTML. Consult README.txt for the syntax."
  `(let ((*html* (ensure-html-stream *html*)))
     ,(if (and (null (cdr body)) (atom (car body)))
          (car body)
          `(progn ,@(parse-html body env)))))


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

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

Input:
(with-attributes nil
    nil)

Output: (defmacro WITH-ATTRIBUTES ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(once-on nil
    (progn))

Issue: Macro call that should be transformed by ONCE-ON

Input:
(once-on nil
    (progn))

Output:
(defmacro once-on (hook args &body body)
  "Attach a handler with ARGS and BODY to the HOOK.

Remove the handler after it fires the first time.

See `on'."
  (let ((handler-name (gensym "once-on-hook-handler"))
        (args (alexandria:ensure-list args)))
    (alexandria:once-only (hook)
      `(add-hook
        ,hook (make-instance 'handler
                             :fn (lambda ,args
                                   (declare (ignorable ,@args))
                                   (remove-hook ,hook (quote ,handler-name))
                                   ,@body)
                             :name (quote ,handler-name))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(define-form-symbol-macro-binding nil
    (progn))

Issue: Macro call that should be transformed by DEFINE-FORM-SYMBOL-MACRO-BINDING

Input:
(define-form-symbol-macro-binding nil
    (progn))

Output:
(defmacro define-form-symbol-macro-binding (name (var &rest args) &body body)
  (emit-binding-definition name var args body :symbol-macro-p T))


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

Problem: Macro call that should be transformed by FBIND*

Input: (fbind* nil)

Output:
(defmacro fbind* (bindings &body body &environment env)
  "Like `fbind', but creates bindings sequentially."
  (setf bindings (expand-fbindings bindings))
  (unless bindings
    (return-from fbind* `(locally ,@body)))
  (mvlet* ((fn (caar bindings))
           (body decls (parse-body body))
           (local others (partition-declarations `((function ,fn))
                                                 decls
                                                 env)))
    `(fbind (,(first bindings))
       ,@local
       (fbind* ,(rest bindings)
         ,@others
         ,@body))))


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

Pattern to recognize: Macro call that should be transformed by EVAL-WHEN-LOAD

Input:
(eval-when-load
  common-lisp:nil
  :key
  common-lisp:nil)

Output: (defmacro EVAL-WHEN-LOAD ...)


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

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

Input:
(update nil
  nil)

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


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

Problem: Macro call that should be transformed by SOME-<>>

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

Output: (defmacro SOME-<>> ...)


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

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

Input: (with nil :key nil)

Output: (defmacro WITH ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(remove-from-plistf nil (progn))

Issue: Macro call that should be transformed by REMOVE-FROM-PLISTF

Input: (remove-from-plistf nil (progn))

Output: (defmacro REMOVE-FROM-PLISTF ...)


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

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

Input:
(f0
  nil)

Output: (defmacro F0 ...)


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

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

Input: (with-collectors 'lol-gen::some-name)

Output: (defmacro WITH-COLLECTORS ...)


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

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

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

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


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

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

Input: (defmacro nil (progn))

Output: (defmacro DEFMACRO ...)


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

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

Input: (to nil)

Output: (defmacro TO ...)


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

Problem: Macro call that should be transformed by NSPLICE-SEQF

Input: (nsplice-seqf nil nil)

Output: (defmacro NSPLICE-SEQF ...)


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

Issue: Macro call that should be transformed by PSETF

Input: (psetf nil nil)

Output: (defmacro PSETF ...)


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

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

Input:
(cond->>
  nil
  :key
  nil)

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


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

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

Input:
(defcondition nil
    :key
  nil)

Output:
(defmacro defcondition (name supers &body (slots &rest options))
  "Alias for `define-condition'.

Like (define-condition ...), but blissfully conforming to the same
nomenclatural convention as every other definition form in Common
Lisp."
  `(define-condition ,name ,supers
     ,slots
     ,@options))


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

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

Input: (defproto nil (progn))

Output: (defmacro DEFPROTO ...)


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

Issue: Macro call that should be transformed by FMV

Input: (fmv nil)

Output:
(defmacro fmv (name)
  `(value (fm-other ,name)))


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

Problem: Macro call that should be transformed by WNOTRC

Input:
(wnotrc nil
  (progn))

Output:
(defmacro wnotrc ((&optional (min 1) (max 50) &rest banner) &body body )
  (declare (ignore min max banner))
  `(progn ,@body))


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

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

Input: (is-type nil nil)

Output:
(defmacro is-type (got expected-type &optional desc)
  (with-gensyms (duration result)
    (once-only (desc expected-type)
      `(with-catching-errors (:description ,desc :expected ,expected-type)
         (with-duration ((,duration ,result) ,got)
           (test ,result ,expected-type ,desc
                 :duration ,duration
                 :got-form ',got
                 :test-fn #'typep
                 :report-expected-label "be a type of"))))))


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

Problem: Macro call that should be transformed by AECASE

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

Output:
(defmacro aecase (keyform &body cases)
  "Like ECASE, except binds the result of the keyform to IT (via LET) for the
scope of the cases."
  `(anaphoric ecase ,keyform ,@cases))


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

Problem: Macro call that should be transformed by PS-HTML

Input: (ps-html nil :key nil)

Output: (defmacro PS-HTML ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(c-in-lazy
  nil
  (progn))

Write a macro that addresses: Macro call that should be transformed by C-IN-LAZY

Input:
(c-in-lazy
  nil
  (progn))

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


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

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

Input:
(with-slots nil
    :key
  nil)

Output: (defmacro WITH-SLOTS ...)


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

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

Input: (as-> nil nil)

Output: (defmacro AS-> ...)


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

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

Input: (restart-case nil)

Output: (defmacro RESTART-CASE ...)


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

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

Input:
(-<>> nil
  nil)

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


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

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

Input:
(with-savepoint nil
  nil)

Output:
(defmacro with-savepoint (conn &body body)
  (let ((ok (gensym "SAVEPOINT-OK"))
        (state-var (gensym "STATE-VAR"))
        (ident-var (gensym "SAVEPOINT-IDENTIFIER-VAR")))
    `(let* ((,state-var (make-instance 'savepoint-state
                                       :conn ,conn))
            (,ident-var (get-identifier ,state-var))
            (*transaction-state*
              (cons ,state-var
                    *transaction-state*))
            ,ok)

       (savepoint ,conn ,ident-var)
       (unwind-protect
            (multiple-value-prog1
                (progn ,@body)
              (setf ,ok t))
         (when (eql (get-state ,state-var)
                    :in-progress)
           (if ,ok
               (release-savepoint ,conn ,ident-var)
               (rollback-savepoint ,conn ,ident-var)))))))


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

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

Input:
(lret* nil
  nil)

Output:
(defmacro lret* ((&rest bindings) &body body)
  "Cf. `lret'."
  `(lret-aux let* ,bindings
     ,@body))


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

Problem: Macro call that should be transformed by DEFOBJECT

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

Output: (defmacro DEFOBJECT ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(with-destructured-lambda-form nil
    :key
  nil)

Write a macro that addresses: Macro call that should be transformed by WITH-DESTRUCTURED-LAMBDA-FORM

Input:
(with-destructured-lambda-form nil
    :key
  nil)

Output: (defmacro WITH-DESTRUCTURED-LAMBDA-FORM ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(compile-$flavor-$methods nil :key nil)

What needs to change: Macro call that should be transformed by COMPILE-$FLAVOR-$METHODS

Input: (compile-$flavor-$methods nil :key nil)

Output: (defmacro COMPILE-$FLAVOR-$METHODS ...)


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

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

Input:
(gathering nil
  :key
  nil)

Output: (defmacro GATHERING ...)


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

Problem: Macro call that should be transformed by OPF

Input: (opf nil nil)

Output:
(defmacro opf (place expr)
  "Like `(callf PLACE (op EXPR))'.
From GOO."
  `(callf (op ,expr) ,place))


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

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

Input: (nest nil (progn))

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:
You are a Common Lisp macro expert. Given this code pattern:
(ensure2 nil
  :key
  nil)

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

Input:
(ensure2 nil
  :key
  nil)

Output:
(defmacro ensure2 (place &body newval &environment env)
  "Like `ensure', but specifically for accessors that return a second
value like `gethash'."
  (multiple-value-bind (vars vals stores setter getter)
      (get-setf-expansion place env)
    (with-gensyms (old presentp)
      `(let* ,(mapcar #'list vars vals)
         (multiple-value-bind (,old ,presentp)
             ,getter
           (if ,presentp
               ,old
               (multiple-value-bind ,stores
                   (progn ,@newval)
                 ,setter)))))))


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

Problem: Macro call that should be transformed by ENSURE-GET

Input:
(ensure-get nil
    nil)

Output:
(defmacro! ensure-get (o!key o!map &body (&optional default))
  `(multiple-value-bind (,g!value ,g!in-map?) (get ,g!key ,g!map)
     (if ,g!in-map?
	 (values ,g!value t)
	 (values
	  (setf (get ,g!key ,g!map) ,default)
	  nil))))


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

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

Input:
(none-of nil
  :key
  nil)

Output: (defmacro NONE-OF ...)


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

What needs to change: Macro call that should be transformed by WITH-CUSTOM-DECODER-LEVEL

Input: (with-custom-decoder-level 'lol-gen::some-name)

Output:
(defmacro with-custom-decoder-level ((&rest customizations) &body body)
  "Execute BODY in a dynamic environment such that, when nested
structures are decoded, the outermost level is decoded with the given
custom handlers (CUSTOMIZATIONS) whereas inner levels are decoded in
the usual way."
  `(let ((current-decoder
          (current-decoder
           ,@(loop for (key value) on customizations by #'cddr
                if (eq key :internal-decoder)
                  do (error "~S ~S customization is meaningless in ~
                             the context of WITH-CUSTOM-DECODER-LEVEL."
                            key value)
                else collect key))))
     (bind-custom-vars (:internal-decoder current-decoder ,@customizations)
       ,@body)))


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

Problem: Macro call that should be transformed by C_?

Input:
(c_?
  nil)

Output:
(defmacro c_? (&body body)
  "Lazy until asked, then eagerly propagating"
  `(make-c-dependent
    :code ',body
    :value-state :unevaluated
    :lazy :until-asked
    :rule (c-lambda ,@body)))


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

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

Input: (the)

Output: (defmacro THE ...)


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

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

Input: (collect nil)

Output: (defmacro COLLECT ...)


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

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

Input: (eko-if nil :key nil)

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:
Define a macro that eliminates this repetitive pattern:
(do-sequences nil
  :key
  nil)

Issue: Macro call that should be transformed by DO-SEQUENCES

Input:
(do-sequences nil
  :key
  nil)

Output:
(defmacro do-sequences (name/seqs &body forms &environment env)
  "Iterate over the elements of one or more sequences.

   Iteration is performed using the iterator interface, and over
   multiple sequences simultaneously.

   The macro arguments can be in one of the following two forms:

    1. (NAME (&REST SEQS) &BODY BODY)

    2. ((&REST SEQS) &BODY BODY)

   NAME is a symbol serving as the name of the BLOCK from which the
   forms in BODY can return, using (RETURN-FROM NAME ...). If not
   given defaults to NIL.

   Each element of SEQS is a list of the form (VAR SEQUENCE . ARGS),
   where VAR is the variable to which the element of the sequence,
   SEQUENCE, is bound, at each iteration, and ARGS are arguments
   passed to the ITERATOR function, after the sequence.

   BODY is a list of forms evaluated at each iteration. RETURN-FROM to
   the block named NAME may be used to terminate the iteration early
   and return a value from the DO-SEQUENCES form. NIL is returned if
   there is no explicit RETURN."

  (let-if ((name name/seqs)
           (seqs (first forms) name/seqs)
           (forms (rest forms) forms))
      (symbolp name/seqs)

    (let ((safety (cadr (assoc 'safety (declaration-information 'optimize env)))))
      `(,(if (> safety 2)
             'do-sequences-safe%
             'do-sequences-fast%)

         ,name
         ,seqs
         ,@forms))))


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

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

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

Output:
(defmacro when-let (bindings &body forms)
    "Creates new variable bindings, and conditionally executes FORMS.

BINDINGS must be either single binding of the form:

 (variable initial-form)

or a list of bindings of the form:

 ((variable-1 initial-form-1)
  (variable-2 initial-form-2)
  ...
  (variable-n initial-form-n))

All initial-forms are executed sequentially in the specified order. Then all
the variables are bound to the corresponding values.

If all variables were bound to true values, then FORMS are executed as an
implicit PROGN."
  (let* ((binding-list (if (and (consp bindings) (symbolp (car bindings)))
                           (list bindings)
                           bindings))
         (variables (mapcar #'car binding-list)))
    `(let ,binding-list
       (when (and ,@variables)
         ,@forms))))


Instruction:
Generate a defmacro form that transforms code like this:
(matrix-ctypecase nil)

Pattern to recognize: Macro call that should be transformed by MATRIX-CTYPECASE

Input: (matrix-ctypecase nil)

Output: (defmacro MATRIX-CTYPECASE ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(multiple-value-cmatch common-lisp:nil
  (common-lisp:progn))

Issue: Macro call that should be transformed by MULTIPLE-VALUE-CMATCH

Input:
(multiple-value-cmatch common-lisp:nil
  (common-lisp:progn))

Output:
(defmacro multiple-value-cmatch (values-form &body clauses)
  #.+multiple-value-match-doc+
  (call-with-mvb-temp-vars
   clauses
   (lambda (clauses temps)
     `(multiple-value-bind ,temps ,values-form
        (match* ,temps
          ,@clauses
          (,temps
           (cerror "continue" 'match-error :pattern ',clauses :values (list ,@temps))))))))


Instruction:
Generate a defmacro form that transforms code like this:
(eval-when-compile
  common-lisp:nil
  common-lisp:nil)

Pattern to recognize: Macro call that should be transformed by EVAL-WHEN-COMPILE

Input:
(eval-when-compile
  common-lisp:nil
  common-lisp:nil)

Output: (defmacro EVAL-WHEN-COMPILE ...)


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

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

Input:
(restart-bind nil
  (progn))

Output: (defmacro RESTART-BIND ...)


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

Write a macro that addresses: Macro call that should be transformed by V-DEFMACRO

Input:
(v-defmacro nil
    (progn))

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


Instruction:
Write a Common Lisp macro to handle this code pattern:
(some-<> nil :key nil)

Problem: Macro call that should be transformed by SOME-<>

Input: (some-<> nil :key nil)

Output: (defmacro SOME-<> ...)


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

Problem: Macro call that should be transformed by GROUP-BY

Input: (group-by 'lol-gen::some-name)

Output: (defmacro GROUP-BY ...)


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

Issue: Macro call that should be transformed by RESTART-CASE

Input: (restart-case 'lol-gen::some-name)

Output: (defmacro RESTART-CASE ...)


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

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

Input: (nearest nil nil)

Output:
(defmacro nearest (self-form type)
   (let ((self (gensym)))
   `(bwhen (,self ,self-form)
       (if (typep ,self ',type) ,self (upper ,self ,type)))))


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

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

Input:
(c-envalue
  nil
  nil)

Output:
(defmacro c-envalue (&body body)
  `(make-c-envaluer
    :envalue-rule (c-lambda ,@body)))


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

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

Input:
(define-declaration nil
    (progn))

Output: (defmacro DEFINE-DECLARATION ...)


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

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

Input: (collect-last nil)

Output: (defmacro COLLECT-LAST ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(export-only-always nil (progn))

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

Input: (export-only-always nil (progn))

Output:
(defmacro export-only-always (symbols &optional (package nil package-supplied?))
  "Like `export-only', but also evaluated at compile time."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (export-only ,symbols ,@(and package-supplied? (list package)))))


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

Pattern to recognize: Macro call that should be transformed by U^

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

Output:
(defmacro u^ (type)
  `(upper self ,type))


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

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

Input:
(defmacro* nil
    nil)

Output: (defmacro DEFMACRO* ...)


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

Pattern to recognize: Macro call that should be transformed by WITH-DESTRUCTURED-LAMBDA-FORM

Input:
(with-destructured-lambda-form nil
    nil)

Output: (defmacro WITH-DESTRUCTURED-LAMBDA-FORM ...)


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

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

Input:
(when-let* nil
  (progn))

Output:
(defmacro when-let* (bindings &body body)
  "Creates new variable bindings, and conditionally executes BODY.

BINDINGS must be either single binding of the form:

 (variable initial-form)

or a list of bindings of the form:

 ((variable-1 initial-form-1)
  (variable-2 initial-form-2)
  ...
  (variable-n initial-form-n))

Each INITIAL-FORM is executed in turn, and the variable bound to the
corresponding value. INITIAL-FORM expressions can refer to variables
previously bound by the WHEN-LET*.

Execution of WHEN-LET* stops immediately if any INITIAL-FORM evaluates to NIL.
If all INITIAL-FORMs evaluate to true, then BODY is executed as an implicit
PROGN."
  (let ((binding-list (if (and (consp bindings) (symbolp (car bindings)))
                          (list bindings)
                          bindings)))
    (labels ((bind (bindings body)
               (if bindings
                   `(let (,(car bindings))
                      (when ,(caar bindings)
                        ,(bind (cdr bindings) body)))
                   `(progn ,@body))))
      (bind binding-list body))))


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

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

Input: (->> nil (progn))

Output: (defmacro ->> ...)


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

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

Input:
(defclause nil
    nil)

Output:
(defmacro defclause (name arglist &body body)
  "Same as cl:defmacro, but additionally records <name> in *clauses* as a known clause macro."
  `(progn
     (defmacro ,name ,arglist ,@body)
     (pushnew ',name *clauses*)))


Instruction:
Generate a defmacro form that transforms code like this:
(eval-when-execute
  common-lisp:nil
  (common-lisp:progn))

Pattern to recognize: Macro call that should be transformed by EVAL-WHEN-EXECUTE

Input:
(eval-when-execute
  common-lisp:nil
  (common-lisp:progn))

Output: (defmacro EVAL-WHEN-EXECUTE ...)


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

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

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

Output: (defmacro EXPORT-SLOTS ...)


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

Problem: Macro call that should be transformed by PECASE

Input: (pecase nil (progn))

Output:
(defmacro pecase (pred keyform &rest clauses)
  "Like ECASE, but uses given PRED instead of EQL to select appropriate CLAUSE.

   Example usage:

       CL-USER> (pecase '< 1
                  (0 (print \"Below zero\"))
                  (2 (print \"OK\")))
"
  (expand-predicate-case pred keyform clauses 'ecase))


Instruction:
Generate a defmacro form that transforms code like this:
(with-out-file 'lol-gen::some-name)

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

Input: (with-out-file 'lol-gen::some-name)

Output:
(defmacro with-out-file ((var path) &body body)
  `(with-open-file (,var ,path :direction :output
                         :if-exists :supersede :if-does-not-exist :create)
     ,@body))


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

Problem: Macro call that should be transformed by PROG1

Input: (prog1 nil nil)

Output: (defmacro PROG1 ...)


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

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

Input:
(c?? nil
  (progn))

Output:
(defmacro c?? ((&key (tagp nil) (in nil) (out t))&body body)
  (let ((result (copy-symbol 'result))
        (thetag (gensym)))
     `(make-c-dependent
       :code ',body
       :value-state :unevaluated
       :rule (c-lambda
              (let ((,thetag (gensym "tag"))
                    (*trcdepth* (1+ *trcdepth*))
                    )
                (declare (ignorable self ,thetag))
                ,(when in
                   `(trc "c??> entry" (c-slot-name c) (c-model c) (when ,tagp ,thetag)))
                (count-it :c?? (c-slot-name c) (md-name (c-model c)))
                (let ((,result (progn ,@body)))
                  ,(when out `(trc "c?? result:" ,result (c-slot-name c) (when ,tagp ,thetag)))
                  ,result))))))


Instruction:
Generate a defmacro form that transforms code like this:
(eval-always
  nil
  nil)

Pattern to recognize: Macro call that should be transformed by EVAL-ALWAYS

Input:
(eval-always
  nil
  nil)

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:
Create a Common Lisp macro for the following transformation. Before code:
(export-structure)

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

Input: (export-structure)

Output: (defmacro EXPORT-STRUCTURE ...)


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

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

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

Output:
(defmacro define-test+run-interactively (name &body args-and-body)
  `(progn (define-test ,name ,@args-and-body)
          (eval-when (:execute)
            (values ',name (test ',name :report 'interactive)))))


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

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

Input:
(with-pp
  'lol-gen::some-name)

Output:
(defmacro with-pp (&body body)
  `(symbol-macrolet ((stream (get-stream-generic pp))
		     (indent (get-indent-generic pp))
		     (--indent (dec-indent-generic pp))
		     (++indent (inc-indent-generic pp)))
     (macrolet ((push-sign (x) `(push-sign-generic pp ,x))
		(pop-sign () `(pop-sign-generic pp))
		(top-sign () `(top-sign-generic pp))
		(find-sign (x) `(find-sign-generic pp ,x))
		(push-info (x) `(push-info-generic pp ,x))
		(pop-info () `(pop-info-generic pp))
		(top-info () `(top-info-generic pp))
		(find-info (x) `(find-info-generic pp ,x))
		(info-size () `(info-size-generic pp))
		(node-slot (x) `(slot-value item ',x)))
       ,@body)))


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

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

Input: (batch)

Output:
(defmacro batch (&body forms)
  "Batch assignments to the values of mutable cells.

The forms in FORMS are evaluated, in an implicit PROGN, with mutable
cell assignment batching in effect. This means that when the value of
a mutable cell is set by SETF within the dynamic extent of the BATCH
form, the observers of the cell are only notified after the last form
in FORMS is evaluated, or the BATCH form is exited by a non-local exit
such as by RETURN-FROM. The effect of this is that the cells appear to
have their values changed simultaneously.

.. note::

   When a BATCH form is nested in the dynamic extent of another BATCH
   form, the nested BATCH form has no effect other than to evaluate
   FORMS. The observers of the cells are only notified when exiting
   the outermost BATCH form.

Returns the value of the last form in FORMS."

  `(if *batch-in-effect-p*
       (progn ,@forms)

       (let ((*batch-in-effect-p* t)
             (*batch-list* nil))

         (unwind-protect (progn ,@forms)
           (end-batch)))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(fluid-bind nil
  (progn))

Issue: Macro call that should be transformed by FLUID-BIND

Input:
(fluid-bind nil
  (progn))

Output:
(defmacro fluid-bind ((&rest bindings) &body body)
  "Fluid-bind is an extension of bind that handles setting and resetting places. For example, suppose that an object of class foo has a slot named bar whose value is currently 3. The following code would evaluate the inner body with bar bound to 17 and restore it when the inner body is exited.

\(fluid-bind \(\(\(bar foo\) 17\)\)
  \(print \(bar foo\)\)\)
\(print \(bar foo\)\)
==> \(prints 17, then 3\)

This is similar to dynamic-binding but _much_ less robust."
  ;; does not handle declarations correctly
  (let ((setup-forms nil)
        (cleanup-forms nil)
        (gensyms nil))
    (loop for binding in bindings collect
          (destructuring-bind
		(setup-form cleanup-form)
	      (cond ((consp binding)
		     (destructuring-bind (var value) binding
		       (let ((g (gensym)))
			 (push g gensyms)
			 (cond ((atom var)
				`((:bind (,var ,value)) nil)
				#+(or)
				;; lexical or special?
				(if (boundp var)
				    `((:bind (,var ,value)) nil)
				    `((:setf (setf ,g ,var ,var ,value))
				      (setf ,var ,g))))
			       ((and (fboundp (first var))
				     (not (eq (first var) 'values)))
				;; putative place
				`((:setf (setf ,g ,var ,var ,value))
				  (setf ,var ,g)))
			       (t
				`((:bind (,var ,value)) nil))))))
		    (t
		     `((:bind (,binding nil)) nil)))
            (push setup-form setup-forms)
            (push cleanup-form cleanup-forms)))
    (let ((result body))
      (mapc (lambda (setup cleanup)
              (setf result
                    (ecase (first setup)
                      (:setf `((unwind-protect
                                 (progn
                                   ,(second setup)
                                   ,@result)
                                 ,cleanup)))
                      (:bind `((bind (,(second setup))
                                 ,@result)))))
              result)
            setup-forms cleanup-forms)
      `(let ,gensyms
         (declare (ignorable ,@gensyms))
         ,@result))))


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

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

Input:
(defun* nil
    nil)

Output: (defmacro DEFUN* ...)


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

Problem: Macro call that should be transformed by IDENTIFIER

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

Output: (defmacro IDENTIFIER ...)


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

Problem: Macro call that should be transformed by WITH-UNIQUE-NAMES

Input:
(with-unique-names nil
  (progn))

Output:
(defmacro with-unique-names (names &body forms)
  "Alias for WITH-GENSYMS."
  `(with-gensyms ,names ,@forms))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(c?+n
  nil
  :key
  nil)

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

Input:
(c?+n
  nil
  :key
  nil)

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


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

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

Input:
(with-tokens nil
  nil)

Output:
(defmacro with-tokens (tokens &body body)
  `(let ((*tokens* ,tokens)
         (*toplevel* nil))
     (trivial-with-current-source-form:with-current-source-form (*tokens*)
       ,@body)))


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

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

Input:
(local
  nil
  nil)

Output:
(defmacro local (&body orig-body &environment env)
  "Make internal definitions using top-level definition forms.

Within `local' you can use top-level definition forms and have them
create purely local definitions, like `let', `labels', and `macrolet':

     (fboundp 'plus) ; => nil

     (local
       (defun plus (x y)
         (+ x y))
       (plus 2 2))
     ;; => 4

     (fboundp 'plus) ; => nil

Each form in BODY is subjected to partial expansion (with
`macroexpand-1') until either it expands into a recognized definition
form (like `defun') or it can be expanded no further.

\(This means that you can use macros that expand into top-level
definition forms to create local definitions.)

Just as at the real top level, a form that expands into `progn' (or an
equivalent `eval-when') is descended into, and definitions that occur
within it are treated as top-level definitions.

\(Support for `eval-when' is incomplete: `eval-when' is supported only
when it is equivalent to `progn').

The recognized definition forms are:

- `def', for lexical variables (as with `letrec')
- `define-values', for multiple lexical variables at once
- `defun', for local functions (as with `labels')
- `defalias', to bind values in the function namespace (like `fbindrec*')
- `declaim', to make declarations (as with `declare')
- `defconstant' and `defconst', which behave exactly like symbol macros
- `define-symbol-macro', to bind symbol macros (as with `symbol-macrolet')

Also, with serious restrictions, you can use:

- `defmacro', for local macros (as with `macrolet')

\(Note that the top-level definition forms defined by Common Lisp
are (necessarily) supplemented by three from Serapeum: `def',
`define-values', and `defalias'.)

The exact order in which the bindings are made depends on how `local'
is implemented at the time you read this. The only guarantees are that
variables are bound sequentially; functions can always close over the
bindings of variables, and over other functions; and macros can be
used once they are defined.

     (local
       (def x 1)
       (def y (1+ x))
       y)
     => 2

     (local
       (defun adder (y)
         (+ x y))
       (def x 2)
       (adder 1))
     => 3

Perhaps surprisingly, `let' forms (as well as `let*' and
`multiple-value-bind') *are* descended into; the only difference is
that `defun' is implicitly translated into `defalias'. This means you
can use the top-level idiom of wrapping `let' around `defun'.

    (local
      (let ((x 2))
        (defun adder (y)
          (+ x y)))
      (adder 2))
    => 4

Support for macros is sharply limited. (Symbol macros, on the other
hand, are completely supported.)

1. Macros defined with `defmacro' must precede all other expressions.

2. Macros cannot be defined inside of binding forms like `let'.

3. `macrolet' is not allowed at the top level of a `local' form.

These restrictions are undesirable, but well justified: it is
impossible to handle the general case both correctly and portably, and
while some special cases could be provided for, the cost in complexity
of implementation and maintenance would be prohibitive.

The value returned by the `local' form is that of the last form in
BODY. Note that definitions have return values in `local' just like
they do at the top level. For example:

     (local
       (plus 2 2)
       (defun plus (x y)
         (+ x y)))

Returns `plus', not 4.

The `local' macro is loosely based on Racket's support for internal
definitions."
  (multiple-value-bind (body decls) (parse-body orig-body)
    (catch 'local
      (generate-internal-definitions
       (make 'internal-definitions-env
             :decls decls
             :env env)
       body))))


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

Problem: Macro call that should be transformed by EXPORT-SLOTS

Input:
(export-slots
  'lol-gen::some-name)

Output: (defmacro EXPORT-SLOTS ...)


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

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

Input: (fail nil (progn))

Output:
(defmacro fail (&rest message-args)
  "Simply generate a FAIL."
  `(process-failure ',message-args
                    ,@message-args))


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

Write a macro that addresses: Macro call that should be transformed by JS-INLINE

Input: (js-inline nil :key nil)

Output: (defmacro JS-INLINE ...)


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

Problem: Macro call that should be transformed by ITERATE

Input: (iterate)

Output: (defmacro ITERATE ...)


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

Issue: Macro call that should be transformed by DOC

Input: (doc common-lisp:nil)

Output: (defmacro DOC ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(define-parse-tree-synonym nil nil)

Write a macro that addresses: Macro call that should be transformed by DEFINE-PARSE-TREE-SYNONYM

Input: (define-parse-tree-synonym nil nil)

Output:
(defmacro define-parse-tree-synonym (name parse-tree)
  "Defines the symbol NAME to be a synonym for the parse tree
PARSE-TREE.  Both arguments are quoted."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (parse-tree-synonym ',name) ',parse-tree)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(as-array-member nil
  (progn))

Issue: Macro call that should be transformed by AS-ARRAY-MEMBER

Input:
(as-array-member nil
  (progn))

Output:
(defmacro as-array-member ((&optional (stream '*json-output*))
                           &body body)
  "BODY should be a program which encodes exactly one JSON datum to
STREAM.  AS-ARRAY-MEMBER ensures that the datum is properly formatted
as a Member of an Array, i. e. separated by comma from any preceding
or following Member."
  `(progn
     (next-aggregate-member 'array ,stream)
     ,@body))


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

Issue: Macro call that should be transformed by IS-PRINT

Input: (is-print nil (progn))

Output:
(defmacro is-print (got expected &optional desc)
  (with-gensyms (output duration duration-inner)
    (once-only (expected desc)
      `(with-catching-errors (:description ,desc :expected ,expected)
         (let* (,duration
                (,output (with-output-to-string (*standard-output*)
                           (with-duration ((,duration-inner ,output) ,got)
                             (declare (ignore ,output))
                             (setq ,duration ,duration-inner)))))
           (test ,output ,expected ,desc
                 :duration ,duration
                 :got-form ',got
                 :test-fn #'string=
                 :report-expected-label "output"))))))


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

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

Input:
(live
  nil
  :key
  nil)

Output:
(defmacro live (&body forms)
  "Define a live block consisting of FORMS.

The FORMS are evaluated once when the LIVE form is first evaluated,
after which they are evaluated again whenever the values of the cells
referenced by them change. Cells may be referenced either directly in
FORMS or by a function called during the evaluation of FORMS.

Returns a function which when called, stops the live block. Once
stopped the live block will no longer be called when the values of the
referenced cells change."

  (let ((spec (make-instance 'watch-function-spec :body forms)))
    (generate-watch-function spec)))


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

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

Input: (listcase nil)

Output:
(defmacro listcase (list &body cases)
  "A typecase-like macro to destinguish between 3 possible kinds of LIST:
   simple lists, alists, and dlists.
   Evaluates the appropriate key-form depending on the kind:
   ALIST, DLIST or simple list (T)."
  (once-only (list)
    `(if (consp (first ,list))
         (cond ((consp (second ,list))
                (progn ,@(assoc1 'alist cases)))
               ((second ,list)
                (progn ,@(assoc1 'dlist cases)))
               (t
                (progn ,@(assoc1 't cases))))
         (progn ,@(assoc1 't cases)))))


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

Problem: Macro call that should be transformed by PRINT-VALUES

Input:
(print-values
  nil
  :key
  nil)

Output: (defmacro PRINT-VALUES ...)


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

Problem: Macro call that should be transformed by JMATCH

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

Output:
(defmacro jmatch (form &body clauses)
  "Similar to Trivia match macro, match the FORM (JSON value) against CLAUSES.
CLAUSES are (PATTERN . BODY) forms, where
- PATTERN is a `jbind' destructuring pattern.
- And BODY is an implicit progn.

If PATTERN matches successfully in `jbind', then BODY is executed with
the variables from the PATTERN bound to the respective values, as per
`jbind'.

The last clause could start with T, OTHERWISE, ELSE, or _, and it will
be invoked if other patterns don't match. If there's no such clause,
`jmatch' will simply return NIL on no matching patterns."
  (let ((form-sym (gensym "MATCH-FORM")))
    `(let ((,form-sym ,form))
       (cond
         ,@(loop for (pattern . body) in clauses
                 when (and (symbolp pattern)
                           (member (symbol-name pattern) '("T" "_" "OTHERWISE" "ELSE")
                                   :test #'string=))
                   collect `(t ,@body)
                 else
                   collect `((ignore-errors (jbind ,pattern ,form-sym t))
                             (jbind ,pattern ,form-sym ,@body)))))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(c-in-lazy)

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

Input: (c-in-lazy)

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


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

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

Input: (select nil)

Output:
(defmacro select (keyform &body clauses)
  "Like `case', but with evaluated keys.

Note that, like `case', `select' interprets a list as the first
element of a clause as a list of keys. To use a form as a key, you
must add an extra set of parentheses.

     (select 2
       ((+ 2 2) t))
     => T

     (select 4
       (((+ 2 2)) t))
     => T

From Zetalisp."
  `(selector ,keyform eql
     ,@clauses))


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

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

Input: (collect-stream nil nil)

Output: (defmacro COLLECT-STREAM ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(define-fixture-capture nil
    :key
  nil)

Write a macro that addresses: Macro call that should be transformed by DEFINE-FIXTURE-CAPTURE

Input:
(define-fixture-capture nil
    :key
  nil)

Output:
(defmacro define-fixture-capture (name args &body body)
  `(progn (setf (gethash ',name *fixture-captures*)
                (lambda ,args ,@body))
          ',name))


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

Problem: Macro call that should be transformed by ISNT

Input: (isnt nil (progn))

Output:
(defmacro isnt (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
                   :notp t
                   :duration ,duration)))))))


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

Problem: Macro call that should be transformed by DECASE

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

Output:
(defmacro decase (keyform &body clauses)
  "DECASE is a combination of ECASE and DESTRUCTURING-BIND.
   KEYFORM must evaluate to a CONS.

   Clauses are of the form:

       ((CASE-KEYS . DESTRUCTURING-LAMBDA-LIST) FORM*)

   The clause whose CASE-KEYS matches CAR of KEY, as if by ECASE,
   is selected, and FORMs are then executed with CDR of KEY is destructured and
   bound by the DESTRUCTURING-LAMBDA-LIST."
  (expand-destructuring-case keyform clauses 'ecase))


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

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

Input: (destructuring-ccase 'lol-gen::some-name)

Output:
(defmacro destructuring-ccase (keyform &body clauses)
  (expand-destructuring-case keyform clauses 'ccase))


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

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

Output:
(defmacro c?1 (&body body)
  `(c?once ,@body))


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

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

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

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


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

Issue: Macro call that should be transformed by SHIFTF

Input: (shiftf nil nil)

Output: (defmacro SHIFTF ...)


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

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

Input: (with-transaction nil)

Output:
(defmacro with-transaction (conn &body body)
  "Start a transaction and commit at the end of this block. If the evaluation `body` is interrupted, the transaction is rolled back automatically."
  (let ((conn-var (gensym "CONN-VAR")))
    `(let ((,conn-var ,conn))
       (if (in-transaction ,conn-var)
           (with-savepoint ,conn-var ,@body)
           (%with-transaction ,conn-var ,@body)))))


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

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

Input: (ntrcx)

Output:
(defmacro ntrcx (&rest os)
  (declare (ignore os))
  '(progn))


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

Issue: Macro call that should be transformed by EMATCH*

Input:
(ematch* common-lisp:nil
  (common-lisp:progn))

Output:
(defmacro ematch* (whats &body clauses)
  #.+match*-doc+
  (let ((temps (make-gensyms whats "OTHERWISE")))
    `(match2* ,whats
       ,@clauses
       (,temps
        (error 'match-error :pattern ',clauses :values (list ,@temps))))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(disable-interpol-syntax)

Problem: Macro call that should be transformed by DISABLE-INTERPOL-SYNTAX

Input: (disable-interpol-syntax)

Output:
(defmacro disable-interpol-syntax ()
  "Restore readtable which was active before last call to
ENABLE-INTERPOL-SYNTAX. If there was no such call, the standard
readtable is used."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
    (%disable-interpol-syntax)))


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

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

Input: (pmap nil nil)

Output:
(defmacro pmap (f parser)
  "Similar to `fmap', but this transforms a parser into another one, altering
its inner result if it happened to be successful."
  `(lambda (offset)
     (fmap ,f (funcall ,parser offset))))


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

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

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

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


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

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

Input:
(scase nil
  :key
  nil)

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


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

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

Input: (returning nil :key nil)

Output: (defmacro RETURNING ...)


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

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

Input:
(lambda-coro
  nil)

Output: (defmacro LAMBDA-CORO ...)


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

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

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

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


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

Issue: Macro call that should be transformed by EXPORT-CLASS

Input:
(export-class
  common-lisp:nil
  (common-lisp:progn))

Output: (defmacro EXPORT-CLASS ...)


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

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

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

Output:
(defmacro fail (offset)
  "Fail a parse while recording while recording how far it got."
  `(values :fail ,offset))