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

Problem: Macro call that should be transformed by DEFINE-FIXTURE-CAPTURE

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

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


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

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

Input: (econd nil)

Output:
(defmacro econd (&rest clauses)
  "Like `cond', but signal an error of type `econd-failure' if no
clause succeeds."
  (let ((test-count (length clauses)))
    `(cond ,@clauses
           ;; SBCL will silently eliminate this branch if it is
           ;; unreachable.
           (t (error 'econd-failure :test-count ',test-count)))))


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

Problem: Macro call that should be transformed by LAMBDA

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

Output: (defmacro LAMBDA ...)


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

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

Input: (undefmessage nil)

Output: (defmacro UNDEFMESSAGE ...)


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

Problem: Macro call that should be transformed by F_N

Input:
(f_n
  nil)

Output: (defmacro F_N ...)


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

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

Input: (multiple-value-setq nil (progn))

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


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

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

Input:
(min-of nil
  :key
  nil)

Output: (defmacro MIN-OF ...)


Instruction:
Define a macro that eliminates this repetitive pattern:
(the-kids nil :key nil)

Issue: Macro call that should be transformed by THE-KIDS

Input: (the-kids nil :key nil)

Output:
(defmacro the-kids (&rest kids)
  `(let ((*parent* self))
     (packed-flat! ,@kids)))


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

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

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

Output: (defmacro SOME-> ...)


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

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

Input: (synchronized nil)

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

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


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

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

Input: (define-hook-generic nil nil)

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

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

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

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

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

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


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

Issue: Macro call that should be transformed by DEFOPTIMIZER

Input:
(defoptimizer common-lisp:nil
    :key
  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:
Write a Common Lisp macro to handle this code pattern:
(abbr nil nil)

Problem: Macro call that should be transformed by ABBR

Input: (abbr nil nil)

Output:
(defmacro abbr (short long &optional lambda-list)
  "Abbreviate LONG macro or function name as SHORT.
   If LAMBDA-LIST is present, also copy appropriate SETF-expander."
  `(eval-always
     ;; Lispworks signals error while abbreviating to keywords
     ;; SBCL has package locks when accessing built-in functionality
     ;; other similar things are probably possible in other implementations
     (handler-bind ((error (lambda (e)
                             (let ((r (find-restart 'continue e)))
                               (when r
                                 (warn 'rutils-style-warning
                                       :format-control
                                       "Skipped error during abbreviation: ~A"
                                       :format-arguments (list e))
                                 (invoke-restart r))))))
       (cond
         ((macro-function ',long)
          (setf (macro-function ',short) (macro-function ',long))
          #+ccl (setf (ccl:arglist ',short) (ccl:arglist ',long)))
         ((special-operator-p ',long)
          (error "Can't abbreviate a special-operator ~a" ',long))
         ((fboundp ',long)
          (setf (fdefinition ',short) (fdefinition ',long))
          #+ccl (setf (ccl:arglist ',short) (ccl:arglist ',long))
          ,(when lambda-list
            `(define-setf-expander ,short ,lambda-list
               (values ,@(multiple-value-bind
                          (dummies vals store store-form access-form)
                          (get-setf-expansion
                           (cons long (remove-if (lambda (sym)
                                                   (member sym '(&optional &key)))
                                                 lambda-list)))
                          (let ((expansion-vals (mapcar (lambda (x) `(quote ,x))
                                                        (list dummies
                                                              vals
                                                              store
                                                              store-form
                                                              access-form))))
                            (setf (second expansion-vals)
                                  (cons 'list vals))
                            expansion-vals))))))
         (t
          (error "Can't abbreviate ~a" ',long)))
       (setf (documentation ',short 'function) (documentation ',long 'function))
       ',short)))


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

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

Input: (setf)

Output: (defmacro SETF ...)


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

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

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

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


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

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

Input: (is-error nil :key nil)

Output: (defmacro IS-ERROR ...)


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

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

Input:
(c-lambda
  nil
  (progn))

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


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

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

Input: (define-hook-type nil (progn))

Output:
(defmacro define-hook-type (name type &optional documentation)
  "Define hook class.
Type must be something like:

  (function (string) (values integer t))

The `handler-type' of the defined hook class has `:class' allocation
type, so that all hooks of such class have the same `handler-type'."
  (let* ((name (string name))
         (hook-class-name (intern (serapeum:concat "HOOK-" name))))
    `(defclass ,hook-class-name (hook)
       ((handler-type :initform ',type :allocation :class))
       (:metaclass closer-mop:funcallable-standard-class)
       ,@(when documentation
           `((:documentation ,documentation))))))


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

What needs to change: Macro call that should be transformed by DECLARE-DEPRECATED-OPERATORS

Input: (declare-deprecated-operators nil nil)

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


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

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

Input: (sif nil nil)

Output:
(defmacro sif (test then &optional else)
  "Like IF, except binds the test form to IT (via SYMBOL-MACROLET) for
the scope of the then and else expressions. IT can be set with SETF"
  `(symbolic if ,test ,then ,else))


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

Issue: Macro call that should be transformed by ACOND

Input:
(acond
  nil)

Output: (defmacro ACOND ...)


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

Problem: Macro call that should be transformed by RG!

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

Output:
(defmacro rg! (id)
  (if (eq id :coach)
      `(fm-other :coach)
    `(fm-find-registered ,id self)))


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

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

Input: (as-> nil :key nil)

Output: (defmacro AS-> ...)


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 (arg) &body body)
  "Equivalent to (defun (arg) [decl-and-docstring] (ematch arg (PATTERN BODY...)))."
  (multiple-value-bind (preamble clauses) (parse-matcher-body body)
    `(defun ,name (,arg)
       ,@preamble
       (ematch ,arg
         ,@clauses))))


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

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

Input: (some->)

Output: (defmacro SOME-> ...)


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

Issue: Macro call that should be transformed by STYPECASE

Input:
(stypecase nil
  (progn))

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

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

Input: (make-instance* nil :key nil)

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

Conveniences:

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

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

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

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

Examples:

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

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

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

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

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

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

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

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


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

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

Input:
(special-symbol-progv nil
    :key
  nil)

Output: (defmacro SPECIAL-SYMBOL-PROGV ...)


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

Pattern to recognize: Macro call that should be transformed by FOREIGN-FUNCALL-VARARGS

Input: (foreign-funcall-varargs nil nil)

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


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

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

Input: (lambda-match)

Output: (defmacro LAMBDA-MATCH ...)


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

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

Input: (some->> nil)

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


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

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

Input: (cond-let nil)

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


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

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

Input: (sort-values nil 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:
Generate a defmacro form that transforms code like this:
(ps-html nil (progn))

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

Input: (ps-html nil (progn))

Output: (defmacro PS-HTML ...)


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

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

Input: (unionf nil (progn))

Output: (defmacro UNIONF ...)


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

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

Input:
(define-inference-rule nil
    (progn))

Output: (defmacro DEFINE-INFERENCE-RULE ...)


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

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

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

Output: (defmacro DESTRUCTURING-MATCH ...)


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

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

Input: (finally nil :key nil)

Output: (defmacro FINALLY ...)


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

Problem: Macro call that should be transformed by EMATCH

Input: (ematch nil)

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

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

Input:
(with-gensyms nil
  :key
  nil)

Output:
(defmacro with-gensyms ((&rest names) &body body)
  "Provide gensyms for given NAMES."
  `(let ,(loop :for n :in names :collect `(,n (gensym)))
     ,@body))


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

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

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

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


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

Problem: Macro call that should be transformed by ITERATE

Input:
(iterate
  nil)

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


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

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

Input:
(necessarily?
  nil
  :key
  nil)

Output: (defmacro NECESSARILY? ...)


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

Problem: Macro call that should be transformed by MATRIX-TYPECASE

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

Output: (defmacro MATRIX-TYPECASE ...)


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

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

Input: (aif nil :key nil)

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


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

Issue: Macro call that should be transformed by EVAL-AND-COMPILE

Input:
(eval-and-compile
  nil
  nil)

Output:
(defmacro eval-and-compile (&body body)
  "Emacs's `eval-and-compile'.
Alias for `eval-always'."
  `(eval-always
     ,@body))


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

Issue: Macro call that should be transformed by WITH

Input:
(with nil
  :key
  nil)

Output: (defmacro WITH ...)


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

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

Input:
(f_
  nil
  nil)

Output: (defmacro F_ ...)


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

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

Input: (with-html)

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


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

Problem: Macro call that should be transformed by SUNLESS

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

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

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

Input: (nest nil nil)

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

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

For example:

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

Is equivalent to:

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

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

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

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

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


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

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

Input: (enable-interpol-syntax nil nil)

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

Issue: Macro call that should be transformed by VAR

Input: (var nil (progn))

Output: (defmacro VAR ...)


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

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

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

Output: (defmacro -> ...)


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

Issue: Macro call that should be transformed by SCTYPECASE

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

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


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

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

Input: (splice-seqf 'lol-gen::some-name)

Output: (defmacro SPLICE-SEQF ...)


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

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

Input: (defparameter nil (progn))

Output: (defmacro DEFPARAMETER ...)


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

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

Input: (destructuring-ecase nil)

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


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

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

Input: (distinct-on nil nil)

Output:
(defmacro distinct-on (columns &rest fields)
  `(make-clause :distinct-on (list ,@columns) ,@(mapcar #'expand-op fields)))


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

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

Input:
(alambda nil
  :key
  nil)

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


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

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

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

Output: (defmacro IGNORE ...)


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

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

Input: (-> nil (progn))

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


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

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

Input:
(defun* nil
    :key
  nil)

Output: (defmacro DEFUN* ...)


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

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

Input: (case nil (progn))

Output: (defmacro CASE ...)


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

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

Input: (boolean-when nil)

Output:
(defmacro boolean-when (branch &body body &environment env)
  "Includes some forms based on whether a macroexpand-time branch is true. The
first argument must be a symbol naming a branch in the lexically enclosing
WITH-BOOLEAN form.
\
It is an error to use this macro outside the lexical environment established by
WITH-BOOLEAN."
  (cond (*boolean-bypass*
         `(when ,branch ,@body))
        ((not (member branch (macroexpand-1 '%all-branches% env)))
         (missing-branch branch))
        ((not (macroexpand-1 '%in-branching% env))
         (conditional-error 'when))
        ((not (member branch (macroexpand-1 '%true-branches% env)))
         `(progn))
        ((= 0 (length body))
         `(progn))
        ((= 1 (length body))
         (car body))
        (t `(progn ,@body))))


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

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

Input: (is-values nil)

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


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

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

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

Output:
(defmacro define-value-binding (name (var &rest args) &body body)
  (let ((vars (lambda-fiddle:extract-lambda-vars (lambda-fiddle:remove-aux-part args))))
    (emit-binding-definition name var args body :extra-vars vars)))


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

What needs to change: Macro call that should be transformed by GEN-LAMBDA-WITH-STICKY-STOP

Input: (gen-lambda-with-sticky-stop nil :key nil)

Output:
(defmacro gen-lambda-with-sticky-stop (&rest rest)
  `(make-instance
    'basic-generator
    :function (sticky-stop-lambda ,@rest)))


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

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

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

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


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

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

Input:
(local*
  nil
  nil)

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

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


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

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

Input: (acond)

Output:
(defmacro acond (&body clauses)
  "Like COND, except result of each test-form is bound to IT (via LET) for the
scope of the corresponding clause."
  (labels ((rec (clauses)
	     (if clauses
		 (destructuring-bind ((test &body body) . rest)  clauses
		   (if body
		       `(anaphoric if ,test (progn ,@body) ,(rec rest))
		       `(anaphoric if ,test it ,(rec rest))))
		 nil)))
    (rec clauses)))


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

Problem: Macro call that should be transformed by ECOND

Input: (econd nil :key nil)

Output:
(defmacro econd (&rest clauses)
  "Like `cond', but signal an error of type `econd-failure' if no
clause succeeds."
  (let ((test-count (length clauses)))
    `(cond ,@clauses
           ;; SBCL will silently eliminate this branch if it is
           ;; unreachable.
           (t (error 'econd-failure :test-count ',test-count)))))


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

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

Input: (the nil nil)

Output: (defmacro THE ...)


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

Problem: Macro call that should be transformed by ITER

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

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


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

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

Input: (defsynonym nil nil)

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


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

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

Input:
(caching-types
  nil)

Output: (defmacro CACHING-TYPES ...)


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

Write a macro that addresses: 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:
(send 'lol-gen::some-name)

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

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

Output: (defmacro SEND ...)


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

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

Input:
(some->
  nil
  (progn))

Output: (defmacro SOME-> ...)


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

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

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

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


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

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

Input: (def-suite* nil nil)

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


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

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

Input: (defgeneric nil (progn))

Output: (defmacro DEFGENERIC ...)


Instruction:
You are a Common Lisp macro expert. Given this code pattern:
(enable-quasi-quoted-binary-to-binary-emitting-form-syntax nil)

Write a macro that addresses: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BINARY-TO-BINARY-EMITTING-FORM-SYNTAX

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

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


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

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

Input: (<* nil)

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


Instruction:
Write a Common Lisp macro to handle this code pattern:
(enable-quasi-quoted-list-to-list-emitting-form-syntax)

Problem: Macro call that should be transformed by ENABLE-QUASI-QUOTED-LIST-TO-LIST-EMITTING-FORM-SYNTAX

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

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


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

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

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

Output:
(defmacro make-node (item)
  "Try to identify and make node object"
    `(make-node-function (quoty ,item)))


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

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

Input:
(some-> nil
  (progn))

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


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

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

Input: (accase nil)

Output:
(defmacro accase (keyform &body cases)
  "Like CCASE, except binds the result of the keyform to IT (via LET) for the
scope of the cases. Unlike CCASE, the keyform/place doesn't receive new values
possibly stored with STORE-VALUE restart; the new value is received by IT."
  `(anaphoric ccase ,keyform ,@cases))


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

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

Input: (query nil (progn))

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:
(enable-quasi-quoted-binary-to-binary-emitting-form-syntax 'lol-gen::some-name)

Write a macro that addresses: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BINARY-TO-BINARY-EMITTING-FORM-SYNTAX

Input: (enable-quasi-quoted-binary-to-binary-emitting-form-syntax 'lol-gen::some-name)

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


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

Issue: Macro call that should be transformed by DOSEQ!

Input: (doseq! 'lol-gen::some-name)

Output:
(defmacro doseq! (name/seq &body body)
  "Mutable version of DOSEQ, expanding into DO-SEQUENCES!."

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

    (destructuring-bind (element sequence &rest args) seq
      `(do-sequences! ,name
         ((,element ,sequence ,@args))
         ,@body))))


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

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

Input:
(cmatch nil
  (progn))

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


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

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

Input:
(some-<>
  nil
  nil)

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


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

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

Input: (group-by)

Output: (defmacro GROUP-BY ...)


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

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

Input: (prog* (quote lol-gen::some-name))

Output: (defmacro PROG* ...)


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

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

Input:
(dispatch-case-let nil
  nil)

Output:
(defmacro dispatch-case-let ((&rest bindings) &body clauses &environment env)
  "Like `dispatch-case', but establish new bindings for each expression.

For example,

    (dispatch-case-let (((x string) (expr1))
                        ((y string) (expr2)))
      ...)

is equivalent to

    (let ((x (expr1))
          (y (expr2)))
      (dispatch-case ((x string)
                      (y string))
        ...))

It may be helpful to think of this as a cross between
`defmethod' (where the (variable type) notation is used in the lambda
list) and `let' (which has an obvious macro-expansion in terms of
`lambda')."
  (multiple-value-bind (vars types exprs)
      ;; Split the bindings and types.
      (with-collectors (vars-out types-out exprs-out)
        (flet ((vars-out (var) (vars-out (ensure-var var))))
          (dolist (binding bindings)
            (ematch binding
              ((list (and var (type symbol)) expr)
               (vars-out var)
               (types-out t)
               (exprs-out expr))
              ((list (list (and var (type symbol)) type) expr)
               (vars-out var)
               (types-out type)
               (exprs-out expr))))))
    (let ((normalized-clauses
            ;; Normalize asterisks into the types of the corresponding
            ;; variables.
            (loop for (clause-types . clause-body) in clauses
                  collect (cons
                           (loop for clause-type in clause-types
                                 for type in types
                                 if (eql clause-type '*)
                                   collect type
                                 else collect clause-type)
                           clause-body))))
      (with-unique-names (block)
        (multiple-value-bind (tags final-clauses)
            (hoist-clause-bodies block normalized-clauses env)
          `(let ,(mapcar #'list vars exprs)
             (with-read-only-vars ,vars
               (block ,block
                 (tagbody
                    (dispatch-case/nobindings ,(mapcar #'list vars types)
                      ,@final-clauses)
                    ,@tags)))))))))


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

Issue: Macro call that should be transformed by SELECTOR

Input:
(selector nil
    :key
  nil)

Output: (defmacro SELECTOR ...)


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

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

Input: (-<> nil :key nil)

Output: (defmacro -<> ...)


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

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

Input: (ps-inline nil)

Output: (defmacro PS-INLINE ...)


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

Problem: Macro call that should be transformed by DEFREPLY

Input:
(defreply nil
    nil)

Output: (defmacro DEFREPLY ...)


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

Issue: Macro call that should be transformed by NOR

Input: (nor nil nil)

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

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


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

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

Input: (for nil)

Output:
(defmacro for (update-type &key of nowait skip-locked)
  (let ((ident-list (if (keywordp of)
                        `(list ,of)
                        `(quote ,of))))
    `(make-clause :updatability ,update-type :of ,ident-list :nowait ,nowait :skip-locked ,skip-locked)))


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

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

Input: (->> nil :key nil)

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


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

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

Input:
(caching-types
  nil
  nil)

Output: (defmacro CACHING-TYPES ...)


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

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

Input: (prog () :key nil)

Output: (defmacro PROG ...)


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

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

Input: (proxy nil (progn))

Output: (defmacro PROXY ...)


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

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

Input: (remf nil nil)

Output: (defmacro REMF ...)


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

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

Input:
(with-live-scope
  'lol-gen::some-name)

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

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

Input: (cond->> nil)

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


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

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

Input: (fgather-result nil)

Output: (defmacro FGATHER-RESULT ...)


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

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

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

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

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


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

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

Input: (incf-pointer nil nil)

Output: (defmacro INCF-POINTER ...)


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

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

Input: (options)

Output: (defmacro OPTIONS ...)


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

What needs to change: Macro call that should be transformed by CLASS/STD

Input: (class/std 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:
Write a Common Lisp macro to handle this code pattern:
(with-unique-names nil)

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

Input: (with-unique-names nil)

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


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

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

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

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

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


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

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

Input:
(cond->
  nil
  (progn))

Output: (defmacro COND-> ...)


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

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

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

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


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

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

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

Output: (defmacro SOME-> ...)


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

Issue: Macro call that should be transformed by ^KIDS

Input: (^kids)

Output: (defmacro ^KIDS ...)


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

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

Input: (coercef nil nil)

Output: (defmacro COERCEF ...)


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

Issue: Macro call that should be transformed by WALK-ENVIRONMENT

Input: (walk-environment)

Output: (defmacro WALK-ENVIRONMENT ...)


Instruction:
Generate a defmacro form that transforms code like this:
(cond-it
  nil
  nil)

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

Input:
(cond-it
  nil
  nil)

Output:
(defmacro cond-it (&body body)
  "Like COND. IT is bound to the passed COND test."
  `(let (it)
     (cond
       ,@(mapcar (lambda (clause)
                   `((setf it ,(car clause)) ,@(cdr clause)))
                 ;; uses the fact, that SETF returns the value set
                 body))))


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

Problem: Macro call that should be transformed by JAND

Input: (jand nil nil)

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


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

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

Input:
(c-lambda
  nil)

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


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

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

Input: (define-switches)

Output:
(defmacro define-switches (&key cl-reader cm-reader macro-character)
  "Define c-mera/common-lisp reader switches"
  `(progn
     (defun ,cl-reader ()
       (setf *c-mera-reader* 'cl)
       (setf *readtable* *readtable-backup*))
     (defun ,cm-reader ()
       (setf *c-mera-reader* 'cm)
       ,@macro-character
       (setf (readtable-case *readtable*) :invert))))


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

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

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

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

Input: (nand nil nil)

Output:
(defmacro nand (&rest forms)
  "Equivalent to (not (and ...))."
  (if (null forms) nil
      (if (null (rest forms))
          `(not ,(first forms))
          `(if ,(first forms)
               (nand ,@(rest forms))
               t))))


Instruction:
Define a macro that eliminates this repetitive pattern:
(ensure-transaction-with-isolation-level 'lol-gen::some-name)

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

Input: (ensure-transaction-with-isolation-level 'lol-gen::some-name)

Output:
(defmacro ensure-transaction-with-isolation-level (isolation-level &body body)
  "Executes body within a with-transaction form if and only if no transaction is
already in progress. This adds the ability to specify an isolation level other
than the current default"
  `(call-with-ensured-transaction (lambda () ,@body) ,isolation-level))


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

Issue: Macro call that should be transformed by NCONCF

Input: (nconcf nil (progn))

Output: (defmacro NCONCF ...)


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

Problem: Macro call that should be transformed by DEFINE-DISPATCH

Input:
(define-dispatch nil
    :key
  nil)

Output:
(defmacro define-dispatch (name lambda-list &body body)
  "the lambda list should accept two arguments:
the list of arguments given by the current method call.
the specific hooks (as named or unamed functions) for the qualified method (that we will be dispatching from).

you should then use the arguments to dispatch the specific hooks as you wish in the body.
if the body returns a result, by default the method will also return that result, this can be overriden with finalize-dispatch-method.

See finalize-dispatch-method
See dispatch"
  `(let ((new-dispatch (make-dispatcher (lambda ,lambda-list ,@body))))
     (setf (gethash ',name *dispatch-table*)
           new-dispatch)))


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

Problem: Macro call that should be transformed by IF-IT

Input: (if-it nil nil)

Output:
(defmacro if-it (test then &optional else)
  "Like IF. IT is bound to TEST."
  `(let ((it ,test))
     (if it ,then ,else)))


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

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

Input:
(when-failing nil
  nil)

Output: (defmacro WHEN-FAILING ...)


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

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

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

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


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

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

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

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


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

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

Input: (defgeneric nil nil)

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

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

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

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

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

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

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

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

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

                       options)

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

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

             ,gf))))))


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

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

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

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


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

Problem: Macro call that should be transformed by SCCASE

Input:
(sccase nil
  (progn))

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


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

Problem: Macro call that should be transformed by F-PLUSP

Input: (f-plusp nil nil)

Output:
(defmacro f-plusp (key &rest body)
  `(with-synapse ,key (prior-fire-value)
     (let ((new-basis (progn ,@body)))
       (values new-basis (if (xor prior-fire-value (plusp new-basis))
                             (progn
                               (setf prior-fire-value (plusp new-basis))
                               :propagate)
                           :no-propagate)))))


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

Issue: Macro call that should be transformed by DELETE-FROM

Input: (delete-from nil)

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


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

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

Input: (with-foreign-object 'lol-gen::some-name)

Output:
(defmacro with-foreign-object ((var type &optional (count 1)) &body body)
  "Bind VAR to a pointer to COUNT objects of TYPE during BODY.
The buffer has dynamic extent and may be stack allocated."
  `(with-foreign-pointer
       (,var ,(if (constantp type)
                  ;; with-foreign-pointer may benefit from constant folding:
                  (if (constantp count)
                      (* (eval count) (foreign-type-size (eval type)))
                      `(* ,count ,(foreign-type-size (eval type))))
                  `(* ,count (foreign-type-size ,type))))
     ,@body))


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

What needs to change: Macro call that should be transformed by DEFINE-PARSE-TREE-SYNONYM

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

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


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

Issue: Macro call that should be transformed by DEFINE-FILTERED-FUNCTION

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

Output: (defmacro DEFINE-FILTERED-FUNCTION ...)


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

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

Input: (do-all-symbols (quote lol-gen::some-name))

Output: (defmacro DO-ALL-SYMBOLS ...)


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

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

Input: (match nil)

Output: (defmacro MATCH ...)


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

Issue: Macro call that should be transformed by F

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

Output: (defmacro F ...)


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

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

Input: (with-shadowed-custom-vars)

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


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

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

Input: (mapping nil nil)

Output: (defmacro MAPPING ...)


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

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

Input: (ps-doc)

Output: (defmacro PS-DOC ...)


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

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

Input: (defobserver nil (progn))

Output:
(defmacro defobserver (slotname &rest args &aux (aroundp (eq :around (first args))))
  (when aroundp (setf args (cdr args)))

  #+irritating
  (when (find slotname '(value kids))
    (warn "d: did you mean .value or .kids when you coded ~a?" slotname))

  (destructuring-bind ((&optional (self-arg 'self) (new-varg 'new-value)
                         (oldvarg 'old-value) (oldvargboundp 'old-value-boundp) (cell-arg 'c))
                       &body output-body) args
    `(progn
       (eval-when (:compile-toplevel :load-toplevel :execute)
         (setf (get ',slotname :output-defined) t))
       ,(if (eql (last1 output-body) :test)
            (let ((temp1 (gensym))
                  (loc-self (gensym)))
              `(defmethod slot-value-observe #-(or cormanlisp) ,(if aroundp :around 'progn)
                 ((slotname (eql ',slotname)) ,self-arg ,new-varg ,oldvarg ,oldvargboundp ,cell-arg)
                 (let ((,temp1 (bump-output-count ,slotname))
                       (,loc-self ,(if (listp self-arg)
                                       (car self-arg)
                                     self-arg)))
                   (when (and ,oldvargboundp ,oldvarg)
                     (format t "~&output ~d (~a ~a) old: ~a" ,temp1 ',slotname ,loc-self ,oldvarg ,cell-arg))
                   (format t "~&output ~d (~a ~a) new: ~a" ,temp1 ',slotname ,loc-self ,new-varg ,cell-arg))))
          `(defmethod slot-value-observe
               #-(or cormanlisp) ,(if aroundp :around 'progn)
             ((slotname (eql ',slotname)) ,self-arg ,new-varg ,oldvarg ,oldvargboundp ,cell-arg)
             (declare (ignorable
                       ,@(flet ((arg-name (arg-spec)
                                  (etypecase arg-spec
                                    (list (car arg-spec))
                                    (atom arg-spec))))
                           (list (arg-name self-arg)(arg-name new-varg)
                             (arg-name oldvarg)(arg-name oldvargboundp) (arg-name cell-arg)))))
             ,@output-body)))))


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

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

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

Output: (defmacro COLLECT-LENGTH ...)


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

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

Input: (psetf nil nil)

Output: (defmacro PSETF ...)


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

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

Input:
(m nil
  :key
  nil)

Output: (defmacro M ...)


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

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

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

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


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

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

Input: (once-only 'lol-gen::some-name)

Output:
(defmacro once-only (specs &body forms)
  "Constructs code whose primary goal is to help automate the handling of
multiple evaluation within macros. Multiple evaluation is handled by introducing
intermediate variables, in order to reuse the result of an expression.

The returned value is a list of the form

  (let ((<gensym-1> <expr-1>)
        ...
        (<gensym-n> <expr-n>))
    <res>)

where GENSYM-1, ..., GENSYM-N are the intermediate variables introduced in order
to evaluate EXPR-1, ..., EXPR-N once, only. RES is code that is the result of
evaluating the implicit progn FORMS within a special context determined by
SPECS. RES should make use of (reference) the intermediate variables.

Each element within SPECS is either a symbol SYMBOL or a pair (SYMBOL INITFORM).
Bare symbols are equivalent to the pair (SYMBOL SYMBOL).

Each pair (SYMBOL INITFORM) specifies a single intermediate variable:

- INITFORM is an expression evaluated to produce EXPR-i

- SYMBOL is the name of the variable that will be bound around FORMS to the
  corresponding gensym GENSYM-i, in order for FORMS to generate RES that
  references the intermediate variable

The evaluation of INITFORMs and binding of SYMBOLs resembles LET. INITFORMs of
all the pairs are evaluated before binding SYMBOLs and evaluating FORMS.

Example:

  The following expression

  (let ((x '(incf y)))
    (once-only (x)
      `(cons ,x ,x)))

  ;;; =>
  ;;; (let ((#1=#:X123 (incf y)))
  ;;;   (cons #1# #1#))

  could be used within a macro to avoid multiple evaluation like so

  (defmacro cons1 (x)
    (once-only (x)
      `(cons ,x ,x)))

  (let ((y 0))
    (cons1 (incf y)))

  ;;; => (1 . 1)

Example:

  The following expression demonstrates the usage of the INITFORM field

  (let ((expr '(incf y)))
    (once-only ((var `(1+ ,expr)))
      `(list ',expr ,var ,var)))

  ;;; =>
  ;;; (let ((#1=#:VAR123 (1+ (incf y))))
  ;;;   (list '(incf y) #1# #1))

  which could be used like so

  (defmacro print-succ-twice (expr)
    (once-only ((var `(1+ ,expr)))
      `(format t \"Expr: ~s, Once: ~s, Twice: ~s~%\" ',expr ,var ,var)))

  (let ((y 10))
    (print-succ-twice (incf y)))

  ;;; >>
  ;;; Expr: (INCF Y), Once: 12, Twice: 12"
  (let ((gensyms (make-gensym-list (length specs) "ONCE-ONLY"))
        (names-and-forms (mapcar (lambda (spec)
                                   (etypecase spec
                                     (list
                                      (destructuring-bind (name form) spec
                                        (cons name form)))
                                     (symbol
                                      (cons spec spec))))
                                 specs)))
    ;; bind in user-macro
    `(let ,(mapcar (lambda (g n) (list g `(gensym ,(string (car n)))))
                   gensyms names-and-forms)
       ;; bind in final expansion
       `(let (,,@(mapcar (lambda (g n)
                           ``(,,g ,,(cdr n)))
                         gensyms names-and-forms))
          ;; bind in user-macro
          ,(let ,(mapcar (lambda (n g) (list (car n) g))
                         names-and-forms gensyms)
             ,@forms)))))


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

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

Input:
(defmethod nil
  nil)

Output: (defmacro DEFMETHOD ...)


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

Problem: Macro call that should be transformed by FOR-ALL*

Input:
(for-all* nil
  :key
  nil)

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

Works like FOR-ALL but variables are defined sequentially - subsequent
generator bindings may use value of a previous generator.

Example:

  (for-all* ((a (gen-integer))
             (b (gen-integer :min a :max (+ a 20)))
    (is (<= a b)))"
  (with-gensyms (test-lambda-args)
    `(perform-random-testing
      nil
      (lambda (,test-lambda-args)
        (declare (ignore ,test-lambda-args))
        (dbind-rec ,bindings
          (if (and ,@(delete-if #'null (mapcar #'third bindings)))
              (progn ,@body)
              (throw 'run-once
                (list :guard-conditions-failed))))))))


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

Problem: Macro call that should be transformed by LAMBDA-EMATCH*

Input: (lambda-ematch*)

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


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

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

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

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


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

Issue: Macro call that should be transformed by EMATCH

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

Output:
(defmacro ematch (what &body clauses)
  #.+match-doc+
  (with-gensyms (otherwise)
    `(match2 ,what
       ,@clauses
       (,otherwise (error 'match-error :pattern ',clauses :values (list ,otherwise))))))


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

Problem: Macro call that should be transformed by ACASE

Input:
(acase nil
  nil)

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


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

Issue: Macro call that should be transformed by GATHERER

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

Output: (defmacro GATHERER ...)


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

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

Input: (and-let nil :key nil)

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

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

Input:
(defwalker-handler nil
  :key
  nil)

Output: (defmacro DEFWALKER-HANDLER ...)


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

Problem: Macro call that should be transformed by LET-MATCH*

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

Output:
(defmacro let-match* (bindings &body body)
  "Similar to LET-MATCH but matches sequentially."
  (reduce (lambda (binding form) `(let-match (,binding) ,form))
          bindings
          :from-end t
          :initial-value `(locally ,.body)))


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

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

Input: (with-gensyms nil)

Output:
(defmacro with-gensyms ((&rest names) &body body)
  "Provide gensyms for given NAMES."
  `(let ,(loop :for n :in names :collect `(,n (gensym)))
     ,@body))


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

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

Input:
(defaction nil
    (progn))

Output: (defmacro DEFACTION ...)


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

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

Input: (defparameter nil :key nil)

Output: (defmacro DEFPARAMETER ...)


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

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

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

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


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

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

Input: (dispatch-caseql-let 'lol-gen::some-name)

Output:
(defmacro dispatch-caseql-let ((&rest bindings) &body clauses)
  "Like `dispatch-case-let', but using the clause syntax of `dispatch-caseql'."
  `(dispatch-case-let ,bindings
     ,@(expand-dispatch-caseql-clauses clauses)))


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

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

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

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

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

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

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

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

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

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

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

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

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

         ,name
         ,seqs
         ,@forms))))


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

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

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

Output:
(defmacro dowhile-it (test &body body)
  "Like DOWHILE. IT is bound to TEST."
  `(do ((it ,test ,test))
       ((not it))
     ,@body))


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

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

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

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


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

Problem: Macro call that should be transformed by IGNORE

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

Output: (defmacro IGNORE ...)


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

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

Input: (with-open-files nil)

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


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

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

Input: (and-bind nil :key nil)

Output: (defmacro AND-BIND ...)


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

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

Input: (continue-whopper nil (progn))

Output: (defmacro CONTINUE-WHOPPER ...)


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

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

Input: (reversef nil)

Output: (defmacro REVERSEF ...)


Instruction:
Write a Common Lisp macro to handle this code pattern:
;; Manual destructuring from sequences is verbose
(let ((lst (compute-list)))
  (let ((a (elt lst 0))
        (b (elt lst 1))
        (c (subseq lst 2)))
    (process a b c)))

;; Nested structures are even worse:
(let ((tree (compute-tree)))
  (let ((x (elt tree 0))
        (inner (elt tree 1)))
    (let ((y (elt inner 0))
          (z (elt inner 1)))
      (compute x y z))))

Problem: Manual sequence destructuring with elt/subseq is error-prone — want pattern-based destructuring like ML/Haskell

Input:
;; Manual destructuring from sequences is verbose
(let ((lst (compute-list)))
  (let ((a (elt lst 0))
        (b (elt lst 1))
        (c (subseq lst 2)))
    (process a b c)))

;; Nested structures are even worse:
(let ((tree (compute-tree)))
  (let ((x (elt tree 0))
        (inner (elt tree 1)))
    (let ((y (elt inner 0))
          (z (elt inner 1)))
      (compute x y z))))

Output:
(defmacro dbind (pat seq &body body)
  (let ((gseq (gensym)))
    `(let ((,gseq ,seq))
       ,(dbind-ex (destruc pat gseq #'atom) body))))


Instruction:
Write a Common Lisp macro to handle this code pattern:
(do-symbol-macros-in-lexenv 'lol-gen::some-name)

Problem: Macro call that should be transformed by DO-SYMBOL-MACROS-IN-LEXENV

Input: (do-symbol-macros-in-lexenv 'lol-gen::some-name)

Output: (defmacro DO-SYMBOL-MACROS-IN-LEXENV ...)


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

Problem: Macro call that should be transformed by DECF

Input: (decf nil)

Output: (defmacro DECF ...)


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

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

Input:
(with-synapse nil
    nil)

Output:
(defmacro with-synapse (synapse-id (&rest closure-vars) &body body)
  (let ((syn-id (gensym)))
    `(let* ((,syn-id ,synapse-id)
            (synapse (or (find ,syn-id (cd-useds *depender*) :key 'c-slot-name)
                       (let ((new-syn
                              (let (,@closure-vars)
                                (make-c-dependent
                                 :model (c-model *depender*)
                                 :slot-name ,syn-id
                                 :code ',body
                                 :synaptic t
                                 :rule (c-lambda ,@body)))))
                         (record-caller new-syn)
                         new-syn))))
       (prog1
           (multiple-value-bind (v p)
               (with-integrity ()
                 (ensure-value-is-current synapse :synapse *depender*))
             (values v p))
         (record-caller synapse)))))


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

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

Input:
(with-transaction nil
  (progn))

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


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

Problem: Macro call that should be transformed by CTYPECASE-OF

Input:
(ctypecase-of nil
    nil)

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


Instruction:
Write a Common Lisp macro to handle this code pattern:
(enable-quasi-quoted-string-to-string-emitting-form-syntax 'lol-gen::some-name)

Problem: Macro call that should be transformed by ENABLE-QUASI-QUOTED-STRING-TO-STRING-EMITTING-FORM-SYNTAX

Input: (enable-quasi-quoted-string-to-string-emitting-form-syntax 'lol-gen::some-name)

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


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

Issue: Macro call that should be transformed by OR

Input: (or)

Output: (defmacro OR ...)


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

Issue: Macro call that should be transformed by DEFINE-TEMPLATED-DISPATCH

Input:
(define-templated-dispatch nil
    (progn))

Output: (defmacro DEFINE-TEMPLATED-DISPATCH ...)


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

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

Input: (the-part nil :key nil)

Output: (defmacro THE-PART ...)


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

Problem: Macro call that should be transformed by WITH-FOREIGN-STRING

Input: (with-foreign-string 'lol-gen::some-name)

Output:
(defmacro with-foreign-string ((var-or-vars lisp-string &rest args) &body body)
  "VAR-OR-VARS is not evaluated and should be a list of the form
\(VAR &OPTIONAL BYTE-SIZE-VAR) or just a VAR symbol.  VAR is
bound to a foreign string containing LISP-STRING in BODY.  When
BYTE-SIZE-VAR is specified then bind the C buffer size
\(including the possible null terminator\(s)) to this variable."
  (destructuring-bind (var &optional size-var)
      (ensure-list var-or-vars)
    `(multiple-value-bind (,var ,@(when size-var (list size-var)))
         (foreign-string-alloc ,lisp-string ,@args)
       (unwind-protect
            (progn ,@body)
         (foreign-string-free ,var)))))


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

Issue: Macro call that should be transformed by ALET

Input:
(alet nil
  :key
  nil)

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