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

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

Input:
(with-yield
  nil)

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


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

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

Input: (query nil)

Output:
(defmacro query (query &rest args/format)
  "Execute the given query, which can be either a string or an S-SQL form (list
starting with a keyword). If the query contains placeholders ($1, $2, etc)
their values can be given as extra arguments. If one of these arguments is a
keyword occurring in the table below, it will not be used as a query
argument, but will determine the format in which the results are returned
instead. Any of the following formats can be used, with the default being :rows:

| :none	             | Ignore the result values.                                 |
| :lists, :rows      | Return a list of lists, each list containing the values   |
|                    | for a row.                                                |
| :list, :row        | Return a single row as a list.                            |
| :alists	           | Return a list of alists which map column names to values, |
|                    | with the names represented as keywords.                   |
| :alist	           | Return a single row as an alist.                          |
| :array-hash        | Return an array of hashtables which map column names to   |
|                    | hash table keys. NOTE: It will return an empty array      |
|                    | if there is no result.                                    |
| :vectors           | Returns a vector of vectors where each internal vector is |
|                    | a returned row from the query. The field names are not    |
|                    | included. NOTE: It will return an empty vector instead of |
|                    | NIL if there is no result.                                |
| :str-alists        | Like :alists, but use the original column names.          |
| :str-alist	       | Return a single row as an alist, with strings for names.  |
| :plists	           | Return a list of plists which map column names to values, |
|                    | with the names represented as keywords.                   |
| :plist	           | Return a single row as a plist.                           |
| :column	           | Return a single column as a list.                         |
| :single	           | Return a single value.                                    |
| :single!	         | Like :single, but raise an error when the number of       |
|                    | selected rows is not equal to 1.                          |
| (:dao type)	       | Return a list of DAOs of the given type. The names of the |
|                    | fields returned by the query must match slots in the DAO  |
|                    | class the same way as with query-dao.                     |
| (:dao type :single)| Return a single DAO of the given type.                    |
| :json-strs         | Return a list of strings where each row is a json object  |
|                    | expressed as a string                                     |
| :json-str          | Return a single string where the row returned is a json   |
|                    | object expressed as a string.                             |
| :json-array-str    | Return a string containing a json array, each element in  |
|                    | the array is a selected row expressed as a json object.   |
|                    | NOTE: If there is no result, it will return a string with |
|                    | an empty json array.                                      |

If the database returns information about the amount rows that were affected,
such as with updating or deleting queries, this is returned as a second value."
  (let* ((format :rows)
         (args (loop :for arg :in args/format
                     :if (or (dao-spec-for-format arg)
                             (assoc arg *result-styles*)) :do (setf format arg)
                     :else :collect arg)))
    (destructuring-bind (reader result-form) (reader-for-format format)
      (let ((base (if args
		      (let ((vars (loop :for x :in args :collect (gensym))))
			`(let ,(loop :for v :in vars :for a :in args :collect `(,v ,a))
			   (prepare-query *database* "" ,(real-query query) (list ,@vars))
			   (exec-prepared *database* "" (list ,@vars) ,reader)))
		      `(exec-query *database* ,(real-query query) ,reader))))
        `(,result-form ,base)))))


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

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

Input:
(product-of nil
  :key
  nil)

Output: (defmacro PRODUCT-OF ...)


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

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

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

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


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

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

Input: (with-savepoint nil)

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

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


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

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

Input: (some-> nil)

Output: (defmacro SOME-> ...)


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

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

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

Output: (defmacro ->> ...)


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

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

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

Output: (defmacro DEFPROTO ...)


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

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

Input:
(with-foreign-strings nil
  :key
  nil)

Output:
(defmacro with-foreign-strings (bindings &body body)
  "See WITH-FOREIGN-STRING's documentation."
  (if bindings
      `(with-foreign-string ,(first bindings)
         (with-foreign-strings ,(rest bindings)
           ,@body))
      `(progn ,@body)))


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

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

Input:
(defclause nil
    :key
  nil)

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


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

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

Input: (rotatef nil (progn))

Output: (defmacro ROTATEF ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(with-decoder-simple-clos-semantics)

Write a macro that addresses: Macro call that should be transformed by WITH-DECODER-SIMPLE-CLOS-SEMANTICS

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

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


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

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

Input: (in-suite nil)

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

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

Input: (call-method nil (progn))

Output: (defmacro CALL-METHOD ...)


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

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

Input: (ignore-errors nil (progn))

Output: (defmacro IGNORE-ERRORS ...)


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

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

Input:
(dynamic-let nil
  nil)

Output: (defmacro DYNAMIC-LET ...)


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

Issue: Macro call that should be transformed by DELETEF

Input: (deletef nil :key nil)

Output: (defmacro DELETEF ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(dynamic-wind)

Issue: Macro call that should be transformed by DYNAMIC-WIND

Input: (dynamic-wind)

Output: (defmacro DYNAMIC-WIND ...)


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

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

Input:
(defmethod* nil
    nil)

Output: (defmacro DEFMETHOD* ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(and-let* nil
  nil)

Issue: Macro call that should be transformed by AND-LET*

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

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

Input: (inext-or-error nil)

Output: (defmacro INEXT-OR-ERROR ...)


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

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

Input: (collect nil nil)

Output: (defmacro COLLECT ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(validate-superclass*)

Issue: Macro call that should be transformed by VALIDATE-SUPERCLASS*

Input: (validate-superclass*)

Output: (defmacro VALIDATE-SUPERCLASS* ...)


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

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

Input: (group-by nil :key nil)

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


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

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

Input: (for-effects)

Output: (defmacro FOR-EFFECTS ...)


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

Problem: Macro call that should be transformed by WITH-ITER-VALUE

Input: (with-iter-value 'lol-gen::some-name)

Output:
(defmacro with-iter-value ((pattern iter) &body body)
  "Bind the current element of a sequence, pointed to by a static iterator, to a variable.

   This macro may only be used within the body of a WITH-ITERATORS
   macro.

   The current value of the sequence, with iterator ITER, is bound to
   the variable(s) specified by PATTERN, with the bindings visible to
   FORMS.

   If the iterator is already at the end of the sequence a non-local
   jump, to the end of the enclosing WITH-ITERATORS form, is
   performed.

   After binding, the iterator is advanced to the next element of the
   sequence.

   PATTERN:

     A binding pattern specifying the variable(s) to which the current
     element of the sequence is bound.

     This may either be a symbol, naming a variable, or a list which
     is interpreted as a pattern to `destructuring-bind`.

   ITER:

     Symbol identifying the iterator, as established by the
     WITH-ITERATORS form.

     This must name an iterator introduced in a parent WITH-ITERATORS
     form.

   BODY:

     The body of the WITH-ITER-VALUE form:

       (DECLARATION* FORM*)

     The body consists of a list of forms evaluated in an implicit
     PROGN, with the value of the last form returned from the
     WITH-ITER-VALUE form. The binding(s) introduced by PATTERN are
     visible to forms.

     The forms may be preceded by declaration expressions, which may
     apply to the variables introduced in PATTERN.

     NOTE: If there are no more elements in the sequence, the forms
     are not evaluated and a non-local jump to the end of the
     enclosing WITH-ITERATORS form is performed."

  `(with-iter-values ((,pattern ,iter)) ,@body))


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

Problem: Macro call that should be transformed by SEND

Input: (send nil :key nil)

Output: (defmacro SEND ...)


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

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

Input: (try-as common-lisp:nil (common-lisp:progn))

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:
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-> (init &body exps) (arrow-macro init exps nil t))


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

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

Input: (dispatch-case nil)

Output:
(defmacro dispatch-case ((&rest exprs-and-types) &body clauses)
  "Dispatch on the types of multiple expressions, exhaustively.

Say you are working on a project where you need to handle timestamps
represented both as universal times, and as instances of
`local-time:timestamp'. You start by defining the appropriate types:

    (defpackage :dispatch-case-example
      (:use :cl :alexandria :serapeum :local-time)
      (:shadow :time))
    \(in-package :dispatch-case-example)

    (deftype universal-time ()
      '(integer 0 *))

    (deftype time ()
      '(or universal-time timestamp))

Now you want to write a `time=' function that works on universal
times, timestamps, and any combination thereof.

You can do this using `etypecase-of':

    (defun time= (t1 t2)
      (etypecase-of time t1
        (universal-time
         (etypecase-of time t2
           (universal-time
            (= t1 t2))
           (timestamp
            (= t1 (timestamp-to-universal t2)))))
        (timestamp
         (etypecase-of time t2
           (universal-time
            (time= t2 t1))
           (timestamp
            (timestamp= t1 t2))))))

This has the advantage of efficiency and exhaustiveness checking, but
the serious disadvantage of being hard to read: to understand what
each branch matches, you have to backtrack to the enclosing branch.
This is bad enough when the nesting is only two layers deep.

Alternately, you could do it with `defgeneric':

    (defgeneric time= (t1 t2)
      (:method ((t1 integer) (t2 integer))
        (= t1 t2))
      (:method ((t1 timestamp) (t2 timestamp))
        (timestamp= t1 t2))
      (:method ((t1 integer) (t2 timestamp))
        (= t1 (timestamp-to-universal t2)))
      (:method ((t1 timestamp) (t2 integer))
        (time= t2 t1)))

This is easy to read, but it has three potential disadvantages. \(1)
There is no exhaustiveness checking. If, at some point in the future,
you want to add another representation of time to your project, the
compiler will not warn you if you forget to update `time='. \(This is
bad enough with only two objects to dispatch on, but with three or
more it gets rapidly easier to miss a case.) \(2) You cannot use the
`universal-time' type you just defined; it is a type, not a class, so
you cannot specialize methods on it. \(3) You are paying a run-time
price for extensibility -- the inherent overhead of a generic function
-- when extensibility is not what you want.

Using `dispatch-case' instead gives you the readability of
`defgeneric' with the efficiency and safety of `etypecase-of'.

    (defun time= (t1 t2)
      (dispatch-case ((t1 time)
                      (t2 time))
        ((universal-time universal-time)
         (= t1 t2))
        ((timestamp timestamp)
         (timestamp= t1 t2))
        ((universal-time timestamp)
         (= t1 (timestamp-to-universal t2)))
        ((timestamp universal-time)
         (time= t2 t1))))

The syntax of `dispatch-case' is much closer to `defgeneric' than it
is to `etypecase'. The order in which clauses are defined does not
matter, and you can define fallthrough clauses in the same way you
would define fallthrough methods in `defgeneric'.

Suppose you wanted to write a `time=' function like the one above, but
always convert times to timestamps before comparing them. You could
write that using `dispatch-case' like so:

    (defun time= (x y)
      (dispatch-case ((x time)
                      (y time))
        ((* universal-time)
         (time= x (universal-to-timestamp y)))
        ((universal-time *)
         (time= (universal-to-timestamp x) y))
        ((timestamp timestamp)
         (timestamp= x y))))

\(In the list of types, you can use as asterisk as a shorthand for the
type of the corresponding argument to `dispatch-case'; in that above,
`time'.)

Note that this requires only three clauses, where writing it out using
nested `etypecase-of' forms would require four clauses. This is a
small gain; but with more subtypes to dispatch on, or more objects,
such fallthrough clauses become more useful."
  (let ((*gensym-counter* 0))
    `(dispatch-case-let
         ,(loop for (expr type) in exprs-and-types
                for i from 0
                for var = (string-gensym 'arg)
                collect `((,var ,type) ,expr))
       ,@clauses)))


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

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

Input: (sort-values nil)

Output:
(defmacro sort-values (pred &rest values)
  "Sort VALUES with PRED and return as multiple values.

Equivalent to

    (values-list (sort (list VALUES...) pred))

But with less consing, and potentially faster."
  ;; Remember to evaluate `pred' no matter what.
  (with-gensyms (gpred)
    `(let ((,gpred (ensure-function ,pred)))
       (declare (ignorable ,gpred)
                (function ,gpred)
                (optimize (safety 1) (debug 0) (compilation-speed 0)))
       ,(match values
          ((list) `(values))
          ((list x) `(values ,x))
          ;; The strategy here is to use a sorting network if the
          ;; inputs are few, and a stack-allocated vector if the
          ;; inputs are many.
          (otherwise
           (if (<= (length values) 8)
               `(sort-values/network ,gpred ,@values)
               `(sort-values/temp-vector ,gpred ,@values)))))))


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

Issue: Macro call that should be transformed by CACHING-TYPES

Input:
(caching-types
  'lol-gen::some-name)

Output: (defmacro CACHING-TYPES ...)


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

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

Input: (defgeneric* nil (progn))

Output: (defmacro DEFGENERIC* ...)


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

What needs to change: Macro call that should be transformed by FINALIZE-DISPATCH-METHOD

Input: (finalize-dispatch-method nil :key nil)

Output:
(defmacro finalize-dispatch-method (generic-function &rest args)
  "add a body to the method which dispatched the hooks for the given specialized-lambda-list
useful if you wanted to use call-next-method

For the definition to be effective, it must be defined after every specific hook for the same method hence finalize.

See defhook"
  (%destructure-defhook-args args
    (with-effective-qualifier generic-function qualifier
      (destructure-specialized-lambda-list descriptive-lambda-list vanilla-lambda-list type-list specialized-lambda-list
        `(%lay-method-base-for-dispatch ,generic-function ,qualifier ,type-list ,descriptive-lambda-list
           ,@body)))))


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

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

Input: (global)

Output: (defmacro GLOBAL ...)


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

Problem: Macro call that should be transformed by DEFRULE

Input:
(defrule nil
  (progn))

Output: (defmacro DEFRULE ...)


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

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

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

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

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

For example:

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

Is equivalent to:

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

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

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

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

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


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

Problem: Macro call that should be transformed by INEXT-OR-ERROR

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

Output: (defmacro INEXT-OR-ERROR ...)


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

Pattern to recognize: Macro call that should be transformed by C-IN-LAZY

Input:
(c-in-lazy
  'lol-gen::some-name)

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


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

Problem: Macro call that should be transformed by MAKE-NAME-TRANSFORMER

Input: (make-name-transformer)

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:
You are a Common Lisp macro expert. Given this code pattern:
(define-test+run-interactively nil)

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

Input: (define-test+run-interactively nil)

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


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

Problem: Macro call that should be transformed by DOITERS

Input: (doiters nil)

Output:
(defmacro doiters (name/iters &body body)
  "Iterate over one or more sequences with the iterator of each sequence bound to a variable.

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

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

    2. ((&REST ITERS) &BODY BODY)

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

   ITERS is a list of bindings with each element of the form (IT-VAR
   SEQUENCE . ARGS). IT-VAR is the variable to which the iterator for
   SEQUENCE is bound. ARGS are the remaining arguments passed to the
   ITERATOR function (if any).

   BODY is a list of forms which are evaluated at each iteration. The
   bindings to the iterator variables (IT-VAR's) are visible. At the
   end of each iteration, each iterator is advanced by one position
   with ADVANCE. The loop is terminated, with the DOITERS form
   returning NIL, when at least one of the iterators reaches the end
   of its sequence (ENDP returns true). The loop can be terminated
   early with a RETURN-FROM to the block named NAME."

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

    (flet ((make-it-binding (it)
	     (destructuring-bind (var &rest args) it
	       `(,var (iterator ,@args))))

	   (make-end-test (it)
	     `(endp ,(car it)))

	   (make-advance (it)
	     `(advance ,(car it))))

      `(let ,(mapcar #'make-it-binding iters)
         (loop ,@(when name `(named ,name))
            until (or ,@(mapcar #'make-end-test iters))
	    do
	      (progn ,@body)
	      ,@(mapcar #'make-advance iters))))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(c-in-lazy
  nil
  nil)

Issue: Macro call that should be transformed by C-IN-LAZY

Input:
(c-in-lazy
  nil
  nil)

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


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

Problem: Macro call that should be transformed by WHEN

Input: (when nil :key nil)

Output: (defmacro WHEN ...)


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


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

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

Input:
(with-access nil
    :key
  nil)

Output:
(defmacro with-access ((&rest keys) val-form &body body)
  "Similar to with-accessors except using the access functions"
  (let* ((gval (gensym "val"))
     (forms
      (iter (for k in keys)
        (for (k-to k-from) = (if (listp k) k (list k k)))
        (collect `(,k-to (access ,gval ',k-from))))))
    `(let ((,gval ,val-form))
       (declare (ignorable ,gval))
       (symbol-macrolet (,@forms)
     ,@body
     ))))


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

Problem: Macro call that should be transformed by NECESSARILY?

Input:
(necessarily?
  nil
  nil)

Output: (defmacro NECESSARILY? ...)


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

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

Input:
(for nil
  :key
  nil)

Output:
(defmacro for (&environment env bindings &body body)
  (let ((*environment* env))
    (multiple-value-bind (bind-init bind-forms bind-exit bind-post) (convert-bindings bindings)
      (multiple-value-bind (clause-init body-forms clause-exit) (convert-clauses body)
        `(with-interleaving
           ,@bind-init
           ,@clause-init
           (with-for-block ()
             (with-for-tagbody
                 (progn ,@bind-forms
                        ,@body-forms
                        ,@bind-post)
               (return-for
                ,@clause-exit
                ,@bind-exit))))))))


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

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

Input:
(dynamic-let nil
  (progn))

Output: (defmacro DYNAMIC-LET ...)


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

Issue: Macro call that should be transformed by FAILURE?

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

Output:
(defmacro failure? (x)
  "Did parsing fail?"
  `(eq :fail ,x))


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

Problem: Macro call that should be transformed by DEFINE-GENERIC*

Input:
(define-generic* nil
    nil)

Output: (defmacro DEFINE-GENERIC* ...)


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

Problem: Macro call that should be transformed by FM-OTHER?

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

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


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

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

Input:
(print-values
  nil
  nil)

Output: (defmacro PRINT-VALUES ...)


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

Issue: Macro call that should be transformed by ->

Output: (defmacro -> ...)


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

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

Input:
(with-packages-unlocked nil
  (progn))

Output: (defmacro WITH-PACKAGES-UNLOCKED ...)


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

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

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

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


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

Issue: Macro call that should be transformed by SUNLESS

Input:
(sunless nil
  nil)

Output:
(defmacro sunless (test &body body)
  "Like UNLESS, except binds the test form to IT (via SYMBOL-MACROLET) for the
scope of the body. IT can be set with SETF."
  `(symbolic unless ,test ,@body))


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

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

Input: (defpackage nil (progn))

Output: (defmacro DEFPACKAGE ...)


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

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

Input: (old nil)

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


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

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

Input: (current-decoder nil (progn))

Output:
(defmacro current-decoder (&rest keys)
  "Capture current values of custom variables and return a custom
decoder which restores these values in its dynamic environment."
  (let (exterior-bindings customizations)
    (flet ((collect (key var)
             (let ((exterior (gensym)))
               (push (list exterior var) exterior-bindings)
               (push exterior customizations)
               (push key customizations))))
      (if keys
          (loop for key in keys
             do (collect key (custom-key-to-variable key)))
          (loop-on-custom (key var)
             do (collect key var)))
      `(let ,exterior-bindings
         (custom-decoder ,@customizations)))))


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

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

Input:
(multiple-value-prog2 nil
    nil)

Output:
(defmacro multiple-value-prog2 (first-form second-form &body forms)
  "Evaluates FIRST-FORM, then SECOND-FORM, and then FORMS. Yields as its value
all the value returned by SECOND-FORM."
  `(progn ,first-form (multiple-value-prog1 ,second-form ,@forms)))


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

Issue: Macro call that should be transformed by RESOLVE

Input:
(resolve
  nil)

Output: (defmacro RESOLVE ...)


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

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

Input:
(defunion nil
  :key
  nil)

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

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

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

Output: (defmacro EXPORT ...)


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

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

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

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


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

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

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

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


Instruction:
Generate a defmacro form that transforms code like this:
(enable-interpol-syntax nil (progn))

Pattern to recognize: Macro call that should be transformed by ENABLE-INTERPOL-SYNTAX

Input: (enable-interpol-syntax nil (progn))

Output:
(defmacro enable-interpol-syntax (&rest %enable-interpol-syntax-args)
  "Enable CL-INTERPOL reader syntax."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
    (%enable-interpol-syntax ,@%enable-interpol-syntax-args)))


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

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

Input: (assert nil)

Output: (defmacro ASSERT ...)


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

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

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

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


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

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

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

Output:
(defmacro case-let ((var expr) &body cases)
  "Like (let ((VAR EXPR)) (case VAR ...)), with VAR read-only."
  `(let1 ,var ,expr
     (case ,var
       ,@cases)))


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

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

Input: (the nil)

Output: (defmacro THE ...)


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

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

Input:
(c?n-until nil
  :key
  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:
Create a Common Lisp macro for the following transformation. Before code:
(ccase nil ())

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

Input: (ccase nil ())

Output: (defmacro CCASE ...)


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

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

Input: (with-foreign-strings nil)

Output:
(defmacro with-foreign-strings (bindings &body body)
  "See WITH-FOREIGN-STRING's documentation."
  (if bindings
      `(with-foreign-string ,(first bindings)
         (with-foreign-strings ,(rest bindings)
           ,@body))
      `(progn ,@body)))


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

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

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

Output: (defmacro DEFMACRO ...)


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

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

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

Output:
(defmacro make-method (form)
  `(cl:make-method ,form))


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

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

Input: (form-attribute nil (progn))

Output: (defmacro FORM-ATTRIBUTE ...)


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

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

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

Output: (defmacro ITER ...)


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

Problem: Macro call that should be transformed by GLOBAL

Input:
(global
  nil)

Output: (defmacro GLOBAL ...)


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

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

Input:
(with-active-layers nil
  (progn))

Output: (defmacro WITH-ACTIVE-LAYERS ...)


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

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

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

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

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

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

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


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

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

Input: (bgo nil)

Output:
(defmacro bgo (msg)
  `(break "BGO ~a" ',msg))


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

Problem: Macro call that should be transformed by DEFGUARANTEE

Input:
(defguarantee nil
    (progn))

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


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

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

Input:
(string-ecase nil
  (progn))

Output: (defmacro STRING-ECASE ...)


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

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

Input:
(named-lambda nil
    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:
Define a macro that eliminates this repetitive pattern:
(custom-decoder nil (progn))

Issue: Macro call that should be transformed by CUSTOM-DECODER

Input: (custom-decoder nil (progn))

Output:
(defmacro custom-decoder (&rest customizations)
  "Return a function which is like DECODE-JSON called in a dynamic
environment with the given CUSTOMIZATIONS."
  `(lambda (&optional (stream *json-input*))
     (bind-custom-vars ,customizations
       (decode-json stream))))


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

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

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

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


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

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

Input:
(ematch nil
  (progn))

Output:
(defmacro ematch (arg &body clauses)
  "Same as MATCH, except MATCH-ERROR will be raised if not matched."
  (once-only (arg)
    (let ((else `(error 'match-error
                        :values (list ,arg)
                        :patterns ',(mapcar (lambda (c) (list (car c))) clauses))))
      (compile-match-1 arg clauses else))))


Instruction:
Generate a defmacro form that transforms code like this:
(without-recursion nil
  nil)

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

Input:
(without-recursion nil
  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:
Create a Common Lisp macro for the following transformation. Before code:
(dynamic-relet* nil
  (progn))

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

Input:
(dynamic-relet* nil
  (progn))

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


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

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

Input: (collect-file nil :key nil)

Output: (defmacro COLLECT-FILE ...)


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

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

Input: (newq nil :key nil)

Output: (defmacro NEWQ ...)


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

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

Input: (block-compile nil)

Output:
(defmacro block-compile ((&key entry-points
                               (block-compile t))
                         &body body)
  "Shorthand for block compilation with `local*'.

Only the functions in ENTRY-POINTS will have global definitions. All
other functions in BODY will be compiled as purely local functions,
and all of their calls to one another will be compiled as local calls.
This includes calls to the entry points, and even self-calls from
within the entry points.

Note that `declaim' forms occuring inside of BODY will be translated
into local `declare' forms.

If you pass `:block-compile nil', this macro is equivalent to progn.
This may be useful during development."
  (if (not block-compile) `(progn ,@body)
      `(local*
         ,@body
         (progn
           ,@(loop for entry-point in entry-points
                   collect `(defalias ,entry-point #',entry-point))))))


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

Write a macro that addresses: Macro call that should be transformed by WITH-CONSTANT-INJECT-HOOK

Input:
(with-constant-inject-hook nil
  (progn))

Output:
(defmacro with-constant-inject-hook (func &body body)
  (let ((func-name (gensym "hook")))
    `(let* ((,func-name ,func)
            (*constant-inject-hook* ,func-name))
       ,@body)))


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

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

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

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


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

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

Input: (ignore-errors)

Output: (defmacro IGNORE-ERRORS ...)


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

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

Input: (check-type nil nil)

Output: (defmacro CHECK-TYPE ...)


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

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

Input:
(bind nil
  (progn))

Output:
(defmacro bind ((&rest bindings) &body body)
  "Bind variables from BINDINGS to be active inside BODY, as if by LET*,
combined with MULTIPLE-VALUE-BIND, DESTRUCTURING-BIND and other -bind forms,
depending on the type of the first argument."
  (let ((rez body))
    (dolist (binding (reverse bindings))
      (setf rez `((,@(funcall #'expand-binding binding rez)))))
    (first rez)))


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

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

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

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


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(enable-punch-syntax)

What needs to change: Macro call that should be transformed by ENABLE-PUNCH-SYNTAX

Input: (enable-punch-syntax)

Output:
(defmacro enable-punch-syntax ()
  '(eval-when (:compile-toplevel :load-toplevel :execute)
    (cl-syntax:use-syntax punch-syntax)))


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

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

Input:
(define-definition-resolver nil
    (progn))

Output:
(defmacro define-definition-resolver (name args &body body)
  `(progn (setf (definition-resolver ',name)
                (lambda ,args ,@body))
          ',name))


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

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

Input: (splice-seqf nil nil)

Output: (defmacro SPLICE-SEQF ...)


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

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

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

Output: (defmacro REDUCED-TYPECASE ...)


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

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

Input:
(define-declaration nil
    (progn))

Output: (defmacro DEFINE-DECLARATION ...)


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

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

Input:
(handler-bind nil
  nil)

Output: (defmacro HANDLER-BIND ...)


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

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

Input: (def-bop nil)

Output: (defmacro DEF-BOP ...)


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

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

Input:
(c?1
  nil
  nil)

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


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

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

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

Output:
(defmacro defoptimizer (name args &body body)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (symbol-optimizer ',name)
           #+sbcl
           (sb-int:named-lambda ',name ,args ,@body)
           #-sbcl
           (lambda ,args ,@body))
     ,@(when (stringp (first body))
         ;; lisp-namespace
         `((setf (documentation ',name 'optimizer)
                 ,(let ((*print-pretty* t))
                    #-clisp
                    (format nil "~<Lambda-List: ~s~
                                 ~:@_~<  ~@;~a~:>~
                               ~:>"
                            (list args (list (first body))))
                    #+clisp
                    (format nil "Lambda-List: ~s~%~a"
                            args (first body))))))))


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

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

Input:
(*let nil
  :key
  nil)

Output: (defmacro *LET ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(pprint-coalton-codegen
  common-lisp:nil
  :key
  common-lisp:nil)

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

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

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


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

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

Input:
(for-all nil
  (progn))

Output:
(defmacro for-all (bindings &body body)
  "Bind BINDINGS to random variables and test BODY *num-trials* times.

BINDINGS is a list of binding forms, each element is a list
of (BINDING VALUE &optional GUARD). Value, which is evaluated
once when the for-all is evaluated, must return a generator which
be called each time BODY is evaluated. BINDING is either a symbol
or a list which will be passed to destructuring-bind. GUARD is a
form which, if present, stops BODY from executing when IT returns
NIL. The GUARDS are evaluated after all the random data has been
generated and they can refer to the current value of any
binding. NB: Generator forms, unlike guard forms, can not contain
references to the bound variables.

Examples:

  (for-all ((a (gen-integer)))
    (is (integerp a)))

  (for-all ((a (gen-integer) (plusp a)))
    (is (integerp a))
    (is (plusp a)))

  (for-all ((less (gen-integer))
            (more (gen-integer) (< less more)))
    (is (<= less more)))

  (for-all (((a b) (gen-two-integers)))
    (is (integerp a))
    (is (integerp b)))"
  (with-gensyms (test-lambda-args)
    `(perform-random-testing
      (list ,@(mapcar #'second bindings))
      (lambda (,test-lambda-args)
        (destructuring-bind ,(mapcar #'first bindings)
            ,test-lambda-args
          (if (and ,@(delete-if #'null (mapcar #'third bindings)))
              (progn ,@body)
              (throw 'run-once
                (list :guard-conditions-failed))))))))


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

Issue: Macro call that should be transformed by ORDER-BY

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

Output: (defmacro ORDER-BY ...)


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

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

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

Output: (defmacro FINALLY ...)


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

Write a macro that addresses: Macro call that should be transformed by AUTO-PERMUTE-TYPECASE

Input: (auto-permute-typecase nil)

Output: (defmacro AUTO-PERMUTE-TYPECASE ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(ignore-errors nil :key nil)

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

Input: (ignore-errors nil :key nil)

Output: (defmacro IGNORE-ERRORS ...)


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

Write a macro that addresses: Macro call that should be transformed by DEF-SUITE*

Input: (def-suite* nil)

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


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(enable-quasi-quoted-bivalent-to-bivalent-emitting-form-syntax nil)

What needs to change: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BIVALENT-TO-BIVALENT-EMITTING-FORM-SYNTAX

Input: (enable-quasi-quoted-bivalent-to-bivalent-emitting-form-syntax nil)

Output: (defmacro ENABLE-QUASI-QUOTED-BIVALENT-TO-BIVALENT-EMITTING-FORM-SYNTAX ...)


Instruction:
Create a Common Lisp macro for the following transformation. Before code:
(enable-quasi-quoted-binary-syntax)

What needs to change: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BINARY-SYNTAX

Input: (enable-quasi-quoted-binary-syntax)

Output: (defmacro ENABLE-QUASI-QUOTED-BINARY-SYNTAX ...)


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

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

Input: (alt nil)

Output:
(defmacro alt (parser &rest parsers)
  "Accept the results of the first parser from a group to succeed."
  (let ((offset (gensym "ALT-OFFSET")))
    `(lambda (,offset)
       ,(labels ((recurse (ps furthest)
                   (if (null ps)
                       `(fail ,furthest)
                       (let ((res  (gensym "ALT-RES"))
                             (next (gensym "ALT-NEXT")))
                         `(multiple-value-bind (,res ,next) (funcall ,(car ps) ,offset)
                            (if (ok? ,res)
                                (values ,res ,next)
                                ,(recurse (cdr ps) `(max ,next ,furthest))))))))
          (recurse (cons parser parsers) offset)))))


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

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

Input: (skip 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:
(raw nil :key nil)

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

Input: (raw nil :key nil)

Output:
(defmacro raw (&rest forms)
  `(list ,@forms))


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

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

Input:
(all-of nil
  nil)

Output: (defmacro ALL-OF ...)


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

Problem: Macro call that should be transformed by STYPECASE

Input:
(stypecase nil
  nil)

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


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

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

Input: (and-let nil (progn))

Output:
(defmacro and-let (var &rest args)
  "Like AND. VAR will be bound to the value of the previous AND form"
  (cond ((null args) t)
        ((null (cdr args)) (car args))
        (t `(when-let (,var ,(car args))
              (and ,@(cdr args))))))


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

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

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

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


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

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

Input: (dynamic-relet* nil)

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


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

Issue: Macro call that should be transformed by NCONCF

Input: (nconcf nil :key nil)

Output: (defmacro NCONCF ...)


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

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

Input: (newq nil (progn))

Output: (defmacro NEWQ ...)


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

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

Input:
(with-logical-transaction nil
  :key
  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:
Generate a defmacro form that transforms code like this:
(peek 'lol-gen::some-name)

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

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

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

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

In the following example

.. code-block::

   (defcell a 0)
   (defcell b 1)

   (defcell sum (+ a (peek b))

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

.. important::

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

   .. code-block::

      (defcell sum (+ b (peek b))

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

"

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

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

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

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

             ,form))))))


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

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

Input: (unionf nil :key nil)

Output: (defmacro UNIONF ...)


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

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

Input:
(finishes
  nil
  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:
Define a macro that eliminates this repetitive pattern:
(when nil)

Issue: Macro call that should be transformed by WHEN

Input: (when nil)

Output: (defmacro WHEN ...)


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

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

Input: (nunionf nil nil)

Output: (defmacro NUNIONF ...)


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

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

Input: (aand)

Output: (defmacro AAND ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-live-scope
  nil
  (progn))

Issue: Macro call that should be transformed by WITH-LIVE-SCOPE

Input:
(with-live-scope
  nil
  (progn))

Output:
(defmacro with-live-scope (&body body)
  "Stop all live blocks defined in BODY on exiting the form.

All live blocks, defined using LIVE, are stopped when exiting the
dynamic extent defined by this form.

Multiple WITH-LIVE-SCOPE forms can be nested, in which case each form
stops the live blocks defined immediately within it."

  (with-gensyms (stoppers forms global-live)
    `(let ((,stoppers nil))
       (macrolet ((,global-live (&body ,forms)
                    (macroexpand `(live ,@,forms)))

                  (live (&body ,forms)
                    `(push (,',global-live ,@,forms) ,',stoppers)))
         (unwind-protect (progn ,@body)
           (foreach #'funcall ,stoppers))))))


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

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

Input: (for nil (progn))

Output: (defmacro FOR ...)


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

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

Input:
(define-module nil
  (progn))

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

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

Input:
(cell-let nil
  (progn))

Output:
(defmacro cell-let ((&rest bindings) &body body &environment env)
  "Define cells that are visible only to the forms in BODY.

BINDINGS is a list of cell bindings to establish, similar to
LET*. Each item in BINDINGS is a list of the form

.. code-block::

   (NAME VALUE-FORM)

where NAME is the symbol identifying the cell and VALUE-FORM is the
value form of the cell. The cell can then be referenced within the
forms in BODY by the symbol NAME.

The cells defined in BINDINGS lexcially shadow those in the
environment defined with DEFCELL or by an enclosing CELL-LET
form. Like LET* and unlike LET, each cell definition may reference the
cells defined earlier in the same CELL-LET.

The forms in BODY are evaluated in an implicit PROGN. The value
returned by the last form is returned by the CELL-LET form."

  (flet ((make-cell-binding (binding form)
           (destructuring-bind (name &optional initform)
               (ensure-list binding)

             (if (constantp initform env)
                 `(mutable-cell-let% (,name ,initform) ,form)
                 `(computed-cell-let% (,name ,initform) ,form)))))

    (->> `(progn ,@body)
         (reduce #'make-cell-binding bindings :from-end t :initial-value))))


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

Problem: Macro call that should be transformed by DEL-PROXY

Input: (del-proxy nil)

Output:
(defmacro del-proxy (slot &key (node-name 'item))
  "Remove proxy-node in slot"
  (let ((val (gensym)) (node-list (gensym)))
    `(let ((,val (slot-value ,node-name ',slot)))
       (if (eql (find-class 'nodelist) (class-of (slot-value ,node-name ',slot)))
  	   (let ((,node-list (slot-value (slot-value ,node-name ',slot) 'nodes)))
 	     (setf (slot-value (slot-value ,node-name ',slot) 'nodes)
  		   (loop for i in ,node-list collect
  			(slot-value i 'proxy-subnode))))
  	   (if ,val (setf (slot-value ,node-name ',slot)
  			  (slot-value ,val 'proxy-subnode)))))))


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

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

Input:
(with-boolean nil
  nil)

Output:
(defmacro with-boolean ((&rest branches) &body body
                        &environment env)
  "Establishes a lexical environment in which it is possible to use
macroexpand-time branching. Within the lexical scope of
`with-boolean', it is possible to use `boolean-if', `boolean-when',
and `boolean-unless' to conditionalize whether some forms are included
at compilation time. (You may also use `:if', `:when', or `:unless'
for brevity.)
\
The first argument must be a list of symbols which name variables. This macro
will expand into a series of conditionals"
  (cond (*boolean-bypass*
         `(progn ,@body))
        (t (let ((all-branches (macroexpand-1 '%all-branches% env)))
             `(macrolet ((:if (cond then else)
                              (list 'boolean-if cond then else))
                         (:when (cond &body then)
                           (list* 'boolean-when cond then))
                         (:unless (cond &body then)
                           (list* 'boolean-unless cond then)))
                (locally
                    (declare #+sbcl (sb-ext:disable-package-locks
                                     %in-branching% %all-branches%)
                             #+sbcl (sb-ext:muffle-conditions
                                     sb-ext:code-deletion-note))
                  (symbol-macrolet ((%in-branching% t)
                                    (%all-branches% (,@branches ,@all-branches))
                                    (%true-branches% ()))
                    (locally (declare #+sbcl (sb-ext:enable-package-locks
                                              %in-branching% %all-branches%))
                      (%with-boolean ,branches ,@body)))))))))


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

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

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

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


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

Issue: Macro call that should be transformed by DEFPACKAGE

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

Output: (defmacro DEFPACKAGE ...)


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

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

Input: (or nil :key nil)

Output: (defmacro OR ...)


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

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

Input: (defcell nil (progn))

Output:
(defmacro defcell (name value-form &environment env)
  "Define a global cell identified by NAME.

This macro defines a cell identified by NAME with its value computed
by VALUE-FORM. The value of the cell can be referenced by the symbol
NAME following the DEFCELL form.

If VALUE-FORM is a constant, by CONSTANTP, a mutable cell is defined
which can have its value set directly using SETF or SETQ on the symbol
NAME.

If VALUE-FORM is not a constant a computed cell is created. A computed
cell may reference one or more argument cells in VALUE-FORM or a
function called during the evaluation of VALUE-FORM.  When the values
of any of the argument cells change, the value of the computed cell is
recomputed by evaluating VALUE-FORM again. The referenced argument
cells are determined automatically when the VALUE-FORM is evaluated.

This macro creates a cell definition that is visible globally to all
forms unless it is lexically shadowed by a definition with the same
NAME using CELL-LET. Note that despite being visible globally, the
cell definition is still lexically scoped and not dynamically scoped
like global variables defined with DEFVAR or DEFPARAMETER."

  (if (constantp value-form env)
      `(define-mutable-cell% ,name ,value-form)
      `(define-computed-cell% ,name ,value-form)))


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

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

Input: (def-kid-slots 'lol-gen::some-name)

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:
(esc 'lol-gen::some-name)

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

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

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


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

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

Input: (eval-always)

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

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

Input: (-<> nil)

Output: (defmacro -<> ...)


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

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

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

Output:
(defmacro char-ecase (keyform &body clauses)
  "Like `ecase', but specifically for characters.
Expands into `tree-case'."
  `(char-ecase-1 ,keyform
     ,@(expand-char-case-keys clauses)))


Instruction:
Generate a defmacro form that transforms code like this:
(dispatch-caseql nil)

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

Input: (dispatch-caseql nil)

Output:
(defmacro dispatch-caseql ((&rest exprs-and-types) &body clauses)
  "Like `dispatch-case', but types in clauses are implicitly wrapped in `eql'.
The syntax of `dispatch-caseql' is tohus closer to `case' than to
`typecase'."
  (expect-form-list
   `(dispatch-case ,exprs-and-types
      ,@(expand-dispatch-caseql-clauses clauses))))


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

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

Input:
(with-unique-names nil
  nil)

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


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

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

Input: (with-active-layers* nil)

Output: (defmacro WITH-ACTIVE-LAYERS* ...)


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

Write a macro that addresses: Macro call that should be transformed by CLASS/STD

Input:
(class/std nil
  :key
  nil)

Output:
(defmacro class/std (name &body defaulted-slots)
  "The most concise shortcut macro to DEFCLASS.

  (class/std example slot1 slot2 slot3)

  expands to:

  (DEFCLASS/STD EXAMPLE ()
    ((SLOT1 SLOT2 SLOT3)))

  which expands to:

  (DEFCLASS EXAMPLE ()
    ((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL)
    (SLOT2 :ACCESSOR SLOT2 :INITARG :SLOT2 :INITFORM NIL)
    (SLOT3 :ACCESSOR SLOT3 :INITARG :SLOT3 :INITFORM NIL)))
"
  `(defclass/std ,name ()
     ((,@defaulted-slots))))


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

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

Input: (compiler-macro-lambda nil)

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


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

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

Input: (*> nil nil)

Output:
(defmacro *> (parser &rest parsers)
  "Combination of parsers yielding the result of the rightmost one."
  (let ((offset (gensym "*>-OFFSET")))
    `(lambda (,offset)
       ,(reduce (lambda (i p)
                  (let ((res  (gensym "*>-RES"))
                        (next (gensym "*>-NEXT")))
                    `(multiple-value-bind (,res ,next) ,i
                       (if (ok? ,res)
                           (funcall ,p ,next)
                           (fail ,next)))))
                parsers
                :initial-value `(funcall ,parser ,offset)))))


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(enable-quasi-quoted-bivalent-syntax)

Write a macro that addresses: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BIVALENT-SYNTAX

Input: (enable-quasi-quoted-bivalent-syntax)

Output: (defmacro ENABLE-QUASI-QUOTED-BIVALENT-SYNTAX ...)


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

What needs to change: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-TYPES

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

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


Instruction:
Define a macro that eliminates this repetitive pattern:
(with-inactive-layers nil
  (progn))

Issue: Macro call that should be transformed by WITH-INACTIVE-LAYERS

Input:
(with-inactive-layers nil
  (progn))

Output: (defmacro WITH-INACTIVE-LAYERS ...)


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

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

Input:
(define-direct-binding nil
    nil)

Output:
(defmacro define-direct-binding (name args &body body)
  (let ((env (or (lambda-fiddle:environment-lambda-var args) (gensym "ENVIRONMENT"))))
    `(progn (setf (binding ',name)
                  (lambda ,(lambda-fiddle:remove-environment-part args)
                    (let ((,env *environment*))
                      (declare (ignorable ,env))
                      ,@body)))
            ',name)))


Instruction:
Define a macro that eliminates this repetitive pattern:
(rem-arg-list-key-value! nil nil)

Issue: Macro call that should be transformed by REM-ARG-LIST-KEY-VALUE!

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

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

Problem: Macro call that should be transformed by DEFMETHOD

Input: (defmethod nil :key nil)

Output: (defmacro DEFMETHOD ...)


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

Problem: Macro call that should be transformed by DEFINE-VARI-FUNCTION

Input:
(define-vari-function nil
    (progn))

Output:
(defmacro define-vari-function (name args &body body)
  (check-args-for-constant-names :function name args)
  (destructuring-bind (in-args uniforms context shared)
      (split-arguments args '(&uniform &context &shared))
    (declare (ignore context))
    (assert (not shared) () 'shared-in-function :name name)
    `(progn
       (add-external-function ',name ',in-args ',uniforms ',body)
       ',name)))


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

Problem: Macro call that should be transformed by FM-COUNT-NAMED

Input: (fm-count-named nil (progn))

Output:
(defmacro fm-count-named (family md-name &key (global-search t))
    `(length (fm-find-all ,family ,md-name
                 :must-find nil
                 :global-search ,global-search)))


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

Problem: Macro call that should be transformed by TRANSLATION-FORMS-FOR-CLASS

Input: (translation-forms-for-class nil nil)

Output:
(defmacro translation-forms-for-class (class type-class)
  "Make forms for translation of foreign structures to and from a standard class.  The class slots are assumed to have the same name as the foreign structure."
  ;; Possible improvement: optional argument to map structure slot names to/from class slot names.
  `(progn
     (defmethod translate-from-foreign (pointer (type ,type-class))
       ;; Make the instance from the plist
       (apply 'make-instance ',class (call-next-method)))
     (defmethod translate-into-foreign-memory ((object ,class) (type ,type-class) pointer)
       (call-next-method
        ;; Translate into a plist and call the general method
        (loop for slot being the hash-value of (structure-slots type)
              for name = (slot-name slot)
              append (list slot-name (slot-value object slot-name)))
        type
        pointer))))


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

Problem: Macro call that should be transformed by DECIDE

Input: (decide nil)

Output: (defmacro DECIDE ...)


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

Problem: Macro call that should be transformed by EKO

Input: (eko nil (progn))

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


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

Problem: Macro call that should be transformed by DEFVAR-UNBOUND

Input:
(defvar-unbound nil
  nil)

Output:
(defmacro defvar-unbound (var &body (docstring))
  "Define VAR as if by `defvar' with no init form, and set DOCSTRING
as its documentation.

I believe the name comes from Edi Weitz."
  `(progn
     (defvar ,var)
     (setf (documentation ',var 'variable) ,docstring)
     ',var))


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

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

Input:
(multiple-value-match nil
  nil)

Output:
(defmacro multiple-value-match (values-form &body clauses)
  "Matches the multiple values of VALUES-FORM with CLAUSES. Unlike
MATCH, CLAUSES have to have the form of (PATTERNS . BODY), where
PATTERNS is a list of patterns. The number of values that will be used
to match is determined by the maximum arity of PATTERNS among CLAUSES.

Examples:

    (multiple-value-match (values 1 2)
     ((2) 1)
     ((1 y) y))
    => 2"
  (compile-multiple-value-match values-form clauses nil))


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

Problem: Macro call that should be transformed by DEFSYNTAX

Input:
(defsyntax nil
  :key
  nil)

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


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

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

Input: (ignore-errors nil nil)

Output: (defmacro IGNORE-ERRORS ...)


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

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

Input:
(c-formula nil
  nil)

Output:
(defmacro c-formula ((&rest keys &key lazy &allow-other-keys) &body forms)
  (assert (member lazy '(nil t :once-asked :until-asked :always)))
  `(make-c-dependent
    :code ',forms
    :value-state :unevaluated
    :rule (c-lambda ,@forms)
    ,@keys))


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

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

Input: (.< common-lisp:nil common-lisp:nil)

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

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


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

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

Input:
(with-context-variables nil
  nil)

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


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

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

Input: (getsethash nil :key nil)

Output:
(defmacro getsethash (key table new-value)
  "Either get the value from TABLE by KEY or set a new calculated NEW-VALUE
   there and return it.
   It's similar to GETHASH called with 3 parameteres, but functions lazily."
  (once-only (key table)
    (with-gensyms (val in#)
      `(multiple-value-bind (,val ,in#) (gethash ,key ,table)
         (if ,in# ,val
             (sethash ,key ,table ,new-value))))))


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

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

Input:
(c?
  nil)

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


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

Problem: Macro call that should be transformed by EMATCH*

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

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

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

Input: (unwrap-as common-lisp:nil)

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

    (unwrap-as <type> <expr>)

is equivalent to

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

and

    (unwrap-as <type>)

is equivalent to

    (fn (expr) (the <type> (unwrap (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")))
           (unwrap (cl:ignore-errors (cl:find-symbol "UNWRAP" "COALTON/CLASSES"))))
    (cl:assert try-into () "`try-as` macro does not have access to `try-into` yet.")
    (cl:assert unwrap () "`unwrap` macro does not have access to `unwrap` yet.")
    (cl:if expr-supplied-p
           `(the ,type (,unwrap (,try-into ,expr)))
           (alexandria:with-gensyms (lexpr)
             `(fn (,lexpr)
                (the ,type (,unwrap (,try-into ,lexpr))))))))


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

Issue: Macro call that should be transformed by DEFMETHOD*

Input:
(defmethod* nil
    nil)

Output: (defmacro DEFMETHOD* ...)


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

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

Input:
(define-modf-rewrite nil
    (progn))

Output:
(defmacro define-modf-rewrite (name (expr) &body body)
  "Define a new rewrite rule.  If a form starting with NAME is encountered, call
the defined function to return a form that we can deal with (i.e. one defined
via DEFINE-MODF-EXPANDER, DEFINE-MODF-FUNCTION, and DEFINE-MODF-METHOD)."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (gethash ',name *modf-rewrites*)
           (lambda (,expr)
             ,@body))))


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

Issue: Macro call that should be transformed by IGNORING

Input:
(ignoring nil
  (progn))

Output:
(defmacro ignoring (type &body body)
  "DEPRECATED: use `alexandria:ignore-some-conditions' instead."
  (simple-style-warning "~s is deprecated, use ~s instead"
                        'ignoring 'ignore-some-conditions)
  `(ignore-some-conditions (,type)
     ,@body))


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

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

Input:
(with nil
  (progn))

Output: (defmacro WITH ...)