Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(with-standard-input-syntax)

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

Input: (with-standard-input-syntax)

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:
(dynamic-progv nil
    :key
  nil)

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

Input:
(dynamic-progv nil
    :key
  nil)

Output: (defmacro DYNAMIC-PROGV ...)


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

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

Input: (minf nil (progn))

Output: (defmacro MINF ...)


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

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

Input:
(synchronized nil
  :key
  nil)

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

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

Input: (scase nil)

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


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

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

Input: (with-fixtures nil)

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


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

Issue: Macro call that should be transformed by BDD-TYPECASE

Input: (bdd-typecase 'lol-gen::some-name)

Output: (defmacro BDD-TYPECASE ...)


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

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

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

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


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

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

Input: (with-unique-names 'lol-gen::some-name)

Output: (defmacro WITH-UNIQUE-NAMES ...)


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

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

Input: (def-suite nil)

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

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


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

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

Input: (from nil)

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


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

Problem: Macro call that should be transformed by FOR-EFFECTS

Input:
(for-effects
  nil
  nil)

Output: (defmacro FOR-EFFECTS ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(set-bop nil nil)

Issue: Macro call that should be transformed by SET-BOP

Input: (set-bop nil nil)

Output: (defmacro SET-BOP ...)


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

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

Input:
(with-special-initargs* nil
  :key
  nil)

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


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

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

Input: (xor nil :key nil)

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

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

Input: (while nil)

Output: (defmacro WHILE ...)


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

Issue: Macro call that should be transformed by DOLIST

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

Output: (defmacro DOLIST ...)


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

Issue: Macro call that should be transformed by .>

Output:
(defmacro .> (cl:&rest items)
  "Left associative compose operator. Creates a new functions that will run the
functions left to right when applied. This is the same as the `pipe` macro without supplying
the value. The composition is thus the reverse order of `compose`.

`(.> f g h)` creates the function `(fn (x) (h (g (f x))))`."
  (alexandria:with-gensyms (x)
    `(fn (,x)
       (pipe ,x ,@items))))


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

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

Input: (cond-> nil)

Output: (defmacro COND-> ...)


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

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

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

Output:
(defmacro match2 (what &body clauses)
  "In match2/match2*, the last clause is not enclosed in a block.
Therefore, using `next' in the last clause results in jumping to the next innermost matching construct,
or results in a compilation error when this is the outermost matching construct."
  `(match2+ ,what t ,@clauses))


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

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

Input: (finishes)

Output:
(defmacro finishes (&body body)
  "Generates a pass if BODY executes to normal completion. In
other words if body does signal, return-from or throw this test
fails."
  `(unwind-protect-case () (progn ,@body)
     (:normal (add-result 'test-passed :test-expr ',body))
     (:abort (process-failure ',body "Test didn't finish"))))


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

Problem: Macro call that should be transformed by WITH-OPEN-FILES

Input:
(with-open-files nil
  (progn))

Output:
(defmacro with-open-files ((&rest args) &body body)
  "A simple macro to open one or more files providing the streams for the BODY. The ARGS is a list of `(stream filespec options*)` as supplied to WITH-OPEN-FILE."
  (case (length args)
    ((0)
     `(progn ,@body))
    ((1)
     `(with-open-file ,(first args) ,@body))
    (t `(with-open-file ,(first args)
          (with-open-files
              ,(rest args) ,@body)))))


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

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

Input:
(actypecase nil
  (progn))

Output:
(defmacro actypecase (keyform &body cases)
  "Like CTYPECASE, except binds the result of the keyform to IT (via LET) for
the scope of the cases. Unlike CTYPECASE, new values possible stored by the
STORE-VALUE restart are not received by the keyform/place, but by IT."
  `(anaphoric ctypecase ,keyform ,@cases))


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

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

Input:
(bind nil
  nil)

Output:
(defmacro bind ((&rest bindings) &body body)
  "Bind is a replacement for let*, destructuring-bind, multiple-value-bind and more.

An example is probably the best way to describe its syntax:

    \(bind \(\(a 2\)
           \(\(b &rest args &key \(c 2\) &allow-other-keys\) '\(:a :c 5 :d 10 :e 54\)\)
           \(\(:values d e\) \(truncate 4.5\)\)
           \(\(:structure xxx- slot1 slot2\) \(make-xxx\)\)
           \(\(:flet name \(arg1 arg2\)\) \(+ arg1 arg2\)\)\)
         \(list a b c d e args\)\)

Simple bindings are as in let*. Destructuring is done if the first item
in a binding is a list. Multiple value binding is done if the first item
in a binding is a list and the first item in the list is ':values'. Other
forms have their own syntax. For example, :structure first has the conc
name and then slot names whereas :flet has the function name and a list
of arguments and then the function body (in an implicit progn)."
  (let (declarations)
    (loop while (and (consp (car body)) (eq (caar body) 'declare)) do
          (push (first body) declarations)
          (setf body (rest body)))
    (if bindings
	(let ((*all-declarations* (bind-expand-declarations (nreverse declarations))))
	  (prog1
	      (bind-macro-helper bindings body)
	    (check-for-unused-variable-declarations *all-declarations*)))
        `(locally
             ,@declarations
           ,@body))))


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

Problem: Macro call that should be transformed by DEFINE-METHOD-COMBINATION

Input: (define-method-combination nil nil)

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


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

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

Input: (group-by nil)

Output:
(defmacro group-by (&rest expressions)
  `(apply #'make-clause :group-by ',expressions))


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

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

Input:
(awhen nil
  (progn))

Output: (defmacro AWHEN ...)


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

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

Input: (dictq)

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


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

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

Input:
(define-alias nil
    nil)

Output: (defmacro DEFINE-ALIAS ...)


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

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

Input: (define-hook-generic nil :key nil)

Output:
(defmacro define-hook-generic (name gf-lambda-list &rest options)
  "utility to help with gf's with method combination by remembering the combination type

by default the combination type becomes the default qualifier for any newly defined hooks
this can be overriden by not using this and using defgeneric or supplying
the option :default-qualifier.

supplying `:hook-point t` will create a method qualified with the default-qualifier
so that the generic acts like an extensible hook point and will not signal
no-applicable-method error when no hooks have been defined.

See defhook"
  (let* ((combination-option (find :method-combination options :key #'car :test #'eql))
         (combination-type
          (cond ((null combination-option) 'progn)
                ((null (cadr combination-option)) :unqualified)
                ((eql 'standard (cadr combination-option)) :unqualified)
                (t (cadr combination-option))))
         (default-qualifier
          (let ((d (cadr (find :default-qualifier options :key #'car :test #'eql))))
            (if (null d) combination-type d)))
         (hook-point (find :hook-point options :key #'car)))

    (intern-hook-generic name combination-type default-qualifier)
    `(progn (intern-hook-generic ',name ',combination-type ',default-qualifier)
            (defgeneric ,name ,gf-lambda-list
              ,@ (remove-if (lambda (s) (or (eql s :method-combination)
                                            (eql s :default-qualifier)
                                            (eql s :hook-point)))
                            options :key #'car)
                 (:method-combination
                   ,(if (eql :unqualified combination-type) 'standard combination-type)))

            ,(when hook-point
               (remove :unqualified `(defmethod ,name ,default-qualifier ,gf-lambda-list)
                       :end 3)))))


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

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

Input:
(defvariant nil
  nil)

Output: (defmacro DEFVARIANT ...)


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

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

Input: (xml nil :key nil)

Output:
(defmacro xml (&rest tags)
  `(with-doctype :xml
     (loop for tag in ',tags
           append (tag->string tag))))


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

Problem: Macro call that should be transformed by EMIT

Input: (emit nil)

Output: (defmacro EMIT ...)


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

Issue: Macro call that should be transformed by SQL

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

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

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

but

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

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


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

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

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

Output: (defmacro WHEN-BIND ...)


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

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

Input: (is-true nil nil)

Output:
(defmacro is-true (condition &rest reason-args)
  "Like IS this check generates a pass if CONDITION returns true
  and a failure if CONDITION returns false. Unlike IS this check
  does not inspect CONDITION to determine how to report the
  failure."
  `(if ,condition
       (add-result 'test-passed :test-expr ',condition)
       (process-failure ',condition
                        ,@(or reason-args
                              `("~S did not return a true value" ',condition)))))


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

Issue: Macro call that should be transformed by OK

Input: (ok nil nil)

Output:
(defmacro ok (test &optional desc)
  (with-gensyms (duration result)
    (once-only (test desc)
      `(with-catching-errors (:expected T :description ,desc)
         (with-duration ((,duration ,result) ,test)
           (test ,result t ,desc
                 :duration ,duration
                 :test-fn (lambda (x y)
                            (eq (not (null x)) y))
                 :got-form ,test))))))


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

Issue: Macro call that should be transformed by NREVERSEF

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

Output: (defmacro NREVERSEF ...)


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

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

Input:
(as->* nil
  :key
  nil)

Output: (defmacro AS->* ...)


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 ~>> (needle &rest holes)
  "Like `~>' but, by default, thread NEEDLE as the last argument
instead of the first."
  (thread-aux '~>> needle holes
              (lambda (needle hole)
                (append hole (list needle)))))


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

Problem: Macro call that should be transformed by KNOWN?

Input: (known? nil)

Output: (defmacro KNOWN? ...)


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

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

Input: (defsyntax nil)

Output:
(defmacro defsyntax (name &body options)
  `(progn
     (setf (get ',name :options) ',options)
     (defvar ,name (defreadtable ,name ,@options))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(reduced-typecase nil nil)

Issue: Macro call that should be transformed by REDUCED-TYPECASE

Input: (reduced-typecase nil nil)

Output: (defmacro REDUCED-TYPECASE ...)


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

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

Input:
(select-dao nil
  :key
  nil)

Output:
(defmacro select-dao (class &body clauses)
  "Build custom queries with SxQL.

Example:

  (select-dao 'tweet
    (where (:like :status \"%Japan%\")))

You can use \"includes\" to eagerly load another table and prevent the \"N+1 query\" performance problem:

  (select-dao 'tweet
    (includes 'user)
    (where (:like :status \"%Japan%\")))

You can use \"joins\" to add JOIN clauses for filtering by related table columns.
Note: \"joins\" does NOT automatically load foreign objects. Use \"includes\" if you need the ghost slots populated:

  ;; Filter by related table - ghost slot NOT populated
  (select-dao 'blog
    (joins 'user)
    (where (:= :user.status \"active\")))

  ;; Filter AND load foreign objects
  (select-dao 'blog
    (joins 'user)
    (includes 'user)
    (where (:= :user.status \"active\")))

See the SxQL documentation for the available clauses and operators."
  (with-gensyms (sql clause results include-classes foreign-class)
    (once-only (class)
      `(#+sb-package-locks locally #+sb-package-locks (declare (sb-ext:disable-package-locks sxql:where))
        #-sb-package-locks cl-package-locks:with-packages-unlocked #-sb-package-locks (sxql)
        (progn
          (setf ,class (ensure-class ,class))
          (let* ((sxql:*sql-symbol-conversion* #'unlispify)
                 (,sql
                   (sxql:select :*
                                (sxql:from (sxql:make-sql-symbol (table-name ,class)))))
                 (,include-classes '()))
            (macrolet ((where (expression)
                         `(sxql:make-clause :where ,(expand-op expression ',class))))
              ;; ignore compiler-note when includes is not used
              #+sbcl (declare (sb-ext:muffle-conditions sb-ext:code-deletion-note))
              (flet ((includes (&rest classes)
                       (appendf ,include-classes (mapcar #'ensure-class classes))
                       nil)
                     (joins (foreign-class &key (type :inner))
                       (let ((foreign-class (ensure-class foreign-class)))
                         (add-child ,sql
                                   (ecase type
                                     (:inner (sxql:inner-join
                                               (sxql:make-sql-symbol (table-name foreign-class))
                                               :on (make-join-condition ,class foreign-class)))
                                     (:left (sxql:left-join
                                              (sxql:make-sql-symbol (table-name foreign-class))
                                              :on (make-join-condition ,class foreign-class)))))
                         nil)))
                (dolist (,clause (list ,@clauses))
                  (when ,clause
                    (add-child ,sql ,clause)))
                (let ((,results (select-by-sql ,class ,sql)))
                  (unless *want-cursor*
                    (dolist (,foreign-class (remove-duplicates ,include-classes))
                      (include-foreign-objects ,foreign-class ,results)))
                  (values ,results ,sql))))))))))


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

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

Input: (lazy-seq 'lol-gen::some-name)

Output:
(defmacro lazy-seq (head &optional tail)
  "Creates a `LAZY-SEQ' where HEAD is the first element in the
   sequence and TAIL is a form which computes the remainder of the
   sequence. TAIL is wrapped in a function that stores the result of
   evaluating FORM, the first time it is invoked, and returns the
   stored result in future invocations."

  `(make-lazy-seq :head ,head :tail (thunk ,tail)))


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

Problem: Macro call that should be transformed by FTYPE

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

Output: (defmacro FTYPE ...)


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

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

Input:
(with-object nil
  :key
  nil)

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


Instruction:
Write a Common Lisp macro to handle this code pattern:
(with-decoder-simple-list-semantics)

Problem: Macro call that should be transformed by WITH-DECODER-SIMPLE-LIST-SEMANTICS

Input: (with-decoder-simple-list-semantics)

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


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

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

Input: (formatter nil)

Output: (defmacro FORMATTER ...)


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

Pattern to recognize: Macro call that should be transformed by DEFINE-FINAL-CLASS

Input: (define-final-class nil :key nil)

Output: (defmacro DEFINE-FINAL-CLASS ...)


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

Issue: Macro call that should be transformed by F_

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

Output: (defmacro F_ ...)


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

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

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

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

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

Input: (dynamic-let nil)

Output: (defmacro DYNAMIC-LET ...)


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

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

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

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


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

Problem: Macro call that should be transformed by ITER

Input:
(iter
  nil
  nil)

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


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

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

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

Output: (defmacro WHEN-FAILING ...)


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

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

Input:
(jwhen nil
  :key
  nil)

Output:
(defmacro jwhen (test &body body)
  "JSON-aware version of `cl:when'.
If TEST is `jtruep' evaluate BODY."
  `(jif ,test
       (progn ,@body)))


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

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

Input:
(with-custom-decoder-level nil
  nil)

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


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

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

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

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


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

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

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

Output: (defmacro EMIT ...)


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

Issue: Macro call that should be transformed by DEFMETHOD*

Input: (defmethod* nil (progn))

Output: (defmacro DEFMETHOD* ...)


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

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

Input:
(c?? nil
  nil)

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


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

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

Input:
(with-rules nil
  :key
  nil)

Output: (defmacro WITH-RULES ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(coalton-codegen)

Issue: Macro call that should be transformed by COALTON-CODEGEN

Input: (coalton-codegen)

Output: (defmacro COALTON-CODEGEN ...)


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

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

Input: (one-value nil)

Output: (defmacro ONE-VALUE ...)


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

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

Input: (defmessage nil nil)

Output: (defmacro DEFMESSAGE ...)


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

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

Input:
(lambda-coro
  nil
  nil)

Output: (defmacro LAMBDA-CORO ...)


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

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

Input: (aif nil (progn))

Output:
(defmacro aif (test then &optional else)
  "Like IF, except binds the result of the test to IT (via LET) for
the scope of the then and else expressions."
  `(anaphoric if ,test ,then ,else))


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

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

Input: (next-in nil :key nil)

Output: (defmacro NEXT-IN ...)


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

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

Input: (is-every nil)

Output:
(defmacro is-every (predicate &body clauses)
  "The input is either a list of lists, or a list of pairs. Generates (is (,predicate ,expr ,value))
   for each pair of elements or (is (,predicate ,expr ,value) ,@reason) for each list."
  `(progn
     ,@(if (every #'consp clauses)
           (loop for (expected actual . reason) in clauses
                 collect `(is (,predicate ,expected ,actual) ,@reason))
           (progn
             (assert (evenp (list-length clauses)))
             (loop for (expr value) on clauses by #'cddr
                   collect `(is (,predicate ,expr ,value)))))))


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

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

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

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:
Create a Common Lisp macro for the following transformation. Before code:
(ps-package-prefix 'lol-gen::some-name)

What needs to change: Macro call that should be transformed by PS-PACKAGE-PREFIX

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

Output: (defmacro PS-PACKAGE-PREFIX ...)


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

Issue: Macro call that should be transformed by LEFT

Input: (left nil (progn))

Output:
(defmacro left (parser &rest parsers)
  "Combination of parsers yielding the result of the leftmost one."
  `(<* ,parser ,@parsers))


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

Problem: Macro call that should be transformed by LAMBDA

Input: (lambda ())

Output: (defmacro LAMBDA ...)


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

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

Input:
(count-failures
  nil
  (progn))

Output: (defmacro COUNT-FAILURES ...)


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

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

Input: (sor nil nil)

Output:
(defmacro sor (first &rest rest)
  "Like OR, except binds the first argument to IT (via SYMBOL-MACROLET) for
the scope of the rest of the arguments. IT can be set with SETF."
  `(symbolic or ,first ,@rest))


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

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

Input: (untrace nil nil)

Output: (defmacro UNTRACE ...)


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

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

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

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


Instruction:
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 ~>> (needle &rest holes)
  "Like `~>' but, by default, thread NEEDLE as the last argument
instead of the first."
  (thread-aux '~>> needle holes
              (lambda (needle hole)
                (append hole (list needle)))))


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

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

Input:
(dynamic-extent common-lisp:nil
  (common-lisp:progn))

Output: (defmacro DYNAMIC-EXTENT ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
;; Macro with double-evaluation bug
(defmacro square (x)
  `(* ,x ,x))
;; (square (incf y)) evaluates (incf y) TWICE

;; Manual fix requires gensym + let boilerplate every time
(defmacro square (x)
  (let ((g (gensym)))
    `(let ((,g ,x))
       (* ,g ,g))))

What needs to change: Macro arguments evaluated multiple times (double evaluation) — need automatic once-only that also provides both original form and evaluated value

Input:
;; Macro with double-evaluation bug
(defmacro square (x)
  `(* ,x ,x))
;; (square (incf y)) evaluates (incf y) TWICE

;; Manual fix requires gensym + let boilerplate every time
(defmacro square (x)
  (let ((g (gensym)))
    `(let ((,g ,x))
       (* ,g ,g))))

Output:
(defun o!-symbol-p (s)
  (and (symbolp s)
       (> (length (symbol-name s)) 2)
       (string= (symbol-name s)
                "O!"
                :start1 0
                :end1 2)))

(defun o!-symbol-to-g!-symbol (s)
  (symb "G!"
        (subseq (symbol-name s) 2)))

(defmacro defmacro! (name args &rest body)
  (let* ((os (remove-if-not #'o!-symbol-p (flatten args)))
         (gs (mapcar #'o!-symbol-to-g!-symbol os)))
    (multiple-value-bind (body declarations docstring)
        (parse-body body :documentation t)
      `(defmacro/g! ,name ,args
         ,@(when docstring
            (list docstring))
         ,@declarations
         `(let ,(mapcar #'list (list ,@gs) (list ,@os))
            ,(progn ,@body))))))


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

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

Input: (define-template nil nil)

Output: (defmacro DEFINE-TEMPLATE ...)


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

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

Input:
(match nil
  nil)

Output:
(defmacro match (arg &body clauses)
  "Matches ARG with CLAUSES. CLAUSES is a list of the form of (PATTERN
. BODY) where PATTERN is a pattern specifier and BODY is an implicit
progn. If ARG matches some PATTERN, `match` then evaluates
the corresponding BODY and returns the evaluated value.  If no pattern matches,
then returns NIL.

Evaluating a form (FAIL) in the clause body causes the latest pattern
matching to fail. For example,

    (match 1
      (x (if (eql x 1)
             (fail)
             x))
      (_ 'ok))

returns OK, because the form (FAIL) in the first clause is
evaluated.

If BODY starts with the symbols WHEN or UNLESS, then the next form
will be used to introduce (FAIL). That is,

    (match list ((list x) when (oddp x) x))
    (match list ((list x) unless (evenp x) x))

will be translated to

    (match list ((list x) (if (oddp x) x (fail))))
    (match list ((list x) (if (evenp x) (fail) x)))

Examples:

    (match 1 (1 1))
    => 1
    (match 1 (2 2))
    => 2
    (match 1 (x x))
    => 1
    (match (list 1 2 3)
      (list x y z) (+ x y z))
    => 6"
  (compile-match-1 arg clauses nil))


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

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

Input:
(defgenerator nil
    :key
  nil)

Output:
(defmacro defgenerator (name arguments &body body)
  (multiple-value-bind (remaining-forms declarations doc-string)
      (alexandria:parse-body body :documentation t)
    `(defun ,name ,arguments
       ,doc-string
       ,@declarations
       (with-yield
	 ,@remaining-forms))))


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

Problem: Macro call that should be transformed by C_?

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


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

What needs to change: Macro call that should be transformed by DEFINE-SCRIPT-SYMBOL-MACRO

Input:
(define-script-symbol-macro nil
  :key
  nil)

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


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 => (fn1 fn2 &rest fns)
  "Function composition of FN1, FN2 and all the other FNS."
  (let ((arg (gensym "ARG")))
    `(lambda (,arg)
       ,(if fns
            `(,fn1 (call (=> ,fn2 ,@fns) ,arg))
            `(,fn1 (,fn2 ,arg))))))


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

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

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

Output: (defmacro WITH-UNIQUE-NAMES ...)


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

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

Input: (make-name-transformer nil nil)

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

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

Use the slot name directly:

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


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

Issue: Macro call that should be transformed by COMPILER-MACRO-LAMBDA

Input:
(compiler-macro-lambda nil
  :key
  nil)

Output:
(defmacro compiler-macro-lambda (lambda-list &body body)
  (introspect-environment:parse-compiler-macro (gensym "COMPILER-MACRO-LAMBDA")
                                               lambda-list
                                               body))


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

Problem: Macro call that should be transformed by DOC

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

Output: (defmacro DOC ...)


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

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

Input: (left-join 'lol-gen::some-name)

Output:
(defmacro left-join (table &key on using)
  `(join ,table :kind :left :on ,on :using ,using))


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

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

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

Output: (defmacro SUM-OF ...)


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

Problem: Macro call that should be transformed by FILTERF

Input: (filterf nil (progn))

Output: (defmacro FILTERF ...)


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

Issue: Macro call that should be transformed by FROM

Input: (from nil :key nil)

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


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

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

Input:
(ensure-list nil
  :key
  nil)

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


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

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

Input: (returning nil nil)

Output:
(defmacro returning (&rest expressions)
  `(apply #'make-clause :returning
          (list ,@(mapcar (lambda (expr)
                            (if (and (listp expr)
                                     (keywordp (car expr)))
                              (expand-op expr)
                              `,expr))
                          expressions))))


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

Write a macro that addresses: Macro call that should be transformed by REMOVE-FROM-PLISTF

Input: (remove-from-plistf nil nil)

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


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

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

Input:
(finishes
  nil
  :key
  nil)

Output:
(defmacro finishes (&body body)
  "Generates a pass if BODY executes to normal completion. In
other words if body does signal, return-from or throw this test
fails."
  `(unwind-protect-case () (progn ,@body)
     (:normal (add-result 'test-passed :test-expr ',body))
     (:abort (process-failure ',body "Test didn't finish"))))


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

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

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

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

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

Input: (^value)

Output: (defmacro ^VALUE ...)


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

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

Input: (without-recursion nil)

Output:
(defmacro without-recursion ((&key) &body body)
  "If BODY calls itself, at any depth, signal a (continuable) error of
type `recursion-forbidden'."
  (with-unique-names (recursion-id)
    `(progn
       (when (member ',recursion-id *recursions*)
         (cerror "Recurse anyway."
                 'recursion-forbidden
                 :form ',body))
       (let ((*recursions* (cons ',recursion-id *recursions*)))
         (declare (dynamic-extent *recursions*))
         ,@body))))


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

Problem: Macro call that should be transformed by LAMBDA*

Input:
(lambda* nil
  (progn))

Output: (defmacro LAMBDA* ...)


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

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

Input: (function-call nil (progn))

Output: (defmacro FUNCTION-CALL ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(compile-$flavor-$methods nil (progn))

Write a macro that addresses: Macro call that should be transformed by COMPILE-$FLAVOR-$METHODS

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

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


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

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

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

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:
(with-collectors nil
  (progn))

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

Input:
(with-collectors nil
  (progn))

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

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


Instruction:
Define a macro that eliminates this repetitive pattern:
(c?dbg)

Issue: Macro call that should be transformed by C?DBG

Input: (c?dbg)

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


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

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

Input: (nix nil (progn))

Output:
(defmacro nix (&rest places)
  "Set PLACES to nil and return the old value(s) of PLACES.

If there is more than one PLACE, return their old values as multiple values.

This may be more efficient than (shiftf place nil), because it only
sets PLACE when it is not already null."
  `(values
    ,@(loop for place in places
            collect `(nix-1 ,place))))


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

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

Input: (prog1 nil (progn))

Output: (defmacro PROG1 ...)


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

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

Input: (export-constructors)

Output: (defmacro EXPORT-CONSTRUCTORS ...)


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

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

Input: (fn common-lisp:nil)

Output: (defmacro FN ...)


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

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

Input: (define-switch)

Output:
(defmacro define-switch (&key name macro-character)
  "Define a c-mera reader switch (in repl)
   allowing preprocessing and mixed case"
  `(defun ,name (&key (debug nil))
     (cond ((eql *c-mera-reader* 'cl)
	    (setf *c-mera-reader* 'cm)
	    ;; TODO when debug
	    ,@macro-character
	    (setf (readtable-case *readtable*) :invert))
	   ((eql *c-mera-reader* 'cm)
	    (setf *c-mera-reader* 'cl)
	    (setf *readtable* *readtable-backup*))
	   (t (error "Unknown c-mera reader status: ~a" *c-mera-reader*)))))