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

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

Input:
(fbind nil
  :key
  nil)

Output:
(defmacro fbind (bindings &body body &environment *lexenv*)
  "Binds values in the function namespace.

That is,
     (fbind ((fn (lambda () ...))))
     ≡ (flet ((fn () ...))),

except that a bare symbol in BINDINGS is rewritten as (symbol
symbol)."
  (setf bindings (expand-fbindings bindings))
  (unless bindings
    (return-from fbind `(locally ,@body)))
  ;; When possible (if the binding expands to a simple
  ;; let-over-lambda), we hoist the bindings to the top and bind
  ;; the lambda directly with flet.

  ;; Failing that, if we know that the function is never directly
  ;; dereferenced with sharp-quote, we can bind with `macrolet'
  ;; instead of `flet', leaving no runtime overhead vs. `funcall'.
  (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))
           (macro-vars
            (merely-syntactic-functions (mapcar #'first bindings)
                                        body
                                        *lexenv*))
           (vars  (mapcar #'first bindings))
           (exprs (mapcar #'second bindings))
           (temps (mapcar #'string-gensym vars))
           (body decls (parse-body body)))
    `(let ,env
       ,@(unsplice (and env-decls `(declare ,@env-decls)))
       (comment "fbind: Hidden variable bindings to close over.")
       (let ,(loop for temp in temps
                   for expr in exprs
                   collect `(,temp (ensure-function ,expr)))
         ,@(when temps
             (unsplice
              `(declare (function ,@temps))))
         (comment "fbind: Hidden variable bindings for function values.")
         (flet (,@(loop for (name lambda) in lambdas
                        collect `(,name ,@(cdr lambda)))
                ,@(loop for var in vars
                        for temp in temps
                        unless (member var macro-vars)
                          collect (build-bind/ftype var temp decls env)))
           #-sbcl (declare (inline ,@(set-difference vars macro-vars)))
           ,@decls
           (comment "fbind: Functions that might be sharp-quoted.")
           (macrolet (,@(loop for var in vars
                              for temp in temps
                              when (member var macro-vars)
                                collect `(,var
                                          (&rest args)
                                          (list* 'funcall ',temp args))))
             (comment "fbind: Macros for functions provably never sharp-quoted.")
             ,@body))))))


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

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

Input: (make-kid 'lol-gen::some-name)

Output:
(defmacro make-kid (class &rest ia)
  (with-gensyms (c)
    `(let ((,c ,class))
       (make-instance ,c
         ,@ia
         :fm-parent (progn (assert self () "make-kid: self nil making ~a" ,c)
                      self)))))


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

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

Input: (some-> nil (progn))

Output: (defmacro SOME-> ...)


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

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

Input:
(with-proxynodes nil
  (progn))

Output:
(defmacro with-proxynodes (proxy-nodes &body body)
  "define proxy nodes for local usage"
  (if (not (listp proxy-nodes))
      (setf proxy-nodes (list proxy-nodes)))
  (if proxy-nodes
      (let ((tmp (gensym (format nil "~:@(proxy-~a-~)" (first proxy-nodes)))))
	;(format t "Symbol:: ~s" tmp)
	(setf (gethash (first proxy-nodes) *proxy-node*) tmp)
	;;for debug/swank, else comment out
	;;(eval `(defnode ,tmp (proxy) ()))
	;;
	`(let ((,(first proxy-nodes) ',tmp))

	     ;(defnode ,tmp (proxy) ())
	     (defproxy ,tmp)

	     (with-proxynodes ,(rest proxy-nodes) ,@body)))
      `(progn ,@body)))


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

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

Input:
(any-of nil
  (progn))

Output: (defmacro ANY-OF ...)


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

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

Input:
(advisable-lambda nil
  :key
  nil)

Output: (defmacro ADVISABLE-LAMBDA ...)


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

Problem: Macro call that should be transformed by UNLESS

Input: (unless nil)

Output: (defmacro UNLESS ...)


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

Problem: Macro call that should be transformed by ACASE

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

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


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

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

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

Output: (defmacro SPECIAL ...)


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

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

Input:
(resolve
  nil
  nil)

Output: (defmacro RESOLVE ...)


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

Pattern to recognize: Macro call that should be transformed by DO-GENERATOR-VALUE-LIST

Input: (do-generator-value-list 'lol-gen::some-name)

Output:
(defmacro do-generator-value-list ((var generator) &body body)
  "Like do-generator, except all values emitted by the generator are placed in a list under the user defined variable."
  (let ((g (gensym)))
    `(let ((,g ,generator))
       (loop
	  do (if-generator (,var ,g)
			   (progn ,@body)
			   (return))))))


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

Problem: Macro call that should be transformed by FNN

Input: (fnn nil (progn))

Output: (defmacro FNN ...)


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

Issue: Macro call that should be transformed by C_1

Input:
(c_1
  nil
  :key
  nil)

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


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

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

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

Output:
(defmacro trcx (tgt-form &rest os)
  (if (eql tgt-form 'nil)
      '(progn)
    `(without-c-dependency
         (call-trc t ,(format nil "TX> ~(~s~)" tgt-form)
           ,@(loop for obj in (or os (list tgt-form))
                   nconcing (list (intern (format nil "~a" obj) :keyword) obj))))))


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

Pattern to recognize: Macro call that should be transformed by DYNAMIC-WIND

Input:
(dynamic-wind
  nil
  :key
  nil)

Output: (defmacro DYNAMIC-WIND ...)


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

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

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

Output:
(defmacro select (fields &body clauses)
  `(make-statement :select
                   ,(match fields
                      ((or (list* (type keyword) _)
                           (list* (list* (type keyword) _) _))
                       `(make-clause :fields
                                     ,@(mapcar #'expand-op fields)))
                      ((type keyword) `(fields ,fields))
                      ((or (type symbol)
                           (list* (type symbol) _))
                       `(convert-if-fields-clause ,fields))
                      (otherwise fields))
                   ,@clauses))


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

Write a macro that addresses: Macro call that should be transformed by RE-SETF

Input: (re-setf nil (progn))

Output:
(defmacro re-setf (var &rest clauses)
  "SETFs VAR to the value of each clause subsequently.
   Re-uses the new value of VAR in subsequent clauses.
   Expects VAR to be a valid place for SETF."
  `(progn ,@(mapcar (lambda (clause)
                      `(setf ,var ,clause))
                    clauses)))


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

Issue: Macro call that should be transformed by FGATHERING

Input:
(fgathering nil
  :key
  nil)

Output: (defmacro FGATHERING ...)


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

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

Input:
(with-connection nil
  :key
  nil)

Output:
(defmacro with-connection (spec &body body)
  "Evaluates the body with *database* bound to a connection as specified by spec,
which should be list that connect can be applied to."
  `(let ((*database* (apply #'connect ,spec)))
     (unwind-protect (progn ,@body)
       (disconnect *database*))))


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 -> ...)


Instruction:
Generate a defmacro form that transforms code like this:
(count-failures
  nil
  nil)

Pattern to recognize: Macro call that should be transformed by COUNT-FAILURES

Input:
(count-failures
  nil
  nil)

Output: (defmacro COUNT-FAILURES ...)


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? (&body body)
  `(make-c-dependent
    :code ',body
    :value-state :unevaluated
    :rule (c-lambda ,@body)))


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

Issue: Macro call that should be transformed by FAIL

Input: (fail)

Output:
(defmacro fail ()
  "Causes the latest pattern matching to fail.  After this failure,
matching continues at the next pattern."
  ;; FIXME: Don't raise an error but expand to %FAIL for the hack
  ;; above.
  ;(error "Not pattern matching.")
  '%fail)


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 (arg) (ematch arg BODY...))."
  (multiple-value-bind (preamble clauses) (parse-matcher-body body)
    (with-gensyms (clause)
      `(lambda (,clause)
         ,@preamble
         (ematch ,clause
           ,@clauses)))))


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

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

Input:
(defaction nil
    :key
  nil)

Output: (defmacro DEFACTION ...)


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

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

Input:
(c?n
  nil)

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:
Write a Common Lisp macro to handle this code pattern:
(print-values
  nil)

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

Input:
(print-values
  nil)

Output: (defmacro PRINT-VALUES ...)


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

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

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

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


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

Issue: Macro call that should be transformed by INSERT-INTO

Input: (insert-into 'lol-gen::some-name)

Output:
(defmacro insert-into (table &body clauses)
  `(make-statement :insert-into
                   ,(expand-expression table)
                   ,@(if (and (listp (car clauses))
                              (keywordp (caar clauses)))
                         `(',(car clauses) ,@(cdr clauses))
                         clauses)))


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

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

Input: (any-of nil)

Output: (defmacro ANY-OF ...)


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

Issue: Macro call that should be transformed by UNIONF

Input: (unionf nil :key nil)

Output: (defmacro UNIONF ...)


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

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

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

Output: (defmacro -<> ...)


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

Pattern to recognize: Macro call that should be transformed by C?N-DBG

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

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


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

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

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

Output:
(defmacro aand (first &rest rest)
  "Like AND, except binds the first argument to IT (via LET) for the
scope of the rest of the arguments."
  `(anaphoric and ,first ,@rest))


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

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

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

Output: (defmacro POSSIBLY? ...)


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

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

Input:
(c?once
  nil
  (progn))

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


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

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

Input: (unionf nil nil)

Output: (defmacro UNIONF ...)


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

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

Input: (defmethod nil (progn))

Output: (defmacro DEFMETHOD ...)


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

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

Input:
(gen-lambda nil
  :key
  nil)

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


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

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

Input: (prog2 nil (progn))

Output: (defmacro PROG2 ...)


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

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

Input: (multiple-value-cmatch nil)

Output:
(defmacro multiple-value-cmatch (values-form &body clauses)
  "Same as MULTIPLE-VALUE-MATCH, except a continuable MATCH-ERROR will
be raised if none of the clauses match."
  (let* ((values (gensym "VALUES"))
         (else `(cerror "Continue."
                        'match-error
                        :values ,values
                        :patterns ',(mapcar #'car clauses))))
    ;; FIXME: remove allocations
    `(let ((,values (multiple-value-list ,values-form)))
       ,(compile-multiple-value-match `(values-list ,values) clauses else))))


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(rem-arg-list-key-value! nil (progn))

What needs to change: Macro call that should be transformed by REM-ARG-LIST-KEY-VALUE!

Input: (rem-arg-list-key-value! nil (progn))

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


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

Problem: Macro call that should be transformed by FBINDREC

Input:
(fbindrec nil
  nil)

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

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


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

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

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

Output:
(defmacro in-suite (suite-name)
  "Set the *suite* special variable so that all tests defined
after the execution of this form are, unless specified otherwise,
in the test-suite named SUITE-NAME.

See also: DEF-SUITE *SUITE*"
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (%in-suite ,suite-name)))


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

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

Input: (isnt-values nil)

Output:
(defmacro isnt-values (form &body body)
  (multiple-value-bind (comp-expected expected comparison description format-args)
      (destructure-is-values-body body)
    `(eval-in-context
      *context*
      (make-instance 'multiple-value-comparison-result
                     :expression '(isnt-values ,form ,@comp-expected)
                     :value-form ',form
                     :body (lambda () ,form)
                     :expected (list ,@expected)
                     :comparison (list ,@comparison)
                     :comparison-geq NIL
                     ,@(when description
                         `(:description (format NIL ,description ,@format-args)))))))


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

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

Input: (collect-sum 'lol-gen::some-name)

Output: (defmacro COLLECT-SUM ...)


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

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

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

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


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

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

Input:
(with-slots nil
    nil)

Output: (defmacro WITH-SLOTS ...)


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

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

Input:
(with-cc nil
  (progn))

Output:
(defmacro with-cc (id &body body)
  `(with-integrity (:change ,id)
     ,@body))


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

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

Input: (some->> nil nil)

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


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

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

Input: (setf)

Output: (defmacro SETF ...)


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

Write a macro that addresses: Macro call that should be transformed by WITH-SHADOWED-CUSTOM-VARS

Input:
(with-shadowed-custom-vars
  'lol-gen::some-name)

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


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

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

Input: (set-dynamic nil nil)

Output: (defmacro SET-DYNAMIC ...)


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

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

Input:
(update nil
  (progn))

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


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

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

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

Output:
(defmacro with-savepoint (name &body body)
  "Can only be used within a transaction. Establishes a savepoint with the given
name at the start of body, and binds the same name to a handle for that savepoint.
The body is executed and, at the end of body, the savepoint is released, unless a
condition is thrown, in which case it is rolled back. Execute the body within a
savepoint, releasing savepoint when the body exits normally, and rolling back
otherwise. NAME is both the variable that can be used to release or rolled back
before the body unwinds, and the SQL name of the savepoint.

An example might look like this:

(defun test12 (x &optional (y nil))
  (with-logical-transaction (lt1 :read-committed-rw)
    (execute (:insert-into 'test-data :set 'value 0))
    (with-savepoint sp1
      (execute (:insert-into 'test-data :set 'value 1))
      (if (< x 0)
          (rollback-savepoint sp1)
          (release-savepoint sp1)))
    (with-savepoint sp2
      (execute (:insert-into 'test-data :set 'value 2))
      (with-savepoint sp3
        (execute (:insert-into 'test-data :set 'value 3))
        (if (> x 0)
            (rollback-savepoint sp3)
            (release-savepoint sp3))
        (when y (rollback-savepoint sp2)))
      (if (= x 0)
          (rollback-savepoint sp2)
          (release-savepoint sp2)))
    (when (string= y \"abrt\")
      (abort-transaction lt1))))"

  `(call-with-savepoint ',name (lambda (,name)
                                 (declare (ignorable ,name)) ,@body)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(eval-always
  nil)

Issue: Macro call that should be transformed by EVAL-ALWAYS

Input:
(eval-always
  nil)

Output:
(defmacro eval-always (&body body)
  "Shorthand for
        (eval-when (:compile-toplevel :load-toplevel :execute) ...)"
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     ,@body))


Instruction:
Generate a defmacro form that transforms code like this:
(c?n-dbg
  nil
  (progn))

Pattern to recognize: Macro call that should be transformed by C?N-DBG

Input:
(c?n-dbg
  nil
  (progn))

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


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

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

Input:
(with-contracts-disabled nil
  :key
  nil)

Output:
(defmacro with-contracts-disabled (() &body body)
  "A shorthand for disabling all contracts for the extent of this form."
  (let ((enabled-contracts (gensym "ENABLED-CONTRACTS-")))
    `(let ((,enabled-contracts (enabled-contracts)))
       (unwind-protect
            (progn (disable-contracts)
                   ,@body)
         (apply #'enable-contracts ,enabled-contracts)))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(c?n-until nil)

Issue: Macro call that should be transformed by C?N-UNTIL

Input: (c?n-until nil)

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


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

Issue: Macro call that should be transformed by UNLESS

Input: (unless nil :key nil)

Output: (defmacro UNLESS ...)


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

Issue: Macro call that should be transformed by WITH-SYMBOL-ACCESS

Input:
(with-symbol-access
  nil)

Output: (defmacro WITH-SYMBOL-ACCESS ...)


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

Problem: Macro call that should be transformed by WHICHEVER

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

Output:
(defmacro whichever (&rest possibilities &environment env)
  "Evaluates exactly one of POSSIBILITIES, chosen at random."
  (setf possibilities (mapcar (lambda (p) (macroexpand p env)) possibilities))
  (let ((length (length possibilities)))
    (cond
      ((= 1 length)
       (first possibilities))
      ((every #'constantp possibilities)
       `(svref (load-time-value (vector ,@possibilities))
               (random ,length)))
      (T
       (labels ((expand (possibilities position random-number)
                  (if (null (cdr possibilities))
                      (car possibilities)
                      (let* ((length (length possibilities))
                             (half (truncate length 2))
                             (second-half (nthcdr half possibilities))
                             (first-half (butlast possibilities (- length half))))
                        `(if (< ,random-number ,(+ position half))
                             ,(expand first-half position random-number)
                             ,(expand second-half (+ position half) random-number))))))
         (with-gensyms (random-number)
           `(let ((,random-number (random ,length)))
              ,(expand possibilities 0 random-number))))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(ignore-some-conditions nil)

Issue: Macro call that should be transformed by IGNORE-SOME-CONDITIONS

Input: (ignore-some-conditions nil)

Output:
(defmacro ignore-some-conditions ((&rest conditions) &body body)
  "Similar to CL:IGNORE-ERRORS but the (unevaluated) CONDITIONS
list determines which specific conditions are to be ignored."
  `(handler-case
       (progn ,@body)
     ,@(loop for condition in conditions collect
             `(,condition (c) (values nil c)))))


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

Issue: Macro call that should be transformed by SEND

Input: (send nil nil)

Output: (defmacro SEND ...)


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

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

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

Output:
(defmacro fm-other (md-name &key (starting 'self) skip-tree (test '#'true-that))
  `(fm-find-one ,starting ,(if (consp md-name)
                               `(list ',(car md-name) ,(cadr md-name))
                             `',md-name)
                :must-find t
                :skip-tree ,skip-tree
                :global-search t
                :test ,test))


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

Problem: Macro call that should be transformed by MARKUP

Input: (markup nil)

Output:
(defmacro markup (&rest tags)
  `(%write-strings
    ,@(loop for tag in tags
            append (tag->string tag))))


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

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

Input: (psetq nil nil)

Output: (defmacro PSETQ ...)


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

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

Input:
(fluid-bind nil
  nil)

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:
Generate a defmacro form that transforms code like this:
(define-method-combination nil :key nil)

Pattern to recognize: Macro call that should be transformed by DEFINE-METHOD-COMBINATION

Input: (define-method-combination nil :key nil)

Output:
(defmacro define-method-combination (name &rest args)
  `(progn
     (define-method-combination% ,name ,@args)
     (c2mop:define-method-combination ,name ,@args)))


Instruction:
Generate a defmacro form that transforms code like this:
(with-standard-io-syntax nil (progn))

Pattern to recognize: Macro call that should be transformed by WITH-STANDARD-IO-SYNTAX

Input: (with-standard-io-syntax nil (progn))

Output: (defmacro WITH-STANDARD-IO-SYNTAX ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(named-lambda nil
    :key
  nil)

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

Input:
(named-lambda nil
    :key
  nil)

Output:
(defmacro named-lambda (name lambda-list &body body)
  "Expands into a lambda-expression within whose BODY NAME denotes the
corresponding function."
  `(labels ((,name ,lambda-list ,@body))
     #',name))


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

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

Input:
(dreletf* nil
  :key
  nil)

Output: (defmacro DRELETF* ...)


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

Problem: Macro call that should be transformed by DEFUNION

Input:
(defunion nil
  (progn))

Output:
(defmacro defunion (union &body variants)
  "Define an algebraic data type.

Each expression in VARIANTS is either a symbol \(in which case it
defines a unit type, as with `defunit') or a list \(in which case it
defines a read-only structure, as with `defconstructor').

UNION is defined as a type equivalent to the disjunction of all the
member types. A class is also defined, with the same name, but with
angle brackets around it."
  (let* ((docstring (and (stringp (first variants))
                         (pop variants)))
         (ctors (remove-if-not #'listp variants))
         (units (remove-if-not #'atom variants))
         (types (append units (mapcar #'first ctors)))
         (super (symbolicate '< union '>)))
    ;; CCL (and maybe other lisps) evaluates `(:include)' options at
    ;; macroexpansion time and does some environment augmenting and checking
    ;; that fails to account for our `env-super' trick.
    ;; So define the abstract base struct via a `progn' at the toplevel.
    `(progn
       (eval-when (:compile-toplevel :load-toplevel :execute)
         (defstruct (,super
                     (:constructor nil)
                     (:copier nil)
                     (:predicate nil)
                     (:include %read-only-struct))
           ,@(unsplice docstring)))
       ;; NB The declarations are not currently used, due to an SBCL bug.
       (locally (declare #+sbcl (sb-ext:disable-package-locks %union))
         (symbol-macrolet ((serapeum/unlocked:%union ,super))
           (declare #+sbcl (sb-ext:enable-package-locks %union))
           (deftype ,union ()
             ,@(unsplice docstring)
             '(or ,@types))
           ,@(loop for type in units
                   collect `(defunit ,type))
           ,@(loop for (type . slots) in ctors
                   collect `(defconstructor ,type ,@slots))
           (declaim-freeze-type ,super)
           ',union)))))


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

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

Input:
(letmatch nil
    nil)

Output: (defmacro LETMATCH ...)


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

Problem: Macro call that should be transformed by DELETE-FROM-PLISTF

Input: (delete-from-plistf nil nil)

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


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

Issue: Macro call that should be transformed by IGNORE-ERRORS

Input: (ignore-errors 'lol-gen::some-name)

Output: (defmacro IGNORE-ERRORS ...)


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 -<>> (init &body exps) (diamond-wand init exps t))


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

Issue: Macro call that should be transformed by ALET

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

Output:
(defmacro alet (form &body body)
  "Binds the FORM to IT (via LET) in the scope of the BODY."
  `(anaphoric ignore-first ,form (progn ,@body)))


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

Issue: Macro call that should be transformed by OK?

Input: (ok? nil)

Output:
(defmacro ok? (x)
  "Did parsing succeed?"
  `(cl:not (failure? ,x)))


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

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

Input: (or nil)

Output: (defmacro OR ...)


Instruction:
Generate a defmacro form that transforms code like this:
(walk-environment
  nil
  nil)

Pattern to recognize: Macro call that should be transformed by WALK-ENVIRONMENT

Input:
(walk-environment
  nil
  nil)

Output: (defmacro WALK-ENVIRONMENT ...)


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

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

Input: (<- nil nil)

Output:
(defmacro <- (place fn)
    "Apply FN in-place to PLACE."
    `(setf ,place (call ,fn ,place)))


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

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

Input:
(static-let nil
  nil)

Output:
(defmacro static-let ((&rest bindings) &body body)
  "Like `let', except the variables are only initialized once and
retain their values between different invocations of `body'.

Every static binding is similar to a `let' binding, except it can have
additional keyword arguments:

- `type' Denotes the type of the variable.
- `once' If true, then binding initialization and mutation will be
         thread-safe.
- `flush' If true, this binding will be flushable. Defaults to true.
- `in' Denotes the static binding group in which the binding will be
       placed for flushing. Defaults to the value of `*package'.
- `read-only' If true, then the binding cannot be mutated with `setf'.

Static bindings can be flushed via `flush-static-binding-group' and
`flush-all-static-binding-groups'; the latter is automatically pushed
into `uiop:*dump-image-hooks*' by Serapeum.

An unflushable static binding will carry its value over into dumped
Lisp binaries."
  (parse-static-let bindings body))


Instruction:
Generate a defmacro form that transforms code like this:
(pprint-coalton-codegen-ast
  'lol-gen::some-name)

Pattern to recognize: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-AST

Input:
(pprint-coalton-codegen-ast
  'lol-gen::some-name)

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


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

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

Input: (appendf nil)

Output: (defmacro APPENDF ...)


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

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

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

Output: (defmacro DECF ...)


Instruction:
Generate a defmacro form that transforms code like this:
(define-setf-expander nil ())

Pattern to recognize: Macro call that should be transformed by DEFINE-SETF-EXPANDER

Input: (define-setf-expander nil ())

Output: (defmacro DEFINE-SETF-EXPANDER ...)


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

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

Input:
(eval-always
  common-lisp:nil
  common-lisp:nil)

Output: (defmacro EVAL-ALWAYS ...)


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

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

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

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

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


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

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

Input:
(defplace nil
    :key
  nil)

Output:
(defmacro defplace (name args &body body)
  "Define NAME and (SETF NAME) in one go.

BODY is a list of forms, starting with an optional docstring. The last
form in BODY, however, must be a single, setf-able expression."
  (match body
    ((list (type string))
     (error "No form for ~s: ~a" 'defplace body))
    ((last (cons (type string) nil) 1)
     `(defplace ,name ,args ,@(reverse body)))
    (otherwise
     (with-gensyms (value)
       `(progn
          (defun ,name ,args
            ,@body)
          (defun (setf ,name) (,value ,@args)
            ,@(butlast body)
            (setf ,(lastcar body) ,value)))))))


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

Problem: Macro call that should be transformed by DEFSYNONYM

Input: (defsynonym nil (progn))

Output:
(defmacro defsynonym (syn word)
  "Makes SYN a synonym for the existing iterate keyword WORD."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (get ',syn 'synonym) ',word)))


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

Problem: Macro call that should be transformed by WHEN

Input: (when nil (progn))

Output: (defmacro WHEN ...)


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

Pattern to recognize: Macro call that should be transformed by FGATHER-NEXT

Input: (fgather-next nil (progn))

Output: (defmacro FGATHER-NEXT ...)


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

Issue: Macro call that should be transformed by DLETF*

Input:
(dletf* nil
  nil)

Output: (defmacro DLETF* ...)


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

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

Input: (define-language nil (progn))

Output: (defmacro DEFINE-LANGUAGE ...)


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

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

Input: (match nil (progn))

Output: (defmacro MATCH ...)


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

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

Input:
(c_?dbg
  'lol-gen::some-name)

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


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-string-dispatch nil
    :key
  nil)

Issue: Macro call that should be transformed by WITH-STRING-DISPATCH

Input:
(with-string-dispatch nil
    :key
  nil)

Output:
(defmacro with-string-dispatch ((&rest types) var &body body)
  "Like `with-subtype-dispatch' with an overall type of `string'."
  `(with-subtype-dispatch string
       ;; Always specialize for (simple-array character (*)).
       ((simple-array character (*))
        (simple-array base-char (*))
        ,@types)
       ,var
     ,@body))


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

Write a macro that addresses: Macro call that should be transformed by CASE-USING

Input:
(case-using nil
    nil)

Output:
(defmacro case-using (pred keyform &body clauses)
  "ISLISP's case-using.

     (case-using #'eql x ...)
     ≡ (case x ...).

Note that, no matter the predicate, the keys are not evaluated. (But
see `selector'.)

The PRED form is evaluated.

When PRED is invoked, KEYFORM is its first argument. You can use
`flip' if you want the arguments passed the other way around. For
example, to dispatch on potential elements of a list:

    (case-using list (flip #'member)
      (:item1 ...))

This version supports both single-item clauses (x ...) and
multiple-item clauses ((x y) ...), as well as (t ...) or (otherwise
...) for the default clause."
  (case (extract-function-name pred)
    (eql
     `(case ,keyform
        ,@clauses))
    ;; TODO Check that this isn't rebound in the environment. (Not a
    ;; concern on SBCL as the package is locked there.)
    (string=
     `(string-case ,keyform
        ,@clauses))
    (t `(case-using-aux ,pred ,keyform
          ,@clauses))))


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

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

Input: (some->> nil)

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


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

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

Input: (and-let* nil)

Output:
(defmacro and-let* ((&rest clauses) &body body &environment env)
  "Scheme's guarded LET* (SRFI-2).

Each clause should have one of the following forms:

- `identifier', in which case IDENTIFIER's value is tested.

- `(expression)', in which case the value of EXPRESSION is tested.

- `(identifier expression)' in which case EXPRESSION is evaluated,
    and, if its value is not false, IDENTIFIER is bound to that value
    for the remainder of the clauses and the optional body.

Note that, of course, the semantics are slightly different in Common
Lisp than in Scheme, because our AND short-circuits on null, not
false.

Also, this version makes the bindings immutable."
  (multiple-value-bind (body decls)
      (parse-body body)
    (labels ((expand (clauses body)
               (unsplice
                (ematch clauses
                  (() (if body `(progn ,@body) nil))
                  ((list* (and var (type symbol)) clauses)
                   `(and ,var ,@(expand clauses body)))
                  ((list* (list var expr) clauses)
                   (let ((temp (gensym (string var))))
                     (multiple-value-bind (local-decls other-decls)
                         (partition-declarations (list var) decls env)
                       ;; The use of the temporary here is so we still
                       ;; get style warnings if the variable is
                       ;; unused.
                       `(let* ((,temp ,expr)
                               (,var ,temp))
                          ,@local-decls
                          (and ,temp
                               ,@(expand clauses
                                         (append other-decls body)))))))
                  ((list* (list expr) clauses)
                   `(and ,expr ,@(expand clauses body)))))))
      (car (expand clauses body)))))


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

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

Input: (true nil :key nil)

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


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

Issue: Macro call that should be transformed by RETURN

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

Output: (defmacro RETURN ...)


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

Problem: Macro call that should be transformed by MATCH

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

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


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

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

Input: (and nil (progn))

Output: (defmacro AND ...)


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

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

Input: (mapping nil (progn))

Output: (defmacro MAPPING ...)


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

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

Input: (prependf nil nil)

Output: (defmacro PREPENDF ...)


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

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

Input: (implies nil nil)

Output:
(defmacro implies (condition consequent)
  "A boolean operator that evaluates to the value of CONSEQUENT if CONDITION is
   true, and otherwise evaluates to T. This isn't particularly specific to Quid
   Pro Quo, but it is a useful logical operator for contracts."
  `(if ,condition ,consequent t))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(pprint-coalton-codegen-types)

Problem: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-TYPES

Input: (pprint-coalton-codegen-types)

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


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

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

Input:
(with-keys nil
    nil)

Output:
(defmacro with-keys ((&rest kv-pairs) ht &body body)
  "Like WITH-ACCESSORS but for pairs in hash-table HT."
  (once-only (ht)
    `(let (,@(mapcar #`(list (car %) `(gethash ,(second %) ,ht))
                     kv-pairs))
       ,@body)))


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

Problem: Macro call that should be transformed by WITH-CONTRACTS-DISABLED

Input: (with-contracts-disabled nil)

Output:
(defmacro with-contracts-disabled (() &body body)
  "A shorthand for disabling all contracts for the extent of this form."
  (let ((enabled-contracts (gensym "ENABLED-CONTRACTS-")))
    `(let ((,enabled-contracts (enabled-contracts)))
       (unwind-protect
            (progn (disable-contracts)
                   ,@body)
         (apply #'enable-contracts ,enabled-contracts)))))


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

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

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

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


Instruction:
Define a macro that eliminates this repetitive pattern:
(unwind-protect-case nil
    nil)

Issue: Macro call that should be transformed by UNWIND-PROTECT-CASE

Input:
(unwind-protect-case nil
    nil)

Output:
(defmacro unwind-protect-case ((&optional abort-flag) protected-form &body clauses)
  "Like CL:UNWIND-PROTECT, but you can specify the circumstances that
the cleanup CLAUSES are run.

  clauses ::= (:NORMAL form*)* | (:ABORT form*)* | (:ALWAYS form*)*

Clauses can be given in any order, and more than one clause can be
given for each circumstance. The clauses whose denoted circumstance
occured, are executed in the order the clauses appear.

ABORT-FLAG is the name of a variable that will be bound to T in
CLAUSES if the PROTECTED-FORM aborted preemptively, and to NIL
otherwise.

Examples:

  (unwind-protect-case ()
       (protected-form)
     (:normal (format t \"This is only evaluated if PROTECTED-FORM executed normally.~%\"))
     (:abort  (format t \"This is only evaluated if PROTECTED-FORM aborted preemptively.~%\"))
     (:always (format t \"This is evaluated in either case.~%\")))

  (unwind-protect-case (aborted-p)
       (protected-form)
     (:always (perform-cleanup-if aborted-p)))
"
  (check-type abort-flag (or null symbol))
  (let ((gflag (gensym "FLAG+")))
    `(let ((,gflag t))
       (unwind-protect (multiple-value-prog1 ,protected-form (setf ,gflag nil))
	 (let ,(and abort-flag `((,abort-flag ,gflag)))
	   ,@(loop for (cleanup-kind . forms) in clauses
		   collect (ecase cleanup-kind
			     (:normal `(when (not ,gflag) ,@forms))
			     (:abort  `(when ,gflag ,@forms))
			     (:always `(progn ,@forms)))))))))


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

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

Input:
(defannotation nil
    :key
    nil)

Output:
(defmacro defannotation (name lambda-list options &body body)
  `(progn
     (set-annotation-options ',name ',options)
     (defmacro ,name ,lambda-list ,@body)))


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

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

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

Output: (defmacro PS ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
(on-duplicate-key-update nil nil)

Problem: Macro call that should be transformed by ON-DUPLICATE-KEY-UPDATE

Input: (on-duplicate-key-update nil nil)

Output:
(defmacro on-duplicate-key-update (&rest args)
  `(make-clause :on-duplicate-key-update ,@(mapcar #'expand-op args)))


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

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

Input: (defunit nil (progn))

Output:
(defmacro defunit (name &optional docstring
                   &environment env)
  "Define a unit type.

A unit type is a type with only one instance.

You can think of a unit type as a singleton without state.

Unit types are useful for many of the same purposes as quoted symbols
\(or keywords) but, unlike a symbol, a unit type is tagged with its
own individual type."
  (let ((ctor (symbolicate '%make- name))
        (super (env-super env '%unit)))
    `(progn
       (eval-when (:compile-toplevel :load-toplevel :execute)
         (defstruct (,name
                     (:include ,super)
                     (:constructor ,ctor)
                     (:copier nil)
                     (:predicate nil)
                     (:print-function print-unit))
           ,@(unsplice docstring)))
       (eval-when (:compile-toplevel :load-toplevel :execute)
         (defmethod make-load-form ((x ,name) &optional env)
           (declare (ignore env))
           '(intern-unit ',name ',ctor)))
       (defmethod %constructor= ((x ,name) (y ,name))
         t)
       (defconst ,name (intern-unit ',name ',ctor))
       (declaim-freeze-type ,name)
       (fmakunbound ',ctor)
       ',name)))


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

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

Input: (markup)

Output:
(defmacro markup (&rest tags)
  `(%write-strings
    ,@(loop for tag in tags
            append (tag->string tag))))


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

Issue: Macro call that should be transformed by XOR

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

Output:
(defmacro xor (&rest datums)
  "Evaluates its arguments one at a time, from left to right. If more than one
argument evaluates to a true value no further DATUMS are evaluated, and NIL is
returned as both primary and secondary value. If exactly one argument
evaluates to true, its value is returned as the primary value after all the
arguments have been evaluated, and T is returned as the secondary value. If no
arguments evaluate to true NIL is returned as primary, and T as secondary
value."
  (with-gensyms (xor tmp true)
    `(let (,tmp ,true)
       (declare (ignorable ,tmp))
       (block ,xor
         ,@(mapcar (lambda (datum)
                     `(if (setf ,tmp ,datum)
                          (if ,true
                              (return-from ,xor (values nil nil))
                              (setf ,true ,tmp))))
                   datums)
         (return-from ,xor (values ,true t))))))


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

Problem: Macro call that should be transformed by ENABLE-ANNOT-SYNTAX

Input: (enable-annot-syntax)

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


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

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

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

Output: (defmacro COLLECT-MAX ...)


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

Issue: Macro call that should be transformed by DRELET

Input:
(drelet nil
  (progn))

Output: (defmacro DRELET ...)


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

Problem: Macro call that should be transformed by WITH-LOGICAL-TRANSACTION

Input:
(with-logical-transaction nil
  nil)

Output:
(defmacro with-logical-transaction ((&optional (name nil name-p)
                                       (isolation-level *isolation-level*
                                                        isolation-level-p))
                                    &body body)
  "Executes body within a with-transaction form if no transaction is currently
in progress, otherwise simulates a nested transaction by executing it
within a with-savepoint form. The transaction or savepoint is bound to name
if one is supplied. The isolation-level will set the isolation-level used by
the transaction.

You can specify the following isolation levels in postmodern transactions:

- :read-committed-rw (read committed with read and write)
- :read-committed-ro (read committed with read only)
- :repeatable-read-rw (repeatable read with read and write)
- :repeatable-read-ro (repeatable read with read only)
- :serializable (serializable with reand and write)

Sample usage where george is just the name given to the transaction (not
quoted or a string) and ... simply indicates other statements would be
expected here:

  (with-logical-transaction ()
    (execute (:insert-into 'test-data :set 'value 77))
    ...)

  (with-logical-transaction (george)
    (execute (:insert-into 'test-data :set 'value 22))
    ...)

  (with-logical-transaction (george :read-committed-rw)
    (execute (:insert-into 'test-data :set 'value 33))
    ...)

  (with-logical-transaction (:serializable)
    (execute (:insert-into 'test-data :set 'value 44))
    ...)"
  (let* ((effective-name (if (and name-p (not (isolation-level-p name)))
                             name
                             (gensym)))
         (effective-body (if (and name-p (not (isolation-level-p name)))
                             `(lambda (,name) ,@body)
                             `(lambda (,effective-name)
                                (declare (ignore ,effective-name))
                                ,@body)))
         (effective-isolation-level (cond ((and isolation-level-p
                                                (isolation-level-p isolation-level))
                                           isolation-level)
                                          ((and name-p (isolation-level-p name))
                                           name)
                                          (t isolation-level))))
    `(call-with-logical-transaction ',effective-name ,effective-body
                                    ,effective-isolation-level)))


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

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

Input: (is-error nil nil)

Output: (defmacro IS-ERROR ...)


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

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

Input:
(as-array-member nil
  nil)

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:
Write a Common Lisp macro to handle this code pattern:
(either
  nil)

Problem: Macro call that should be transformed by EITHER

Input:
(either
  nil)

Output: (defmacro EITHER ...)


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

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

Input: (terminate)

Output: (defmacro TERMINATE ...)


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

Write a macro that addresses: Macro call that should be transformed by LTBDD-WITH-NEW-HASH

Input: (ltbdd-with-new-hash 'lol-gen::some-name)

Output: (defmacro LTBDD-WITH-NEW-HASH ...)


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

Problem: Macro call that should be transformed by WITH-CURRENT-SOURCE-FORM

Input: (with-current-source-form 'lol-gen::some-name)

Output: (defmacro WITH-CURRENT-SOURCE-FORM ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(make-simple-collector-to-place nil)

What needs to change: Macro call that should be transformed by MAKE-SIMPLE-COLLECTOR-TO-PLACE

Input: (make-simple-collector-to-place nil)

Output: (defmacro MAKE-SIMPLE-COLLECTOR-TO-PLACE ...)


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

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

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

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


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

Issue: Macro call that should be transformed by FMV

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

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


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

Write a macro that addresses: Macro call that should be transformed by TREE-CASE

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

Output: (defmacro TREE-CASE ...)


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

Write a macro that addresses: Macro call that should be transformed by PUSH-END

Input: (push-end nil (progn))

Output:
(defmacro push-end (item place &environment env)
  "Destructively push ITEM to the end of PLACE.
Like `push', but affects the last item rather than the first.

You may want to use `enq' on a `queue' instead.

From LispWorks."
  (multiple-value-bind (dummies vals temps setter getter)
      (get-setf-expansion place env)
    (when (rest temps) (error "Invalid place for push-end"))
    (let ((temp (car temps)))
      `(let* (,@(mapcar #'list dummies vals)
              (,temp ,getter))
         (setf ,temp (nconc1 ,temp ,item))
         ,setter))))


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

Problem: Macro call that should be transformed by IGNORE

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

Output: (defmacro IGNORE ...)


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

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

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

Output: (defmacro EXPORT-ACCESSORS ...)


Instruction:
Generate a defmacro form that transforms code like this:
(defparameter-unbound nil
  nil)

Pattern to recognize: Macro call that should be transformed by DEFPARAMETER-UNBOUND

Input:
(defparameter-unbound nil
  nil)

Output:
(defmacro defparameter-unbound (var &body (docstring))
  "Like `defvar-unbound', but ensures VAR is unbound when evaluated."
  `(progn
     (defvar ,var)
     (makunbound ',var)
     (setf (documentation ',var 'variable) ,docstring)
     ',var))


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

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

Input: (esc)

Output:
(defmacro esc (&rest forms)
  `(list
    ,@(loop for form in forms
            collect (%escape-string-form form))))


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

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

Input: (ensure-list 'lol-gen::some-name)

Output:
(defmacro ensure-list (item &body body)
  `(let ((,item (if (listp ,item) ,item '(,item))))
     ,@body))


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

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

Input: (is-print nil :key nil)

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:
(with-standard-io-syntax nil :key nil)

Pattern to recognize: Macro call that should be transformed by WITH-STANDARD-IO-SYNTAX

Input: (with-standard-io-syntax nil :key nil)

Output: (defmacro WITH-STANDARD-IO-SYNTAX ...)


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

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

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

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


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

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

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

Output: (defmacro -> ...)


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

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

Input: (fail nil)

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


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

Pattern to recognize: Macro call that should be transformed by MAKE-LIST

Input: (make-list common-lisp:nil :key common-lisp:nil)

Output:
(defmacro make-list (cl:&rest forms)
  "Create a heterogeneous Coalton `List` of objects. This macro is
deprecated; use `coalton/list:make`."
  (cl:labels
      ((list-helper (forms)
         (cl:if (cl:endp forms)
                `coalton:Nil
                `(coalton:Cons ,(cl:car forms) ,(list-helper (cl:cdr forms))))))
    (list-helper forms)))


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

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

Input: (matrix-ecase 'lol-gen::some-name)

Output: (defmacro MATRIX-ECASE ...)


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

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

Input:
(with-explicit-encoder
  'lol-gen::some-name)

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


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

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

Output: (defmacro -<> ...)


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

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

Input:
(local-output
  'lol-gen::some-name)

Output: (defmacro LOCAL-OUTPUT ...)


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

Problem: Macro call that should be transformed by MULTIPLE-VALUE-LIST

Input: (multiple-value-list 'lol-gen::some-name)

Output: (defmacro MULTIPLE-VALUE-LIST ...)


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

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

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

Output: (defmacro DIG ...)


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

Problem: Macro call that should be transformed by SYNCHRONIZED

Input:
(synchronized nil
  (progn))

Output:
(defmacro synchronized ((&optional (object nil objectp)) &body body &environment env)
  "Run BODY holding a unique lock associated with OBJECT.
If no OBJECT is provided, run BODY as an anonymous critical section.

If BODY begins with a literal string, attach the string to the lock
object created (as the argument to `bt:make-recursive-lock')."
  (multiple-value-bind (string? body)
      (if (stringp (first body))
          (values (first body) (rest body))
          (values nil body))
    (let* ((form (lock-form object objectp env string?)))
      (with-gensyms (lock)
        `(let ((,lock ,form))
           (bt:with-recursive-lock-held (,lock)
             ;; On some Lisps this would return T if empty.
             ,@(or body '(nil))))))))


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

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

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

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

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

Input:
(defun* nil
    (progn))

Output: (defmacro DEFUN* ...)


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

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

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

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


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

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

Input: (terminate)

Output:
(defmacro terminate () ; recommended for use with FOR ... NEXT
  "Use within FOR ... DO-/NEXT clause to end the iteration"
  '(finish))


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

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

Input: (producing nil)

Output: (defmacro PRODUCING ...)


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

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

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

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

Input: (->> nil)

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


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

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

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

Output: (defmacro DEFMACRO ...)


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

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

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

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


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

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

Input: (skip nil :key nil)

Output:
(defmacro skip (&rest reason)
  "Generates a TEST-SKIPPED result."
  `(add-result 'test-skipped :reason (format nil ,@reason)))


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

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

Input:
(define-module nil
  nil)

Output:
(defmacro define-module (name &body options)
  (let ((name (string name))
        (package (gensym "PACKAGE")))
    `(eval-when (:compile-toplevel :load-toplevel :execute)
       (let ((,package (or (find-package ,name)
                           (make-package ,name :use ()))))
         (modularize :package ,package :name ,name)
         (expand-module ,name ',options)
         ,package))))


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

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

Input: (do-iter-values nil)

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:
Define a macro that eliminates this repetitive pattern:
(defparameter-unbound nil
  (progn))

Issue: Macro call that should be transformed by DEFPARAMETER-UNBOUND

Input:
(defparameter-unbound nil
  (progn))

Output:
(defmacro defparameter-unbound (var &body (docstring))
  "Like `defvar-unbound', but ensures VAR is unbound when evaluated."
  `(progn
     (defvar ,var)
     (makunbound ',var)
     (setf (documentation ',var 'variable) ,docstring)
     ',var))


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

Problem: Macro call that should be transformed by LAMBDA-MATCH1

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

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


Instruction:
Generate a defmacro form that transforms code like this:
(define-option-expander nil
    (progn))

Pattern to recognize: Macro call that should be transformed by DEFINE-OPTION-EXPANDER

Input:
(define-option-expander nil
    (progn))

Output:
(defmacro define-option-expander (name (package &rest arguments) &body body)
  (let ((args (gensym "ARGS")))
    `(defmethod expand-option ((,(gensym "TYPE") (eql ,(intern (string name) "KEYWORD"))) ,package ,args)
       (destructuring-bind ,arguments ,args
         ,@body))))


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

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

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

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


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

Issue: Macro call that should be transformed by DEFPROTOCOL

Input: (defprotocol nil)

Output: (defmacro DEFPROTOCOL ...)


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

What needs to change: Macro call that should be transformed by PUSH-END-NEW

Input: (push-end-new nil nil)

Output:
(defmacro push-end-new (item place
                        &rest kwargs
                        &key key test test-not
                        &environment env)
  "Pushes ITEM to the end of place (like `push-end') but only if it not already a member of PLACE (like `pushnew').

For the use of KEY, TEST, and TEST-NOT, see `pushnew'."
  (declare (ignore key test test-not))
  (once-only (item)
    (multiple-value-bind (dummies vals temps setter getter)
        (get-setf-expansion place env)
      (when (rest temps) (error "Invalid place for push-end"))
      (let ((temp (car temps)))
        `(let* (,@(mapcar #'list dummies vals)
                (,temp ,getter))
           (unless (member ,item ,temp ,@kwargs)
             (setf ,temp (nconc1 ,temp ,item)))
           ,setter)))))


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

Problem: Macro call that should be transformed by LAMBDA-CMATCH1

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

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


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

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

Input:
(->
  nil
  :key
  nil)

Output: (defmacro -> ...)


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

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

Input: (the nil :key nil)

Output: (defmacro THE ...)


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

Issue: Macro call that should be transformed by APPENDF

Input: (appendf nil :key nil)

Output: (defmacro APPENDF ...)


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

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

Input: (try-as 'lol-gen::some-name)

Output:
(defmacro try-as (type cl:&optional (expr cl:nil expr-supplied-p))
  "A syntactic convenience for type casting.

    (try-as <type> <expr>)

is equivalent to

    (the (Optional <type>) (tryInto <expr>))

and

    (try-as <type>)

is equivalent to

    (fn (expr) (the (Optional <type>) (tryInto expr))).

Note that this may copy the object or allocate memory."

  (cl:let ((try-into (cl:ignore-errors (cl:find-symbol "TRYINTO" "COALTON/CLASSES")))
           (Optional (cl:ignore-errors (cl:find-symbol "OPTIONAL" "COALTON/CLASSES"))))
    (cl:assert try-into () "`try-as` macro does not have access to `try-into` yet.")
    (cl:assert Optional () "`try-as` macro does not have access to `Optional` yet.")
    (cl:if expr-supplied-p
           `(the (,Optional ,type) (,try-into ,expr))
           (alexandria:with-gensyms (lexpr)
             `(fn (,lexpr)
                (the (,Optional ,type) (,try-into ,lexpr)))))))


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

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

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

Output: (defmacro DLETF* ...)


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

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

Input:
(dynamic-let nil
  :key
  nil)

Output: (defmacro DYNAMIC-LET ...)


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

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

Input: (defpackage nil :key nil)

Output: (defmacro DEFPACKAGE ...)


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

Issue: Macro call that should be transformed by PROG*

Input: (prog* () (progn))

Output: (defmacro PROG* ...)


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

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

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

Output: (defmacro LOCAL ...)


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

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

Input: (make-instance* nil)

Output:
(defmacro make-instance* (class &rest arguments)
  "Convenience macro on top of `make-instance'.

Conveniences:

- First argument can be a (possibly empty) list of shortcut symbols,
  which is automatically converted into a KEYWORD+SYMBOL pairs where
  - KEYWORD is the same as shortcut name, but interned as keyword.
  - And SYMBOL is the same as shortcut.

- The last argument can be an apply argument---arbitrary
  list-producing form, which will be used as the last argument
  to (apply #'make-instance ...) idiom.

Note that using a singular shortcut list of apply argument is an
ambiguous case that will be interpreted in favor of apply argument. To
force either of interpretations, provide shortcuts and apply arguments
explicitly:
(make-instance* 'class (a b c)) ;; BAD
(make-instance* 'class (a b c) nil) ;; GOOD
(make-instance* 'class (when t nil)) ;; BAD
(make-instance* 'class () (when t nil)) ;; GOOD

Otherwise, the behavior is equivalent to `make-instance'.

Examples:

Shortcut args:
\(make-instance* 'class (a b c))
=>
\(make-instance 'class :a a :b b :c c)

Last form converted into `apply' argument:
\(make-instance* 'class :c c :b b (when something (list :a a)))
=>
\(apply #'make-instance 'class :c c :b b (when something (list :a a)))

Shortcut arguments, regular arguments, and form for `apply':
\(make-instance* 'class (b c) :x x (when something (list :a a)))
=>
\(apply #'make-instance 'class :b b :c c :x x (when something (list :a a)))

Form for `apply' (notice the empty shortcuts---these are required for
unambiguous parsing):
\(make-instance* 'class () (when something (list :a a)))
=>
\(apply #'make-instance 'class (when something (list :a a)))

Regular `make-instance'-like use:
\(make-instance* 'class :a a-value :b b-value)
=>
\(make-instance 'class :a a-value :b b-value)"
  (when (and (= 1 (length arguments))
             (listp (first arguments)))
    (style-warn "Body of MAKE-INSTANCE* contains a single list-like form ~a.

If you meant APPLY args, add empty shortcuts list:
(make-instance* 'class () (apply-form))

If you meant shortcut list, add empty APPLY args:
(make-instance* 'class (shortcuts) nil)

Interpreting as APPLY args for now, but this behavior may change in
the future." arguments))
  (let* ((shortcuts-p (and (listp (first arguments))
                           (> (length arguments) 1)))
         (shortcuts (when shortcuts-p
                      (first arguments)))
         (arguments (if shortcuts-p
                        (rest arguments)
                        arguments))
         (last-appendable-form-p (oddp (length arguments)))
         (last-appendable-form (when last-appendable-form-p
                                 (first (last arguments))))
         (arguments (if last-appendable-form-p
                        (butlast arguments)
                        arguments)))
    `(,@(if last-appendable-form-p
            `(apply #'make-instance)
            `(make-instance))
      ,class
      ,@(loop for shortcut in shortcuts
              append (list (intern (symbol-name shortcut) :keyword)
                           shortcut))
      ,@arguments
      ,@(when last-appendable-form-p
          (list last-appendable-form)))))


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

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

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

Output: (defmacro INLINE ...)


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

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

Input: (when-it nil)

Output:
(defmacro when-it (test &body body)
  "Like WHEN. IT is bound to TEST."
  `(let ((it ,test))
     (when it
       ,@body)))


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

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

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

Output: (defmacro STEP ...)


Instruction:
Generate a defmacro form that transforms code like this:
(def-kid-slots nil (progn))

Pattern to recognize: Macro call that should be transformed by DEF-KID-SLOTS

Input: (def-kid-slots nil (progn))

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:
(lambda-cmatch)

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

Input: (lambda-cmatch)

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


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-standard-input-syntax
  nil
  nil)

Issue: Macro call that should be transformed by WITH-STANDARD-INPUT-SYNTAX

Input:
(with-standard-input-syntax
  nil
  nil)

Output:
(defmacro with-standard-input-syntax (&body body)
  "Like `with-standard-io-syntax', but only bind the variables that
control the reader, not the printer.

This may be preferable to using `with-standard-io-syntax' when loading
data, as it will not effect how errors are printed, thus preserving
debugging information."
  (with-thunk ((body :name with-standard-input-syntax))
    `(call/standard-input-syntax ,body)))


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

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

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

Output: (defmacro ACROSS ...)


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

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

Input:
(static-let nil
  (progn))

Output:
(defmacro static-let ((&rest bindings) &body body)
  "Like `let', except the variables are only initialized once and
retain their values between different invocations of `body'.

Every static binding is similar to a `let' binding, except it can have
additional keyword arguments:

- `type' Denotes the type of the variable.
- `once' If true, then binding initialization and mutation will be
         thread-safe.
- `flush' If true, this binding will be flushable. Defaults to true.
- `in' Denotes the static binding group in which the binding will be
       placed for flushing. Defaults to the value of `*package'.
- `read-only' If true, then the binding cannot be mutated with `setf'.

Static bindings can be flushed via `flush-static-binding-group' and
`flush-all-static-binding-groups'; the latter is automatically pushed
into `uiop:*dump-image-hooks*' by Serapeum.

An unflushable static binding will carry its value over into dumped
Lisp binaries."
  (parse-static-let bindings body))


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

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

Input: (skip nil nil)

Output:
(defmacro skip (&rest reason)
  "Generates a TEST-SKIPPED result."
  `(add-result 'test-skipped :reason (format nil ,@reason)))


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

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

Input: (local*)

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

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


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

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

Input:
(with-fixtures nil
  nil)

Output:
(defmacro with-fixtures (fixtures &body body)
  `(call-with-fixtures (lambda () ,@body) ,fixtures))


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

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

Input:
(with-html
  nil
  (progn))

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:
(define-simple-type-map nil (progn))

Issue: Macro call that should be transformed by DEFINE-SIMPLE-TYPE-MAP

Input: (define-simple-type-map nil (progn))

Output:
(defmacro define-simple-type-map (class type)
  `(defmethod type ((,class ,class))
     ',type))


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

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

Input:
(some->>
  nil
  nil)

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


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

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

Input: (typecase nil (progn))

Output: (defmacro TYPECASE ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(v-defmacro nil
    nil)

Issue: Macro call that should be transformed by V-DEFMACRO

Input:
(v-defmacro nil
    nil)

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:
(fn common-lisp:nil
  common-lisp:nil)

Problem: Macro call that should be transformed by FN

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

Output: (defmacro FN ...)


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

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

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

Output:
(defmacro dcase (keyform &body clauses)
  "DCASE is a combination of CASE 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 CASE,
   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 'case))


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

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

Input:
(fn nil
    :key
  nil)

Output: (defmacro FN ...)