[User]
Create a Common Lisp macro for the following transformation. Before code:
(def-iter iterator-chain-from-iter (curr-iter itail) (chain-from-iter (iterable-of-iterables) "Yields the elements of the first iterable in `iterable`, then the second, etc. Equivalent to python's chain.from_iterable(), and conceptually equivalent to `(picl:apply #'picl:chain iterable-of-iterables)`. ``` (chain-from-iter (picl:map (lambda (x) (picl:range x))) (picl:count)) ;; 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, etc ```" (let ((iterable-of-iterables (make-iterator iterable-of-iterables))) (multiple-value-bind (curr-iter its-alive) (next iterable-of-iterables) (if its-alive (init-state (curr-iter (make-iterator curr-iter)) (itail iterable-of-iterables)) (empty-iterator))))) (multiple-value-bind (curr-item curr-alive) (next curr-iter) (if curr-alive (values curr-item t) (progn (multiple-value-bind (next-iter itail-alive) (next itail) (if itail-alive (progn (setf curr-iter (make-iterator next-iter)) (self)) (values nil nil)))))))

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

(def-iter iterator-chain-from-iter (curr-iter itail) (chain-from-iter (iterable-of-iterables) "Yields the elements of the first iterable in `iterable`, then the second, etc. Equivalent to python's chain.from_iterable(), and conceptually equivalent to `(picl:apply #'picl:chain iterable-of-iterables)`. ``` (chain-from-iter (picl:map (lambda (x) (picl:range x))) (picl:count)) ;; 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, etc ```" (let ((iterable-of-iterables (make-iterator iterable-of-iterables))) (multiple-value-bind (curr-iter its-alive) (next iterable-of-iterables) (if its-alive (init-state (curr-iter (make-iterator curr-iter)) (itail iterable-of-iterables)) (empty-iterator))))) (multiple-value-bind (curr-item curr-alive) (next curr-iter) (if curr-alive (values curr-item t) (progn (multiple-value-bind (next-iter itail-alive) (next itail) (if itail-alive (progn (setf curr-iter (make-iterator next-iter)) (self)) (values nil nil)))))))

[Assistant]
(defmacro def-iter (name state-vars (constructor-name constructor-params &body constructor-body)
                    &body next-body)
  "An anaphoric convenience macro which can be re-implemented to change how iterators are
  structured. Exposes the local `init-state` macro within `constructor-body`

  If you don't want to-use this macro (which I totally understand) just write constructors for your
  iterators returning 0-argument closures representing the `next` function and you'll be fine. This
  macro just helped me get through a lot of waffling during development

  Parameters
  ----------
  `name` is a synbol naming the iterator's backing state. However it's actually
  ignored, since PICL doesn't currently expose iterators' backing state

  `state-vars` is a list of symbols naming the iterator's state variables.

  The `constructor-name/params/body` will be `defun`'d to create the user-facing constructor
  function. In `constructor-body`, the return value should be an iterator or a call to local
  `init-state` macro

  `next-body` The definition of the `next` function for this iterator, which will be run in a
   lexical environment consisting of the state vars

  Both `constructor-body` and `next-body` are defined in the lexical environment of the `def-iter`
  form, and as such can access any lexical bindings not shadowed by the `constructor-params` and
  `state-vars` respectively

  The local `init-state` macro.
  ----------------------------
  The arguments to `init-state` should be of the form `(statevar-symbol value-form)`or
  `statevar-symbol`. In the first case, the value of `value-form` will be used to initialize the
  state variable named by `symbol`. In the second case, `statevar-symbol` is also used as the
  corresponding `value-form`

  Example
  -------
  What follows is a sample implementation of the `count` iterator using this macro
  ```
  (def-iter ignored-backing-name (curr-val step)
    (count (start step)
      (init-state (curr-val start) step))
    (prog1 curr-val (incf curr-val step))))
  ````"

  (declare (ignore name))
  (alexandria:with-gensyms (next-fname)
    (let ((docstring "Function had no docstring, so this one was inserted"))
      (when (and (cdr constructor-body) (stringp (car constructor-body)))
        (setf docstring (car constructor-body)
              constructor-body (cdr constructor-body)))
      `(labels ((,next-fname (&key ,@state-vars)
                  (labels ((self () ,@next-body)) #'self)))
         (defun ,constructor-name ,constructor-params
           ,docstring
           (macrolet
               ((init-state (&rest argspecs)
                  (list 'apply '#',next-fname
                        (apply #'append
                               '(list )
                               (mapcar (lambda (aspec)
                                         (if (symbolp aspec)
                                             (list (alx:make-keyword aspec) aspec)
                                             (destructuring-bind (aname adef) aspec
                                               (list (alx:make-keyword aname) adef))))
                                       argspecs)))))
             ,@constructor-body))))))

;; macroexpand:
(labels ((#:next-fname135 (&key curr-iter itail) (labels ((self nil (multiple-value-bind (curr-item curr-alive) (next curr-iter) (if curr-alive (values curr-item t) (progn (multiple-value-bind (next-iter itail-alive) (next itail) (if itail-alive (progn (setf curr-iter (make-iterator next-iter)) (self)) (values nil nil)))))))) (function self)))) (defun chain-from-iter (iterable-of-iterables) "Yields the elements of the first iterable in `iterable`, then the second, etc. Equivalent to python's chain.from_iterable(), and conceptually equivalent to `(picl:apply #'picl:chain iterable-of-iterables)`. ``` (chain-from-iter (picl:map (lambda (x) (picl:range x))) (picl:count)) ;; 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, etc ```" (macrolet ((init-state (&rest argspecs) (list (quote apply) (quote (function #:next-fname135)) (apply (function append) (quote (list)) (mapcar (lambda (aspec) (if (symbolp aspec) (list (alx:make-keyword aspec) aspec) (destructuring-bind (aname adef) aspec (list (alx:make-keyword aname) adef)))) argspecs))))) (let ((iterable-of-iterables (make-iterator iterable-of-iterables))) (multiple-value-bind (curr-iter its-alive) (next iterable-of-iterables) (if its-alive (init-state (curr-iter (make-iterator curr-iter)) (itail iterable-of-iterables)) (empty-iterator)))))))


[User]
Write a Common Lisp macro to handle this code pattern:
(defreply nil
    :key
  nil)

Problem: Macro call that should be transformed by DEFREPLY

(defreply nil
    :key
  nil)

[Assistant]
(defmacro DEFREPLY ...)

;; macroexpand:
(progn
 (eval-when (:compile-toplevel)
   (unless (fboundp 'nil)
     (warn 'automatic-message-creation :message-name 'nil)
     (ensure-message 'nil :lambda-list 'nil)))
 (ensure-reply 'nil :qualifiers '(:key) :lambda-list 'nil :participants (list)
               :documentation nil :function
               (lambda (#:args144 #:next-replies145 &rest #:more-args147)
                 (declare
                  (ignorable #:args144 #:next-replies145 #:more-args147))
                 (flet ((next-reply-p ()
                          (not (null #:next-replies145)))
                        (call-next-reply (&rest args)
                          (if (null #:next-replies145)
                              (apply 'no-next-reply
                                     (getf #:more-args147 :message)
                                     (getf #:more-args147 :reply)
                                     (or args #:args144))
                              (apply (reply-function (car #:next-replies145))
                                     (or args #:args144)
                                     (cdr #:next-replies145) #:more-args147))))
                   (declare
                    (ignorable (function next-reply-p)
                     (function call-next-reply)))
                   (flet ((#:reply-function146 ()
                            (declare (ignorable))
                            (block nil)))
                     (declare (inline #:reply-function146))
                     (apply #'#:reply-function146 #:args144))))))


[User]
Generate a defmacro form that transforms code like this:
(define-class-method nil
    :key
  nil)

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

(define-class-method nil
    :key
  nil)

[Assistant]
(defmacro DEFINE-CLASS-METHOD ...)

;; macroexpand:
(progn
 (define-incongruent-method nil
     :key
   nil)
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (add-class-principal-method 'nil ':key)))


[User]
Define a macro that eliminates this repetitive pattern:
(as-> nil
    :key
  nil)

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

(as-> nil
    :key
  nil)

[Assistant]
(defmacro AS-> ...)

;; macroexpand:
(let* ((:key nil) (:key (nil)))
  :key)


[User]
Create a Common Lisp macro for the following transformation. Before code:
(is-true t)

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

(is-true t)

[Assistant]
(defmacro is (test &rest reason-args)
  "The DWIM checking operator.

If TEST returns a true value a test-passed result is generated,
otherwise a test-failure result is generated. The reason, unless
REASON-ARGS is provided, is generated based on the form of TEST:

 (predicate expected actual) - Means that we want to check
 whether, according to PREDICATE, the ACTUAL value is
 in fact what we EXPECTED.

 (predicate value) - Means that we want to ensure that VALUE
 satisfies PREDICATE.

 Wrapping the TEST form in a NOT simply produces a negated reason
 string."
  (assert (listp test)
          (test)
          "Argument to IS must be a list, not ~S" test)
  (let (bindings effective-test default-reason-args)
    (with-gensyms (e a v)
      (flet ((process-entry (predicate expected actual &optional negatedp)
               ;; make sure EXPECTED is holding the entry that starts with 'values
               (when (and (consp actual)
                          (eq (car actual) 'values))
                 (assert (not (and (consp expected)
                                   (eq (car expected) 'values))) ()
                                   "Both the expected and actual part is a values expression.")
                 (rotatef expected actual))
               (let ((setf-forms))
                 (if (and (consp expected)
                          (eq (car expected) 'values))
                     (progn
                       (setf expected (copy-list expected))
                       (setf setf-forms (loop for cell = (rest expected) then (cdr cell)
                                              for i from 0
                                              while cell
                                              when (eq (car cell) '*)
                                              collect `(setf (elt ,a ,i) nil)
                                              and do (setf (car cell) nil)))
                       (setf bindings (list (list e `(list ,@(rest expected)))
                                            (list a `(multiple-value-list ,actual)))))
                     (setf bindings (list (list e expected)
                                          (list a actual))))
                 (setf effective-test `(progn
                                         ,@setf-forms
                                         ,(if negatedp
                                              `(not (,predicate ,e ,a))
                                              `(,predicate ,e ,a)))))))
        (list-match-case test
          ((not (?predicate ?expected ?actual))
           (process-entry ?predicate ?expected ?actual t)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is ~2&~S~2%to ~2&~S~2% (it should not be)"
                       `',?actual a `',?predicate e)))
          ((not (?satisfies ?value))
           (setf bindings (list (list v ?value))
                 effective-test `(not (,?satisfies ,v))
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which satisfies ~2&~S~2% (it should not)"
                       `',?value v `',?satisfies)))
          ((?predicate ?expected ?actual)
           (process-entry ?predicate ?expected ?actual)
           (setf default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%"
                       `',?actual a `',?predicate e)))
          ((?satisfies ?value)
           (setf bindings (list (list v ?value))
                 effective-test `(,?satisfies ,v)
                 default-reason-args
                 (list "~2&~S~2% evaluated to ~2&~S~2% which does not satisfy ~2&~S~2%"
                       `',?value v `',?satisfies)))
          (?_
           (setf bindings '()
                 effective-test test
                 default-reason-args (list "~2&~S~2% was NIL." `',test)))))
      `(let ,bindings
         (if ,effective-test
             (add-result 'test-passed :test-expr ',test)
             (process-failure ',test
                              ,@(or reason-args default-reason-args)))))))

;; macroexpand:
(if t (add-result (quote test-passed) :test-expr (quote t)) (process-failure (quote t) "~S did not return a true value" (quote t)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defobject 'some-name)

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

(defobject 'some-name)

[Assistant]
(defmacro DEFOBJECT ...)

;; macroexpand:
(object :parents (list quote some-name) :properties (list))


[User]
Define a macro that eliminates this repetitive pattern:
(iterate)

Issue: Macro call that should be transformed by ITERATE

(iterate)

[Assistant]
(defmacro ITERATE ...)

;; macroexpand:
(iter)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(defsynonym never :never)

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

(defsynonym never :never)

[Assistant]
(defmacro defsynonym (symbol synonym)
  "Set SYNONYM for a SYMBOL. "
  `(eval-always
     (setf (get ',symbol 'synonym) ',synonym)))

;; macroexpand:
(eval-always (setf (get (quote never) (quote synonym)) (quote :never)))


[User]
Write a Common Lisp macro to handle this code pattern:
(define-simple-definition-resolver macro macro-function)

Problem: Macro call that should be transformed by define-simple-definition-resolver

(define-simple-definition-resolver macro macro-function)

[Assistant]
(defmacro define-simple-definition-resolver (class lookup-function &body body)
  (let ((package (gensym "PACKAGE")))
    `(define-definition-resolver ,class (,class ,package)
       (when (ignore-errors ,(if body
                                 `(let ((,(first lookup-function) ,class))
                                    ,@body)
                                 `(,lookup-function ,class)))
         (list (make-instance ',class :designator ,class :package ,package))))))

;; macroexpand:
(define-definition-resolver macro (macro #:package134) (when (ignore-errors (macro-function macro)) (list (make-instance (quote macro) :designator macro :package #:package134))))


[User]
Define a macro that eliminates this repetitive pattern:
(define-option-expander shadow (package &rest symbols) (shadow symbols package))

Issue: Macro call that should be transformed by define-option-expander

(define-option-expander shadow (package &rest symbols) (shadow symbols package))

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

;; macroexpand:
(defmethod expand-option ((#:type128 (eql :shadow)) package #:args127) (destructuring-bind (&rest symbols) #:args127 (shadow symbols package)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(lambda-ematch0 ((list* var options) `(type ,(getf options :type) ,var)))

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

(lambda-ematch0 ((list* var options) `(type ,(getf options :type) ,var)))

[Assistant]
(defmacro lambda-ematch0 (&body clauses)
  (alexandria:with-gensyms (arg)
    `(lambda (,arg)
       (ematch0 ,arg
         ,@clauses))))

;; macroexpand:
(lambda (#:arg167) (ematch0 #:arg167 ((list* var options) (sb-int:quasiquote (type #S(sb-impl::comma :expr (getf options :type) :kind 0) #S(sb-impl::comma :expr var :kind 0))))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(define-modf-rewrite cdadar (expr) `(cdr (cadar ,(second expr))))

What needs to change: Macro call that should be transformed by define-modf-rewrite

(define-modf-rewrite cdadar (expr) `(cdr (cadar ,(second expr))))

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

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (setf (gethash (quote cdadar) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (cdr (cadar #S(sb-impl::comma :expr (second expr) :kind 0)))))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(lambda-match
  nil
  :key
  nil)

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

(lambda-match
  nil
  :key
  nil)

[Assistant]
(defmacro LAMBDA-MATCH ...)

;; macroexpand:
(lambda (#:arg149)
  (match #:arg149
    nil
    :key
    nil))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(receive (x) (values) x)

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

(receive (x) (values) x)

[Assistant]
(defmacro receive (formals expr &body body)
  "Stricter version of `multiple-value-bind'.

Use `receive' when you want to enforce that EXPR should return a
certain number of values, or a minimum number of values.

If FORMALS is a proper list, then EXPR must return exactly as many
values -- no more and no less -- as there are variables in FORMALS.

If FORMALS is an improper list (VARS . REST), then EXPR must return at
least as many values as there are VARS, and any further values are
bound, as a list, to REST.

Lastly, if FORMALS is a symbol, bind that symbol to all the values
returned by EXPR, as if by `multiple-value-list'.

From Scheme (SRFI-8)."
  ;; It's probably not worth stack-allocating the thunk.
  (cond ((null formals)
         `(multiple-value-call
              (lambda ()
                ,@body)
            ,expr))
        ((atom formals)
         ;; This could also be written:
         #+(or) `(let ((,formals (multiple-value-list ,expr)))
                   ,@body)
         ;; But I want it to be possible to declare FORMALS to have
         ;; dynamic extent, and most Lisps support that for &rest
         ;; lists.
         `(multiple-value-call
              (lambda (&rest ,formals)
                ,@body)
            ,expr))
        ((proper-list-p formals)
         (when (intersection formals lambda-list-keywords)
           (error "Lambda list keywords in formals: ~a" formals))
         `(multiple-value-call
              (lambda ,formals
                ,@body)
            ,expr))
        (t (let* ((last (last formals))
                  (vars (append (butlast formals)
                                (list (car last))))
                  (rest (cdr last)))
             (when (intersection (cons rest vars) lambda-list-keywords)
               (error "Lambda list keywords in formals: ~a" formals))
             `(multiple-value-call
                  (lambda (,@vars &rest ,rest)
                    ,@body)
                ,expr)))))

;; macroexpand:
(multiple-value-call (lambda (x) x) (values))


[User]
Define a macro that eliminates this repetitive pattern:
(do+ (for x (to 5)) (generating y (in #(0 1))) (collect (list x y)) (when (oddp x) (is (eql (try-update y :on-error (lambda (value cond) (setf error cond) value)) y))) (when error (multiple-value-bind (value success?) (try-update y) (is (eql value y)) (is (null success?)))))

Issue: Macro call that should be transformed by do+

(do+ (for x (to 5)) (generating y (in #(0 1))) (collect (list x y)) (when (oddp x) (is (eql (try-update y :on-error (lambda (value cond) (setf error cond) value)) y))) (when error (multiple-value-bind (value success?) (try-update y) (is (eql value y)) (is (null success?)))))

[Assistant]
(defmacro do+ (&body body)
  "High-level, extensible iteration construct. Refer to the manual for syntax and semantics."
  `(do+/internal nil ,@body))

;; macroexpand:
(do+/internal nil (for x (to 5)) (generating y (in #(0 1))) (collect (list x y)) (when (oddp x) (is (eql (try-update y :on-error (lambda (value cond) (setf error cond) value)) y))) (when error (multiple-value-bind (value success?) (try-update y) (is (eql value y)) (is (null success?)))))


[User]
Write a Common Lisp macro to handle this code pattern:
(def-neo4j-fun list-indexes ((type :node)) :get (:uri-spec (format nil "index/~A" (string-downcase (symbol-name type)))) (:status-handlers (200 (decode-neo4j-json-output body))))

Problem: Macro call that should be transformed by def-neo4j-fun

(def-neo4j-fun list-indexes ((type :node)) :get (:uri-spec (format nil "index/~A" (string-downcase (symbol-name type)))) (:status-handlers (200 (decode-neo4j-json-output body))))

[Assistant]
(defmacro def-neo4j-fun (name lambda-list method &rest args)
  `(progn
     (defun ,name (&key ,@lambda-list)
       (let ((uri ,(cadr (assoc :uri-spec args)))
             (json (encode-neo4j-json-payload ,@(aif (assoc :encode args)
                                                     (cdr it)
                                                     (list '() :string)))))
         (make-neo4j-request ,method uri json
                             (list ,@(mapcar (lambda (handler)
                                               `(list ,(car handler) (lambda (body uri json)
                                                                  ,(cadr handler))))
                                             (cdr (assoc :status-handlers args)))))))))

;; macroexpand:
(progn (defun list-indexes (&key (type :node)) (let ((uri (format nil "index/~A" (string-downcase (symbol-name type)))) (json (encode-neo4j-json-payload nil :string))) (make-neo4j-request :get uri json (list (list 200 (lambda (body uri json) (decode-neo4j-json-output body))))))))


[User]
Write a Common Lisp macro to handle this code pattern:
(defiter nil
    (progn))

Problem: Macro call that should be transformed by DEFITER

(defiter nil
    (progn))

[Assistant]
(defmacro DEFITER ...)

;; macroexpand:
(defun nil (progn) (make-instance 'iterator :coro (lambda-coro)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(define-templated-dispatch nil
    :key
  nil)

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

(define-templated-dispatch nil
    :key
  nil)

[Assistant]
(defmacro DEFINE-TEMPLATED-DISPATCH ...)

;; macroexpand:
(define-type-dispatch nil
    :key)


[User]
Define a macro that eliminates this repetitive pattern:
(caching-types)

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

(caching-types)

[Assistant]
(defmacro CACHING-TYPES ...)

;; macroexpand:
(call-with-disjoint-hash
 (lambda ()
   (call-with-subtype-hash
    (lambda ()
      (call-with-equiv-hash
       (lambda () (call-with-subtypep-cache (lambda ()))))))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(-<>>
  'some-name)

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

(-<>>
  'some-name)

[Assistant]
(defmacro -<>> ...)

;; macroexpand:
'some-name


[User]
Create a Common Lisp macro for the following transformation. Before code:
(->*
  nil
  (progn))

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

(->*
  nil
  (progn))

[Assistant]
(defmacro ->* ...)

;; macroexpand:
(let* ((#:var192 (progn)) (#:var193 (nil #:var192)))
  #:var193)


[User]
Generate a defmacro form that transforms code like this:
(define-class some-class (some super classes) ((slot1 :unbound :documentation "zork")) (1 2) (3 4))

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

(define-class some-class (some super classes) ((slot1 :unbound :documentation "zork")) (1 2) (3 4))

[Assistant]
(defmacro define-class (name supers slots &rest options)
  "Convenience wrapper of `defclass'.

It automates a lot of boilerplate (like exporting all the accessors of a class)
plus adds some new features.

Slot options:

- The initform can be specified as the second value.

- `:accessor', `:reader' and `:writer' can be set to either a name, NIL or T.
  If NIL, the method is not generated.
  If T, the method is generated using the `:accessor-name-transformer' class option value.

- The `:export' option allows to control the slot-name export on a per-slot basis.

New class options (defaults are NIL unless specified):

- `:slot-definition-transformer' (default: `default-slot-definition-transformer').
  A function that takes a SLOT-DEFINITION and returns a new one.

- `:accessor-name-package': The package of the generated accessors.  See
  `:accessor-name-transformer'.  Some special values are accepted:
  - `:slot-name': The package of the slot-name.
  - `:default': The current package.

- `:accessor-name-transformer' (default `default-accessor-name-transformer').

  A function of (SLOT-NAME SLOT-DEFINITION) arguments that returns the accessor
  name (a symbol).  Other transformer: `dwim-accessor-name-transformer'.

- `:automatic-accessors-p': Whether to generate accessor names automatically for
  all slots.

  As a special case, the accessor is not generated if all following conditions are met:
  - `:accessor-name-package' is `:slot-name',
  - slot name package is different from current package,
  - if the `:accessor' slot option is not provided,

- `:initarg-name-transformer' (default: `default-initarg-name-transformer'.)

  A function of (SLOT-NAME SLOT-DEFINITION) arguments that returns the accessor
  name (a symbol.

- `:automatic-initargs-p' (default: T): Whether to generate accessor names
  automatically for all slots.

- `:predicate-name-transformer' (default: `default-predicate-name-transformer').

  A function of (SLOT-NAME SLOT-DEFINITION) arguments that returns the predicate
  name (a symbol).

- `:automatic-predicates-p' (default: T): Whether to generate a predicate
  for the class.

- `:type-inference' (default: `default-type-inference').

  Function that returns the type of a slot definition (with an initform).  It
  takes 3 arguments:

  - The initform.
  - The slot name.
  - The rest of the slot definition.

- `:automatic-types-p': Whether to generate the type automatically for all
  slots.  The type can still be specified manually with the `:type' slot option.

- Self-explanatory export options (all NIL by default):
  - `:export-class-name-p'
  - `:export-accessor-names-p'
  - `:export-slot-names-p'
  - `:export-predicate-name'"
  (build-defclass-like-expansion
   name supers slots options
   (lambda (processed-slots clean-options)
     `(defclass ,name ,supers
        ,processed-slots
        ,@clean-options))))

;; macroexpand:
(progn (defclass some-class (some super classes) ((slot1 :accessor slot1 :initarg :slot1 :documentation "zork")) (1 2) (3 4)) (unless (fboundp (quote some-class-p)) (define-generic some-class-p (object) #A((75) base-char . "Auto-generated predicate for whether OBJECT is an instance of `some-class'.") (declare (sb-ext:muffle-conditions style-warning)) (typep object (quote some-class)))) (setf (documentation (quote slot1) (quote function)) #A((53) base-char . "Auto-generated accessor function for slot SLOT1.
zork")) (ignore-errors (setf (documentation (fdefinition (quote slot1)) (quote function)) #A((53) base-char . "Auto-generated accessor function for slot SLOT1.
zork"))) (ignore-errors (setf (documentation (fdefinition (quote (setf slot1))) (quote function)) #A((53) base-char . "Auto-generated accessor function for slot SLOT1.
zork"))) (find-class (quote some-class) nil))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(define-modf-rewrite cdar (expr) `(cdr (car ,(second expr))))

Write a macro that addresses: Macro call that should be transformed by define-modf-rewrite

(define-modf-rewrite cdar (expr) `(cdr (car ,(second expr))))

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

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (setf (gethash (quote cdar) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (cdr (car #S(sb-impl::comma :expr (second expr) :kind 0)))))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(defstore example (object))

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

(defstore example (object))

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

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (ensure-store (quote example) (quote (object)))))


[User]
Write a Common Lisp macro to handle this code pattern:
(some->)

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

(some->)

[Assistant]
(defmacro SOME-> ...)

;; macroexpand:
nil


[User]
You are a Common Lisp macro expert. Given this code pattern:
(with-packages-unlocked 'some-name)

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

(with-packages-unlocked 'some-name)

[Assistant]
(defmacro WITH-PACKAGES-UNLOCKED ...)

;; macroexpand:
(let ((#:|packages124| (locked-packages ''some-name)))
  (unlock-packages #:|packages124|)
  (unwind-protect (lock-packages #:|packages124|)))


[User]
Write a Common Lisp macro to handle this code pattern:
(answer foo 42)

Problem: Macro call that should be transformed by answer

(answer foo 42)

[Assistant]
(defmacro answer (call &body forms)
  (let ((name (if (listp call) (car call) call))
        (sym (gensym)))
    `(if-called
      ',name
      (let ((,sym (fdefinition ',name)))
        (declare (ignorable ,sym))
        (let ((times 0))
          (lambda (&rest args)
            (declare (ignorable args))
            ,(let ((cases
                     `(case (prog1 times (incf times))
                        ,.(loop
                            for i from 0
                            for (form . rest) on forms
                            collect `(,(if rest i T) ,form)))))
               (if (listp call)
                   `(trivia:match args
                     ((list . ,(cdr call)) ,cases)
                     (_ (unhandled)))
                   cases))))))))

;; macroexpand:
(if-called (quote foo) (let ((#:g162 (fdefinition (quote foo)))) (declare (ignorable #:g162)) (let ((times 0)) (lambda (&rest args) (declare (ignorable args)) (case (prog1 times (incf times)) (t 42))))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(defvar-compile-time *tagbody-tags* '() "This must be globally NIL.")

Write a macro that addresses: Macro call that should be transformed by defvar-compile-time

(defvar-compile-time *tagbody-tags* '() "This must be globally NIL.")

[Assistant]
(defmacro defvar-compile-time (name &optional initial-value documentation)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (defvar ,name ,initial-value ,documentation)))

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (defvar *tagbody-tags* (quote nil) "This must be globally NIL."))


[User]
Write a Common Lisp macro to handle this code pattern:
(f 'some-name)

Problem: Macro call that should be transformed by F

(f 'some-name)

[Assistant]
(defmacro F ...)

;; macroexpand:
(lambda (quote some-name))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(bdd-typecase 'some-name)

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

(bdd-typecase 'some-name)

[Assistant]
(defmacro BDD-TYPECASE ...)

;; macroexpand:
((lambda (#:obj165)
   (declare (ignorable #:obj165))
   (block #:block166 (tagbody)))
 'some-name)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(collect-hash nil (progn))

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

(collect-hash nil (progn))

[Assistant]
(defmacro COLLECT-HASH ...)

;; macroexpand:
(common-lisp:let* ((#:out-149 (make-hash-table)))
  (common-lisp:let ((#:generator-153 (generator (progn)))
                    #:values-145
                    (#:generator-151 (generator nil))
                    #:keys-144)
    (declare (type generator #:generator-153)
             (type generator #:generator-151))
    (tagbody
     #:ll-154
      (setq #:values-145 (next-in #:generator-153 (go end)))
      (setq #:keys-144 (next-in #:generator-151 (go end)))
      (setf (gethash #:keys-144 #:out-149) #:values-145)
      (go #:ll-154)
     end)
    #:out-149))


[User]
Define a macro that eliminates this repetitive pattern:
(define-error unknown-type-spec () (type-spec) "Could not find the correct type for type-spec ~s~@[ ~a~]~%~a" type-spec (when (typep type-spec 'v-type) (format nil "~%It seems we recieved a type object instead of type spec")) (let ((found (find-alternative-types-for-spec type-spec))) (if found (format nil "~%Perhaps you meant one of these types?:~%~(~{~s~%~}~)" found) "")))

Issue: Macro call that should be transformed by define-error

(define-error unknown-type-spec () (type-spec) "Could not find the correct type for type-spec ~s~@[ ~a~]~%~a" type-spec (when (typep type-spec 'v-type) (format nil "~%It seems we recieved a type object instead of type spec")) (let ((found (find-alternative-types-for-spec type-spec))) (if found (format nil "~%Perhaps you meant one of these types?:~%~(~{~s~%~}~)" found) "")))

[Assistant]
(defmacro define-error (name (&key (error-type 'varjo-error) (prefix "Varjo"))
                            (&rest args) error-string &body body)
  `(defcondition ,name (:error-type ,error-type :prefix ,prefix) ,args
       ,error-string ,@body))

;; macroexpand:
(defcondition unknown-type-spec (:error-type varjo-error :prefix "Varjo") (type-spec) "Could not find the correct type for type-spec ~s~@[ ~a~]~%~a" type-spec (when (typep type-spec (quote v-type)) (format nil "~%It seems we recieved a type object instead of type spec")) (let ((found (find-alternative-types-for-spec type-spec))) (if found (format nil "~%Perhaps you meant one of these types?:~%~(~{~s~%~}~)" found) "")))


[User]
Generate a defmacro form that transforms code like this:
(def-dynenv-macro nil
    nil)

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

(def-dynenv-macro nil
    nil)

[Assistant]
(defmacro DEF-DYNENV-MACRO ...)

;; macroexpand:
(defmacro nil (&environment #:env174) (with-dynenv #:env174))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(deferror "08007" transaction-resolution-unknown)

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

(deferror "08007" transaction-resolution-unknown)

[Assistant]
(defmacro deferror (code typename &optional (superclass 'database-error))
  `(progn (define-condition ,typename (,superclass) ())
          (setf (gethash ,code *error-table*) ',typename)))

;; macroexpand:
(progn (define-condition transaction-resolution-unknown (database-error) nil) (setf (gethash "08007" *error-table*) (quote transaction-resolution-unknown)))


[User]
Write a Common Lisp macro to handle this code pattern:
(failure NIL)

Problem: Macro call that should be transformed by fail

(failure NIL)

[Assistant]
(defmacro fail (form &optional (type 'error) description &rest format-args)
  `(eval-in-context
    *context*
    (make-instance 'comparison-result
                   :expression '(fail ,form ,type)
                   :value-form '(capture-error ,form)
                   :body (lambda () (capture-error ,form ,(maybe-unquote type)))
                   :expected ',(maybe-unquote type)
                   :comparison 'typep
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))

;; macroexpand:
(failure nil)


[User]
Define a macro that eliminates this repetitive pattern:
(flow-lambda-macro (flow-context) `(flet ((,test-fu () ,live-test-form)) (dispatch-repeatedly ,flow-context #',test-fu ,flow-list)))

Issue: Macro call that should be transformed by flow-lambda-macro

(flow-lambda-macro (flow-context) `(flet ((,test-fu () ,live-test-form)) (dispatch-repeatedly ,flow-context #',test-fu ,flow-list)))

[Assistant]
(defmacro flow-lambda-macro ((flow-context) &body body)
  `(with-gensyms (,flow-context)
     `(%flow-lambda (,,flow-context)
        ,,@body)))

;; macroexpand:
(with-gensyms (flow-context) (sb-int:quasiquote (%flow-lambda (#S(sb-impl::comma :expr flow-context :kind 0)) #S(sb-impl::comma :expr (sb-int:quasiquote (flet ((#S(sb-impl::comma :expr test-fu :kind 0) nil #S(sb-impl::comma :expr live-test-form :kind 0))) (dispatch-repeatedly #S(sb-impl::comma :expr flow-context :kind 0) (function #S(sb-impl::comma :expr test-fu :kind 0)) #S(sb-impl::comma :expr flow-list :kind 0)))) :kind 0))))


[User]
Write a Common Lisp macro to handle this code pattern:
(defsynonym :reducing :reduce)

Problem: Macro call that should be transformed by defsynonym

(defsynonym :reducing :reduce)

[Assistant]
(defmacro defsynonym (symbol synonym)
  "Set SYNONYM for a SYMBOL. "
  `(eval-always
     (setf (get ',symbol 'synonym) ',synonym)))

;; macroexpand:
(eval-always (setf (get (quote :reducing) (quote synonym)) (quote :reduce)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(with-interleaving `(with-interleaving ,@(loop for part in (rest form) collect (remove-bindings bindings part))))

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

(with-interleaving `(with-interleaving ,@(loop for part in (rest form) collect (remove-bindings bindings part))))

[Assistant]
(defmacro with-interleaving (&body body)
  (let* ((root (copy-list (pop body)))
         (current root))
    (dolist (form body root)
      (let ((form (copy-list form)))
        (when form
          (setf (cdr (last current)) (cons form NIL))
          (setf current form))))))

;; macroexpand:
(sb-int:quasiquote (with-interleaving #S(sb-impl::comma :expr (loop for part in (rest form) collect (remove-bindings bindings part)) :kind 2)))


[User]
Define a macro that eliminates this repetitive pattern:
(f nil
  (progn))

Issue: Macro call that should be transformed by F

(f nil
  (progn))

[Assistant]
(defmacro F ...)

;; macroexpand:
(lambda () (progn))


[User]
Define a macro that eliminates this repetitive pattern:
(enable-readtime-wrapper-syntax nil (progn))

Issue: Macro call that should be transformed by ENABLE-READTIME-WRAPPER-SYNTAX

(enable-readtime-wrapper-syntax nil (progn))

[Assistant]
(defmacro ENABLE-READTIME-WRAPPER-SYNTAX ...)

;; macroexpand:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-readtime-wrapper-syntax-in-readtable nil (progn))
  (values))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(quasiquote-expand-1 'list (butlast x))

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

(quasiquote-expand-1 'list (butlast x))

[Assistant]
(defmacro quasiquote (x) (quasiquote-expand x))

;; macroexpand:
(quasiquote-expand-1 (quote list) (butlast x))


[User]
Write a Common Lisp macro to handle this code pattern:
(defsynonym :with with)

Problem: Macro call that should be transformed by defsynonym

(defsynonym :with with)

[Assistant]
(defmacro defsynonym (symbol synonym)
  "Set SYNONYM for a SYMBOL. "
  `(eval-always
     (setf (get ',symbol 'synonym) ',synonym)))

;; macroexpand:
(eval-always (setf (get (quote :with) (quote synonym)) (quote with)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(defstore example (a &optional (b (the real (compute-default a))) (c (the real (1+ b)))))

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

(defstore example (a &optional (b (the real (compute-default a))) (c (the real (1+ b)))))

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

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (defun a-init-function152 (a) (declare (ignorable a)) (the real (compute-default a))) (defun b-init-function154 (a b #:b?160) (declare (ignorable a b #:b?160)) (the real (1+ b))) (ensure-store (quote example) (quote (a &optional (b (the real (a-init-function152 a)) #:b?160) (c (the real (b-init-function154 a b #:b?160)) #:c?161))))))


[User]
Generate a defmacro form that transforms code like this:
(-<>> 'some-name)

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

(-<>> 'some-name)

[Assistant]
(defmacro -<>> ...)

;; macroexpand:
'some-name


[User]
Create a Common Lisp macro for the following transformation. Before code:
(action (:traverse node-application node bound-variables) (unless (tracked-variable-p (node-application-rator node) bound-variables) (funcall *traverse* (node-application-rator node) bound-variables)) (loop :for rand :in (node-application-rands node) :do (funcall *traverse* rand bound-variables)) (traverse-keyword-rands (node-application-keyword-rands node) bound-variables) node)

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

(action (:traverse node-application node bound-variables) (unless (tracked-variable-p (node-application-rator node) bound-variables) (funcall *traverse* (node-application-rator node) bound-variables)) (loop :for rand :in (node-application-rands node) :do (funcall *traverse* rand bound-variables)) (traverse-keyword-rands (node-application-keyword-rands node) bound-variables) node)

[Assistant]
(defmacro action ((when type &rest args) &body body)
  "Construct an action block, turning `body` into a lambda function
accepting `args` if `args` are provided. If there are no `args`, then
`body` is assumed to be a function object and is used directly with
`when` and `type` to create an `action` instance. Otherwise, the first
argument in `args` is declared to be a node of type `type`, and the
`args` and `body` are used to generate a lambda function."
  (check-type when keyword)
  (check-type type symbol)
  (assert (subtypep type 'node))
  (assert (or (not (endp args)) (= 1 (length body))))
  (if (endp args)
      `(make-action ',when ',type ,@body)
      `(make-action ',when ',type
                    (lambda (,@args)
                      (declare (type ,type ,(first args)))
                      ,@body))))

;; macroexpand:
(make-action (quote :traverse) (quote node-application) (lambda (node bound-variables) (declare (type node-application node)) (unless (tracked-variable-p (node-application-rator node) bound-variables) (funcall *traverse* (node-application-rator node) bound-variables)) (loop :for rand :in (node-application-rands node) :do (funcall *traverse* rand bound-variables)) (traverse-keyword-rands (node-application-keyword-rands node) bound-variables) node))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(ps-doc
  'some-name)

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

(ps-doc
  'some-name)

[Assistant]
(defmacro PS-DOC ...)

;; macroexpand:
"'someName';"


[User]
Create a Common Lisp macro for the following transformation. Before code:
(ƒ→ nil nil)

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

(ƒ→ nil nil)

[Assistant]
(defmacro Ƒ→ ...)

;; macroexpand:
(defn nil nil (&optional α)
      (let ((α (or α t)))
        (cond)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(define-cruft %unassociate-name-from-readtable (name readtable) "Remove the association between NAME and READTABLE" #+ :allegro (let ((n (readtable-name-for-allegro name))) (assert (eq readtable (excl:named-readtable n))) (setf (excl:named-readtable n) nil)) #+ :common-lisp (progn (assert (eq readtable (gethash name *named-readtables*))) (remhash name *named-readtables*)))

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

(define-cruft %unassociate-name-from-readtable (name readtable) "Remove the association between NAME and READTABLE" #+ :allegro (let ((n (readtable-name-for-allegro name))) (assert (eq readtable (excl:named-readtable n))) (setf (excl:named-readtable n) nil)) #+ :common-lisp (progn (assert (eq readtable (gethash name *named-readtables*))) (remhash name *named-readtables*)))

[Assistant]
(defmacro define-cruft (name lambda-list &body (docstring . alternatives))
  (assert (typep docstring 'string) (docstring) "Docstring missing!")
  (assert (not (null alternatives)))
  `(progn
     (declaim (inline ,name))
     (defun ,name ,lambda-list ,docstring ,(first alternatives))))

;; macroexpand:
(progn (declaim (inline %unassociate-name-from-readtable)) (defun %unassociate-name-from-readtable (name readtable) "Remove the association between NAME and READTABLE" (progn (assert (eq readtable (gethash name *named-readtables*))) (remhash name *named-readtables*))))


[User]
Generate a defmacro form that transforms code like this:
(-> :tag-2 ((a b)) (concatenate 'string a b " World!"))

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

(-> :tag-2 ((a b)) (concatenate 'string a b " World!"))

[Assistant]
(defmacro -> (invariant &body args)
  "See flow:atomically"
  `(atomically ,invariant ,@args))

;; macroexpand:
(atomically :tag-2 ((a b)) (concatenate (quote string) a b " World!"))


[User]
Generate a defmacro form that transforms code like this:
(without-package-lock (:common-lisp #+lispworks :implementation) (defmethod documentation ((name symbol) (doc-type (eql 'readtable))) (let ((readtable (find-readtable name))) (and readtable (gethash readtable *readtable-to-docstring*)))) (defmethod documentation ((readtable readtable) (doc-type (eql 'readtable))) (gethash readtable *readtable-to-docstring*)) (defmethod (setf documentation) (docstring (name symbol) (doc-type (eql 'readtable))) (let ((readtable (find-readtable name))) (unless readtable (error 'readtable-does-not-exist :readtable-name name)) (setf (gethash readtable *readtable-to-docstring*) docstring))) (defmethod (setf documentation) (docstring (readtable readtable) (doc-type (eql 'readtable))) (setf (gethash readtable *readtable-to-docstring*) docstring)))

Pattern to recognize: Macro call that should be transformed by without-package-lock

(without-package-lock (:common-lisp #+lispworks :implementation) (defmethod documentation ((name symbol) (doc-type (eql 'readtable))) (let ((readtable (find-readtable name))) (and readtable (gethash readtable *readtable-to-docstring*)))) (defmethod documentation ((readtable readtable) (doc-type (eql 'readtable))) (gethash readtable *readtable-to-docstring*)) (defmethod (setf documentation) (docstring (name symbol) (doc-type (eql 'readtable))) (let ((readtable (find-readtable name))) (unless readtable (error 'readtable-does-not-exist :readtable-name name)) (setf (gethash readtable *readtable-to-docstring*) docstring))) (defmethod (setf documentation) (docstring (readtable readtable) (doc-type (eql 'readtable))) (setf (gethash readtable *readtable-to-docstring*) docstring)))

[Assistant]
(defmacro without-package-lock ((&rest package-names) &body body)
  (declare (ignorable package-names))
  #+clisp
  (return-from without-package-lock
    `(ext:without-package-lock (,@package-names) ,@body))
  #+lispworks
  (return-from without-package-lock
    `(let ((hcl:*packages-for-warn-on-redefinition*
             (set-difference hcl:*packages-for-warn-on-redefinition*
                             '(,@package-names)
                             :key (lambda (package-designator)
                                    (if (packagep package-designator)
                                        (package-name package-designator)
                                        package-designator))
                             :test #'string=)))
       ,@body))
  `(progn ,@body))

;; macroexpand:
(progn (defmethod documentation ((name symbol) (doc-type (eql (quote readtable)))) (let ((readtable (find-readtable name))) (and readtable (gethash readtable *readtable-to-docstring*)))) (defmethod documentation ((readtable readtable) (doc-type (eql (quote readtable)))) (gethash readtable *readtable-to-docstring*)) (defmethod (setf documentation) (docstring (name symbol) (doc-type (eql (quote readtable)))) (let ((readtable (find-readtable name))) (unless readtable (error (quote readtable-does-not-exist) :readtable-name name)) (setf (gethash readtable *readtable-to-docstring*) docstring))) (defmethod (setf documentation) (docstring (readtable readtable) (doc-type (eql (quote readtable)))) (setf (gethash readtable *readtable-to-docstring*) docstring)))


[User]
Generate a defmacro form that transforms code like this:
(with-component-testers (a b #'pathname-type) (components-are-member '(nil :wild :unspecific)) (components-are-string=))

Pattern to recognize: Macro call that should be transformed by with-component-testers

(with-component-testers (a b #'pathname-type) (components-are-member '(nil :wild :unspecific)) (components-are-string=))

[Assistant]
(defmacro with-component-testers ((a b key) &body body)
  (let ((k (gensym)))
    `(let* ((,k ,key)
            (,a (funcall ,k ,a))
            (,b (funcall ,k ,b)))
       (labels ((components-are (test)
                  (and (funcall test ,a) (funcall test ,b)))
                (components-are-member (values)
                  (and (member ,a values :test #'eql)
                       (member ,b values :test #'eql)
                       (eql ,a ,b)))
                (components-are-string= ()
                  (and (stringp ,a) (stringp ,b) (string= ,a ,b)))
                (components-are-every (test)
                  (and (consp ,a)
                       (consp ,b)
                       (every test ,a ,b))))
         (declare (ignorable #'components-are #'components-are-member
                             #'components-are-string= #'components-are-every))
         (if (or ,@body)
             (values t ,a ,b)
             nil)))))

;; macroexpand:
(let* ((#:g147 (function pathname-type)) (a (funcall #:g147 a)) (b (funcall #:g147 b))) (labels ((components-are (test) (and (funcall test a) (funcall test b))) (components-are-member (values) (and (member a values :test (function eql)) (member b values :test (function eql)) (eql a b))) (components-are-string= nil (and (stringp a) (stringp b) (string= a b))) (components-are-every (test) (and (consp a) (consp b) (every test a b)))) (declare (ignorable (function components-are) (function components-are-member) (function components-are-string=) (function components-are-every))) (if (or (components-are-member (quote (nil :wild :unspecific))) (components-are-string=)) (values t a b) nil)))


[User]
Generate a defmacro form that transforms code like this:
(c? (when (kv-collector self) (funcall (kv-collector self) (^value))))

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

(c? (when (kv-collector self) (funcall (kv-collector self) (^value))))

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

;; macroexpand:
(make-c-dependent :code (quote ((when (kv-collector self) (funcall (kv-collector self) (^value))))) :value-state :unevaluated :rule (c-lambda (when (kv-collector self) (funcall (kv-collector self) (^value)))))


[User]
Define a macro that eliminates this repetitive pattern:
(deferror "23001" restrict-violation integrity-violation)

Issue: Macro call that should be transformed by deferror

(deferror "23001" restrict-violation integrity-violation)

[Assistant]
(defmacro deferror (code typename &optional (superclass 'database-error))
  `(progn (define-condition ,typename (,superclass) ())
          (setf (gethash ,code *error-table*) ',typename)))

;; macroexpand:
(progn (define-condition restrict-violation (integrity-violation) nil) (setf (gethash "23001" *error-table*) (quote restrict-violation)))


[User]
Write a Common Lisp macro to handle this code pattern:
(undefreply nil)

Problem: Macro call that should be transformed by UNDEFREPLY

(undefreply nil)

[Assistant]
(defmacro UNDEFREPLY ...)

;; macroexpand:
(undefine-reply 'nil :qualifiers 'nil :participants `nil)


[User]
Generate a defmacro form that transforms code like this:
(when (node-slot shared) (make-proxy shared comma))

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

(when (node-slot shared) (make-proxy shared comma))

[Assistant]
(defmacro when (test &body forms)
  `(if ,test
	   ,(cl:if (cadr forms)
			   `(progn ,@forms)
			   (car forms))))

;; macroexpand:
(if (node-slot shared) (make-proxy shared comma))


[User]
Write a Common Lisp macro to handle this code pattern:
(keep-bops nil)

Problem: Macro call that should be transformed by KEEP-BOPS

(keep-bops nil)

[Assistant]
(defmacro KEEP-BOPS ...)

;; macroexpand:
(eval-when (:load-toplevel :compile-toplevel :execute)
  (progn
   (init-binfix)
   (unless nil
     (setq *binfix*
             (delete nil
                     (mapcar
                      (lambda (bs)
                        (setq bs
                                (delete-if
                                 (lambda (b)
                                   (unless (member (car b) '(nil))
                                     (remprop (car b) 'properties)
                                     t))
                                 bs)))
                      *binfix*)))
     (assign-properties))))


[User]
Write a Common Lisp macro to handle this code pattern:
(match0 (remove nil (list (hyphened) (concname) (nameonly))) ((list sym) sym) ((list) nil) (readers (ambiguous-slot-error "Multiple candidates of the accessor function: ~{~a~^, ~}" readers)))

Problem: Macro call that should be transformed by match0

(match0 (remove nil (list (hyphened) (concname) (nameonly))) ((list sym) sym) ((list) nil) (readers (ambiguous-slot-error "Multiple candidates of the accessor function: ~{~a~^, ~}" readers)))

[Assistant]
(defmacro match0 (*what* &body clauses &environment *env*)
  (once-only (*what*)
    (parse-patterns clauses)))

;; macroexpand:
(let ((#:*what*158 (remove nil (list (hyphened) (concname) (nameonly))))) (declare (ignorable #:*what*158)) (if (and (consp #:*what*158) (let ((#:*what*159 (car #:*what*158))) (declare (ignorable #:*what*159)) t) (let ((#:*what*160 (cdr #:*what*158))) (declare (ignorable #:*what*160)) (equal #:*what*160 nil))) (let* ((#:*what*159 (car #:*what*158)) (sym #:*what*159) (#:*what*160 (cdr #:*what*158))) (declare (ignorable #:*what*160 sym #:*what*159)) sym) (if (null #:*what*158) (let* nil (declare (ignorable)) nil) (if t (let* ((readers #:*what*158)) (declare (ignorable readers)) (ambiguous-slot-error "Multiple candidates of the accessor function: ~{~a~^, ~}" readers)) nil))))


[User]
Generate a defmacro form that transforms code like this:
(*let nil
  nil)

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

(*let nil
  nil)

[Assistant]
(defmacro *LET ...)

;; macroexpand:
(let* ()
  nil)


[User]
Define a macro that eliminates this repetitive pattern:
(define-custom-var (:object-value *object-value-handler*))

Issue: Macro call that should be transformed by define-custom-var

(define-custom-var (:object-value *object-value-handler*))

[Assistant]
(defmacro define-custom-var ((key name) &rest other-args)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (progn (pushnew '(,name . ,key) *custom-vars* :test #'equal)
            (defvar ,name ,@other-args))))

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (pushnew (quote (*object-value-handler* . :object-value)) *custom-vars* :test (function equal)) (defvar *object-value-handler*)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(assert-values ("deleted foo") (foo 'nothing) (foo+1 'nothing) (bar 2) (bar-1 1))

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

(assert-values ("deleted foo") (foo 'nothing) (foo+1 'nothing) (bar 2) (bar-1 1))

[Assistant]
(defmacro assert-values ((desc) &body objects-and-values)
  `(progn
     (trc ,desc)
     ,@(loop for (obj val) in objects-and-values
	    collect `(assert (eql (value ,obj) ,val)))))

;; macroexpand:
(progn (trc "deleted foo") (assert (eql (value foo) (quote nothing))) (assert (eql (value foo+1) (quote nothing))) (assert (eql (value bar) 2)) (assert (eql (value bar-1) 1)))


[User]
Define a macro that eliminates this repetitive pattern:
(λλ)

Issue: Macro call that should be transformed by ΛΛ

(λλ)

[Assistant]
(defmacro ΛΛ ...)

;; macroexpand:
(lambda (&optional α) (cond))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(collect-product 'some-name)

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

(collect-product 'some-name)

[Assistant]
(defmacro COLLECT-PRODUCT ...)

;; macroexpand:
(common-lisp:let* ((#:generator-131 (generator 'some-name))
                   #:numbers-127
                   (#:mul-128 1))
  (declare (type generator #:generator-131)
           (type number #:mul-128))
  (tagbody
   #:ll-132
    (setq #:numbers-127 (next-in #:generator-131 (go end)))
    (setq #:mul-128 (* #:mul-128 #:numbers-127))
    (go #:ll-132)
   end)
  #:mul-128)


[User]
Write a Common Lisp macro to handle this code pattern:
(do-notation bind-maybe ((sum nothing) (str (maybe->string sum))) (print str))

Problem: Macro call that should be transformed by do-notation

(do-notation bind-maybe ((sum nothing) (str (maybe->string sum))) (print str))

[Assistant]
(defmacro do-notation (bind-function expressions &body body)
  "Given a BIND-FUNCTION and all the bind expressions, evaluate BODY."
  `(progn
     ,@(reduce (lambda (acc do-binding)
		 (append `((,bind-function (lambda (,(car do-binding)) ,@acc)
					   ,@(cdr do-binding)))))
	       (reverse expressions)
	       :initial-value body)))

;; macroexpand:
(progn (bind-maybe (lambda (sum) (bind-maybe (lambda (str) (print str)) (maybe->string sum))) nothing))


[User]
Define a macro that eliminates this repetitive pattern:
(action (:after node-variable node bound-variables) (when (and (eq name (node-variable-value node)) (not (member name bound-variables :test #'eq))) (copy-node value (node-type node))))

Issue: Macro call that should be transformed by action

(action (:after node-variable node bound-variables) (when (and (eq name (node-variable-value node)) (not (member name bound-variables :test #'eq))) (copy-node value (node-type node))))

[Assistant]
(defmacro action ((when type &rest args) &body body)
  "Construct an action block, turning `body` into a lambda function
accepting `args` if `args` are provided. If there are no `args`, then
`body` is assumed to be a function object and is used directly with
`when` and `type` to create an `action` instance. Otherwise, the first
argument in `args` is declared to be a node of type `type`, and the
`args` and `body` are used to generate a lambda function."
  (check-type when keyword)
  (check-type type symbol)
  (assert (subtypep type 'node))
  (assert (or (not (endp args)) (= 1 (length body))))
  (if (endp args)
      `(make-action ',when ',type ,@body)
      `(make-action ',when ',type
                    (lambda (,@args)
                      (declare (type ,type ,(first args)))
                      ,@body))))

;; macroexpand:
(make-action (quote :after) (quote node-variable) (lambda (node bound-variables) (declare (type node-variable node)) (when (and (eq name (node-variable-value node)) (not (member name bound-variables :test (function eq)))) (copy-node value (node-type node)))))


[User]
Generate a defmacro form that transforms code like this:
(defsynonym next :next)

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

(defsynonym next :next)

[Assistant]
(defmacro defsynonym (symbol synonym)
  "Set SYNONYM for a SYMBOL. "
  `(eval-always
     (setf (get ',symbol 'synonym) ',synonym)))

;; macroexpand:
(eval-always (setf (get (quote next) (quote synonym)) (quote :next)))


[User]
Write a Common Lisp macro to handle this code pattern:
(count-of nil
  (progn))

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

(count-of nil
  (progn))

[Assistant]
(defmacro COUNT-OF ...)

;; macroexpand:
(lc (nil (progn)) count)


[User]
Create a Common Lisp macro for the following transformation. Before code:
(with-cached-reader-conditionals)

What needs to change: Macro call that should be transformed by WITH-CACHED-READER-CONDITIONALS

(with-cached-reader-conditionals)

[Assistant]
(defmacro WITH-CACHED-READER-CONDITIONALS ...)

;; macroexpand:
(call-with-cached-reader-conditionals (lambda ()))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(*> (char #\\) (alt (<$ #\newline (char #\n)) (<$ #\tab (char #\t)) (<$ #\return (char #\r)) (<$ #\backspace (char #\b)) (<$ #\page (char #\f))))

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

(*> (char #\\) (alt (<$ #\newline (char #\n)) (<$ #\tab (char #\t)) (<$ #\return (char #\r)) (<$ #\backspace (char #\b)) (<$ #\page (char #\f))))

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

;; macroexpand:
(lambda (#:*>-offset197) (multiple-value-bind (#:*>-res198 #:*>-next199) (funcall (char #\REVERSE_SOLIDUS) #:*>-offset197) (if (ok? #:*>-res198) (funcall (alt (<$ #\Newline (char #\LATIN_SMALL_LETTER_N)) (<$ #\Tab (char #\LATIN_SMALL_LETTER_T)) (<$ #\Return (char #\LATIN_SMALL_LETTER_R)) (<$ #\Backspace (char #\LATIN_SMALL_LETTER_B)) (<$ #\Page (char #\LATIN_SMALL_LETTER_F))) #:*>-next199) (fail #:*>-next199))))


[User]
Write a Common Lisp macro to handle this code pattern:
(some-<>>)

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

(some-<>>)

[Assistant]
(defmacro SOME-<>> ...)

;; macroexpand:
nil


[User]
Create a Common Lisp macro for the following transformation. Before code:
(c? (1+ (^m-cyc2-a)))

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

(c? (1+ (^m-cyc2-a)))

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

;; macroexpand:
(make-c-dependent :code (quote ((1+ (^m-cyc2-a)))) :value-state :unevaluated :rule (c-lambda (1+ (^m-cyc2-a))))


[User]
Define a macro that eliminates this repetitive pattern:
(with-yield-binds (if (cdr (conjunctive-op-expressions op)) (format nil (format nil "(~~{~~A~~^ ~A ~~})" (sql-op-name op)) (mapcar #'yield (conjunctive-op-expressions op))) (yield (car (conjunctive-op-expressions op)))))

Issue: Macro call that should be transformed by with-yield-binds

(with-yield-binds (if (cdr (conjunctive-op-expressions op)) (format nil (format nil "(~~{~~A~~^ ~A ~~})" (sql-op-name op)) (mapcar #'yield (conjunctive-op-expressions op))) (yield (car (conjunctive-op-expressions op)))))

[Assistant]
(defmacro with-yield-binds (&body body)
  `(let ((*bind-values* nil)
         (*use-global-bind-values* t))
     (values
      (progn ,@body)
      (loop for bind in (reverse *bind-values*)
            append bind))))

;; macroexpand:
(let ((*bind-values* nil) (*use-global-bind-values* t)) (values (progn (if (cdr (conjunctive-op-expressions op)) (format nil (format nil "(~~{~~A~~^ ~A ~~})" (sql-op-name op)) (mapcar (function yield) (conjunctive-op-expressions op))) (yield (car (conjunctive-op-expressions op))))) (loop for bind in (reverse *bind-values*) append bind)))


[User]
Write a Common Lisp macro to handle this code pattern:
(parse-conjunctive-clauses client instance t)

Problem: Macro call that should be transformed by parse-conjunctive-clauses

(parse-conjunctive-clauses client instance t)

[Assistant]
(defmacro parse-conjunctive-clauses (client region read-name-p &rest args)
  (with-unique-names (clauses next)
    `(prog (,clauses)
      ,next
        (push (do-parse-clause ,client ,region *index* ,read-name-p ,@args)
              ,clauses)
        (when (maybe-parse-token :keywords '(:and))
          (go ,next))
        (return (nreverse ,clauses)))))

;; macroexpand:
(prog (#:clauses122) #:next123 (push (do-parse-clause client instance *index* t) #:clauses122) (when (maybe-parse-token :keywords (quote (:and))) (go #:next123)) (return (nreverse #:clauses122)))


[User]
Define a macro that eliminates this repetitive pattern:
(f nil
  nil)

Issue: Macro call that should be transformed by F

(f nil
  nil)

[Assistant]
(defmacro F ...)

;; macroexpand:
(lambda () nil)


[User]
Generate a defmacro form that transforms code like this:
(special-symbol-progv nil
    (progn))

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

(special-symbol-progv nil
    (progn))

[Assistant]
(defmacro SPECIAL-SYMBOL-PROGV ...)

;; macroexpand:
(let (#:symbol-list178)
  (tagbody
   #:retry179
    (setq #:symbol-list178 nil)
    (unless (every #'special-symbol-p #:symbol-list178)
      (cerror "Retry to rebind the place(s)."
              "Attempt at rebinding one or more non-special places: ~S" 'nil)
      (go #:retry179)))
  (dynamic-progv #:symbol-list178
      (progn)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defmacro* nil
    :key
  nil)

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

(defmacro* nil
    :key
  nil)

[Assistant]
(defmacro DEFMACRO* ...)

;; macroexpand:
(defmacro nil :key
  `(with-yield
     ,nil))


[User]
Write a Common Lisp macro to handle this code pattern:
(c-assert (or (null (fm-parent kid)) (eql fm-parent (fm-parent kid))))

Problem: Macro call that should be transformed by c-assert

(c-assert (or (null (fm-parent kid)) (eql fm-parent (fm-parent kid))))

[Assistant]
(defmacro c-assert (assertion &optional places fmt$ &rest fmt-args)
  (declare (ignorable assertion places fmt$ fmt-args))
   #+(or)`(progn)
  `(unless *stop*
     (unless ,assertion
       ,(if fmt$
            `(c-break ,fmt$ ,@fmt-args)
          `(c-break "failed assertion: ~a" ',assertion)))))

;; macroexpand:
(unless *stop* (unless (or (null (fm-parent kid)) (eql fm-parent (fm-parent kid))) (c-break "failed assertion: ~a" (quote (or (null (fm-parent kid)) (eql fm-parent (fm-parent kid)))))))


[User]
Write a Common Lisp macro to handle this code pattern:
(odig nil)

Problem: Macro call that should be transformed by ODIG

(odig nil)

[Assistant]
(defmacro ODIG ...)

;; macroexpand:
(odig 1 nil)


[User]
Define a macro that eliminates this repetitive pattern:
(when (first in-decl) (pop in-decl-item))

Issue: Macro call that should be transformed by when

(when (first in-decl) (pop in-decl-item))

[Assistant]
(defmacro when (test &body forms)
  `(if ,test
	   ,(cl:if (cadr forms)
			   `(progn ,@forms)
			   (car forms))))

;; macroexpand:
(if (first in-decl) (pop in-decl-item))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(resolve
  'some-name)

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

(resolve
  'some-name)

[Assistant]
(defmacro RESOLVE ...)

;; macroexpand:
(locally
 (declare)
 (multiple-value-bind (#:assignment155 #:unified-p156)
     (type-unify 'nil 'nil (list))
   (assert #:unified-p156 nil 'simple-type-error :format-control
           "gtypes failed to unify to the actual types:~% ~a~%    against~% ~a"
           :format-arguments (list 'nil (list)))
   (let ()
     (declare (ignorable))
     'some-name)))


[User]
Write a Common Lisp macro to handle this code pattern:
(defun/1 getchar () (getc stdin))

Problem: Macro call that should be transformed by defun/1

(defun/1 getchar () (getc stdin))

[Assistant]
(defmacro defun/1 (name arglist &body body)
  "Lisp-1 defun; makes function pointers work."
  `(progn
     (defun ,name ,arglist
       (declare (optimize (speed 0) (debug 3)
                          ;; FIXME: Why do minor warnings result in load errors?
                          #+sbcl (sb-ext:inhibit-warnings 3)))

       ,@body)
     (defparameter ,name (vacietis.c:mkptr& (symbol-function ',name)))))

;; macroexpand:
(progn (defun getchar nil (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (getc stdin)) (defparameter getchar (vacietis.c:mkptr& (symbol-function (quote getchar)))))


[User]
Define a macro that eliminates this repetitive pattern:
(def$frame nil :key nil)

Issue: Macro call that should be transformed by DEF$FRAME

(def$frame nil :key nil)

[Assistant]
(defmacro DEF$FRAME ...)

;; macroexpand:
(def$flavor nil :key nil)


[User]
Write a Common Lisp macro to handle this code pattern:
(with-wrap-attempt () name (define-foreign-type name (make-instance 'foreign-alias :name name :type (ensure-type type "alias of type ~S to ~S" type name))))

Problem: Macro call that should be transformed by with-wrap-attempt

(with-wrap-attempt () name (define-foreign-type name (make-instance 'foreign-alias :name name :type (ensure-type type "alias of type ~S to ~S" type name))))

[Assistant]
(defmacro with-wrap-attempt ((&optional format-control &rest format-args) wrappable-name &body body)
  `(call-with-wrap-attempt ,wrappable-name (lambda () ,@body) ,format-control (list ,@format-args)))

;; macroexpand:
(call-with-wrap-attempt name (lambda nil (define-foreign-type name (make-instance (quote foreign-alias) :name name :type (ensure-type type "alias of type ~S to ~S" type name)))) nil (list))


[User]
Generate a defmacro form that transforms code like this:
(define-alias-binding append appending)

Pattern to recognize: Macro call that should be transformed by define-alias-binding

(define-alias-binding append appending)

[Assistant]
(defmacro define-alias-binding (name referenced-binding-name)
  `(progn (setf (binding ',name) ',referenced-binding-name)
          ',name))

;; macroexpand:
(progn (setf (binding (quote append)) (quote appending)) (quote append))


[User]
Generate a defmacro form that transforms code like this:
(define-direct-binding over (var iterable &rest iterator-args) (let ((iterator (gensym "ITERATOR")) (next (gensym "NEXT")) (has-more (gensym "HAS-MORE")) (update (gensym "UPDATE")) (end (gensym "END"))) (values `(with-interleaving (let (,@(lambda-fiddle:extract-lambda-vars (enlist var)) (,iterator (make-iterator ,iterable ,@iterator-args)))) (multiple-value-bind (,next ,has-more ,update ,end) (step-functions ,iterator) (declare (ignore ,update))) (unwind-protect* (funcall ,end))) `(if (funcall ,has-more) (update ,var (funcall ,next)) (end-for)))))

Pattern to recognize: Macro call that should be transformed by define-direct-binding

(define-direct-binding over (var iterable &rest iterator-args) (let ((iterator (gensym "ITERATOR")) (next (gensym "NEXT")) (has-more (gensym "HAS-MORE")) (update (gensym "UPDATE")) (end (gensym "END"))) (values `(with-interleaving (let (,@(lambda-fiddle:extract-lambda-vars (enlist var)) (,iterator (make-iterator ,iterable ,@iterator-args)))) (multiple-value-bind (,next ,has-more ,update ,end) (step-functions ,iterator) (declare (ignore ,update))) (unwind-protect* (funcall ,end))) `(if (funcall ,has-more) (update ,var (funcall ,next)) (end-for)))))

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

;; macroexpand:
(progn (setf (binding (quote over)) (lambda (var iterable &rest iterator-args) (let ((#:environment127 *environment*)) (declare (ignorable #:environment127)) (let ((iterator (gensym "ITERATOR")) (next (gensym "NEXT")) (has-more (gensym "HAS-MORE")) (update (gensym "UPDATE")) (end (gensym "END"))) (values (sb-int:quasiquote (with-interleaving (let (#S(sb-impl::comma :expr (lambda-fiddle:extract-lambda-vars (enlist var)) :kind 2) (#S(sb-impl::comma :expr iterator :kind 0) (make-iterator #S(sb-impl::comma :expr iterable :kind 0) #S(sb-impl::comma :expr iterator-args :kind 2))))) (multiple-value-bind (#S(sb-impl::comma :expr next :kind 0) #S(sb-impl::comma :expr has-more :kind 0) #S(sb-impl::comma :expr update :kind 0) #S(sb-impl::comma :expr end :kind 0)) (step-functions #S(sb-impl::comma :expr iterator :kind 0)) (declare (ignore #S(sb-impl::comma :expr update :kind 0)))) (unwind-protect* (funcall #S(sb-impl::comma :expr end :kind 0))))) (sb-int:quasiquote (if (funcall #S(sb-impl::comma :expr has-more :kind 0)) (update #S(sb-impl::comma :expr var :kind 0) (funcall #S(sb-impl::comma :expr next :kind 0))) (end-for)))))))) (quote over))


[User]
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 ->

(-> nil :key nil)

[Assistant]
(defmacro -> ...)

;; macroexpand:
(nil (:key nil))


[User]
Define a macro that eliminates this repetitive pattern:
(make-instance* 'class (a b c) (when t (list :x x)))

Issue: Macro call that should be transformed by make-instance*

(make-instance* 'class (a b c) (when t (list :x x)))

[Assistant]
(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)))))

;; macroexpand:
(apply (function make-instance) (quote class) :a a :b b :c c (when t (list :x x)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(define-case-aware-find-symbol find-pp-operator-name #:with-c-syntax.preprocess-operator)

What needs to change: Macro call that should be transformed by define-case-aware-find-symbol

(define-case-aware-find-symbol find-pp-operator-name #:with-c-syntax.preprocess-operator)

[Assistant]
(defmacro define-case-aware-find-symbol
    (finder-function-name package-name
     &key (upcased-package-name (format nil "~A.~A" (string package-name) '#:UPCASED))
       (docstring
        (format nil "Find a symbol in `~A' package having a same NAME. If not found, returns `nil'."
                package-name)))
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (defpackage ,upcased-package-name
       (:use)
       (:intern
        ,@(loop for sym being the external-symbol of package-name
                collect (string-upcase (symbol-name sym)))))
     ,@(loop for sym being the external-symbol of package-name
             for upcased = (string-upcase (symbol-name sym))
             collect `(setf (symbol-value (find-symbol ,upcased ',upcased-package-name))
                            ',sym))
     (defun ,finder-function-name (string &optional (readtable-case (readtable-case *readtable*)))
       ,@(if docstring `(,docstring))
       (ecase readtable-case
         ((:upcase :invert)
          (if-let ((up-sym (find-symbol string ',upcased-package-name)))
            (symbol-value up-sym)))
         ((:downcase :preserve)
          (find-symbol string ',package-name))))))

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (defpackage #A((41) base-char . "WITH-C-SYNTAX.PREPROCESS-OPERATOR.UPCASED") (:use) (:intern #A((7) base-char . "DEFINED") #A((7) base-char . "_PRAGMA"))) (setf (symbol-value (find-symbol #A((7) base-char . "DEFINED") (quote #A((41) base-char . "WITH-C-SYNTAX.PREPROCESS-OPERATOR.UPCASED")))) (quote with-c-syntax.preprocess-operator:|defined|)) (setf (symbol-value (find-symbol #A((7) base-char . "_PRAGMA") (quote #A((41) base-char . "WITH-C-SYNTAX.PREPROCESS-OPERATOR.UPCASED")))) (quote with-c-syntax.preprocess-operator:|_Pragma|)) (defun find-pp-operator-name (string &optional (readtable-case (readtable-case *readtable*))) #A((109) base-char . "Find a symbol in `WITH-C-SYNTAX.PREPROCESS-OPERATOR' package having a same NAME. If not found, returns `nil'.") (ecase readtable-case ((:upcase :invert) (if-let ((up-sym (find-symbol string (quote #A((41) base-char . "WITH-C-SYNTAX.PREPROCESS-OPERATOR.UPCASED"))))) (symbol-value up-sym))) ((:downcase :preserve) (find-symbol string (quote #:with-c-syntax.preprocess-operator))))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(*> (string "Mālum") (char #\,))

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

(*> (string "Mālum") (char #\,))

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

;; macroexpand:
(lambda (#:*>-offset203) (multiple-value-bind (#:*>-res204 #:*>-next205) (funcall (string "Mālum") #:*>-offset203) (if (ok? #:*>-res204) (funcall (char #\COMMA) #:*>-next205) (fail #:*>-next205))))


[User]
Write a Common Lisp macro to handle this code pattern:
(-<> nil :key nil)

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

(-<> nil :key nil)

[Assistant]
(defmacro -<> ...)

;; macroexpand:
(nil (:key nil))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(with-yield (dolist (x data) (yield x (1+ x))))

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

(with-yield (dolist (x data) (yield x (1+ x))))

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

;; macroexpand:
(let (#:g143 #:g144) (with-call/cc (labels ((yield (&rest values) (setf #:g144 values) (let/cc k (setf #:g143 k)))) (dolist (x data) (yield x (1+ x))) (setf #:g143 nil))) (gen-lambda nil (cond ((null #:g143) (quote generator-stop)) (t (let ((current #:g144)) (funcall #:g143 nil) (apply (function values) (funcall values-handler current)))))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(->>
  nil
  (progn))

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

(->>
  nil
  (progn))

[Assistant]
(defmacro ->> ...)

;; macroexpand:
(let* ((#:var185 nil) (#:var186 (progn #:var185)))
  #:var186)


[User]
Generate a defmacro form that transforms code like this:
(draw scene (:rect :x 0 :y 0 :height "100%" :width "100%") :fill (xlink-href pattern))

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

(draw scene (:rect :x 0 :y 0 :height "100%" :width "100%") :fill (xlink-href pattern))

[Assistant]
(defmacro draw (scene (shape &rest params) &rest opts)
  (let ((element (gensym)))
    `(let ((,element (funcall #'make-svg-element ,shape (append (list ,@params) (list ,@opts)))))
       (add-element ,scene ,element)
       ,element)))

;; macroexpand:
(let ((#:g154 (funcall (function make-svg-element) :rect (append (list :x 0 :y 0 :height "100%" :width "100%") (list :fill (xlink-href pattern)))))) (add-element scene #:g154) #:g154)


[User]
Write a Common Lisp macro to handle this code pattern:
(with-yield-binds (if *inside-insert-into* (apply #'format nil "(~{~A~^, ~}) VALUES (~{~A~^, ~})" (loop for (k v) on (set=-clause-args clause) by #'cddr collect (yield-arg k) into keys collect (yield-arg v) into values finally (return (list keys values)))) (format nil "SET ~{~A = ~A~^, ~}" (mapcar #'yield-arg (set=-clause-args clause)))))

Problem: Macro call that should be transformed by with-yield-binds

(with-yield-binds (if *inside-insert-into* (apply #'format nil "(~{~A~^, ~}) VALUES (~{~A~^, ~})" (loop for (k v) on (set=-clause-args clause) by #'cddr collect (yield-arg k) into keys collect (yield-arg v) into values finally (return (list keys values)))) (format nil "SET ~{~A = ~A~^, ~}" (mapcar #'yield-arg (set=-clause-args clause)))))

[Assistant]
(defmacro with-yield-binds (&body body)
  `(let ((*bind-values* nil)
         (*use-global-bind-values* t))
     (values
      (progn ,@body)
      (loop for bind in (reverse *bind-values*)
            append bind))))

;; macroexpand:
(let ((*bind-values* nil) (*use-global-bind-values* t)) (values (progn (if *inside-insert-into* (apply (function format) nil "(~{~A~^, ~}) VALUES (~{~A~^, ~})" (loop for (k v) on (set=-clause-args clause) by (function cddr) collect (yield-arg k) into keys collect (yield-arg v) into values finally (return (list keys values)))) (format nil "SET ~{~A = ~A~^, ~}" (mapcar (function yield-arg) (set=-clause-args clause))))) (loop for bind in (reverse *bind-values*) append bind)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defpattern alist (&rest args) `(and ,@(loop for (key . value) in args collect `(assoc ,key ,value))))

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

(defpattern alist (&rest args) `(and ,@(loop for (key . value) in args collect `(assoc ,key ,value))))

[Assistant]
(defmacro defpattern (name lambda-list &body body)
  "Defines a derived pattern specifier named NAME. This is analogous
to DEFTYPE.

Examples:

    ;; Defines a LIST pattern.
    (defpattern list (&rest args)
      (when args
        `(cons ,(car args) (list ,@(cdr args)))))"
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (pattern-expand-function ',name) (lambda ,lambda-list ,@body))))

;; macroexpand:
(%defpattern alist (quote &rest) (quote args) (lambda (quasiquote (and #S(sb-impl::comma :expr (loop for (key . value) in args collect (quasiquote (assoc #S(sb-impl::comma :expr key :kind 0) #S(sb-impl::comma :expr value :kind 0)))) :kind 2)))))


[User]
Define a macro that eliminates this repetitive pattern:
(mvlet nil
  :key
  nil)

Issue: Macro call that should be transformed by MVLET

(mvlet nil
  :key
  nil)

[Assistant]
(defmacro MVLET ...)

;; macroexpand:
(progn :key nil)


[User]
Create a Common Lisp macro for the following transformation. Before code:
(cond-> 'some-name)

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

(cond-> 'some-name)

[Assistant]
(defmacro COND-> ...)

;; macroexpand:
(let* ((#:|cond134| 'some-name))
  #:|cond134|)


[User]
Create a Common Lisp macro for the following transformation. Before code:
(xor nil nil nil)

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

(xor nil nil nil)

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

;; macroexpand:
(let (#:tmp147 #:true148) (declare (ignorable #:tmp147)) (block #:xor146 (if (setf #:tmp147 nil) (if #:true148 (return-from #:xor146 (values nil nil)) (setf #:true148 #:tmp147))) (if (setf #:tmp147 nil) (if #:true148 (return-from #:xor146 (values nil nil)) (setf #:true148 #:tmp147))) (if (setf #:tmp147 nil) (if #:true148 (return-from #:xor146 (values nil nil)) (setf #:true148 #:tmp147))) (return-from #:xor146 (values #:true148 t))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(deferror "55006" object-in-use object-state-error)

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

(deferror "55006" object-in-use object-state-error)

[Assistant]
(defmacro deferror (code typename &optional (superclass 'database-error))
  `(progn (define-condition ,typename (,superclass) ())
          (setf (gethash ,code *error-table*) ',typename)))

;; macroexpand:
(progn (define-condition object-in-use (object-state-error) nil) (setf (gethash "55006" *error-table*) (quote object-in-use)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(while nil
  (progn))

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

(while nil
  (progn))

[Assistant]
(defmacro WHILE ...)

;; macroexpand:
(loop while nil
      do (progn (progn)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(defclass/a dbd-mysql (dbi-driver) ())

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

(defclass/a dbd-mysql (dbi-driver) ())

[Assistant]
(defmacro defclass/a (name superclasses slots &rest class-options)
  `(progn
     (defclass ,name ,superclasses ,slots ,@class-options)
     (deftype ,(intern (format nil "<~A>" (symbol-name name))) () ',name)
     (setf (find-class ',(intern (format nil "<~A>" (symbol-name name))))
           (find-class ',name))))

;; macroexpand:
(progn (defclass dbd-mysql (dbi-driver) nil) (deftype <dbd-mysql> nil (quote dbd-mysql)) (setf (find-class (quote <dbd-mysql>)) (find-class (quote dbd-mysql))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(with-connection (execute (create-table :user ((id :type :bigint :primary-key t) (name :type '(:varchar 32)) (email :type '(:varchar 255)) (status :type '(:varchar 20)) (created_at :type :datetime) (updated_at :type :datetime)))) (execute (create-table :tweet ((id :type :bigint :primary-key t) (user_id :type :bigint) (body :type :text) (created_at :type :datetime)))) (execute (insert-into :user (set= :id 1 :name "nitro_idiot" :email "e.arrows@gmail.com" :status "normal" :created_at (princ-to-string *now*)))) (execute (insert-into :tweet (set= :id 1 :user_id 1 :body "Hi." :created_at (princ-to-string *now*)))) (execute (insert-into :tweet (set= :id 2 :user_id 1 :body "Is it working?" :created_at (princ-to-string *now*)))))

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

(with-connection (execute (create-table :user ((id :type :bigint :primary-key t) (name :type '(:varchar 32)) (email :type '(:varchar 255)) (status :type '(:varchar 20)) (created_at :type :datetime) (updated_at :type :datetime)))) (execute (create-table :tweet ((id :type :bigint :primary-key t) (user_id :type :bigint) (body :type :text) (created_at :type :datetime)))) (execute (insert-into :user (set= :id 1 :name "nitro_idiot" :email "e.arrows@gmail.com" :status "normal" :created_at (princ-to-string *now*)))) (execute (insert-into :tweet (set= :id 1 :user_id 1 :body "Hi." :created_at (princ-to-string *now*)))) (execute (insert-into :tweet (set= :id 2 :user_id 1 :body "Is it working?" :created_at (princ-to-string *now*)))))

[Assistant]
(defmacro with-connection (&body body)
  `(let ((*connection* (connect-cached :sqlite3 :database-name *db-path*)))
     ,@body))

;; macroexpand:
(let ((execute (connect (create-table :user ((id :type :bigint :primary-key t) (name :type (quote (:varchar 32))) (email :type (quote (:varchar 255))) (status :type (quote (:varchar 20))) (created_at :type :datetime) (updated_at :type :datetime)))))) (unwind-protect (progn (execute (create-table :tweet ((id :type :bigint :primary-key t) (user_id :type :bigint) (body :type :text) (created_at :type :datetime)))) (execute (insert-into :user (set= :id 1 :name "nitro_idiot" :email "e.arrows@gmail.com" :status "normal" :created_at (princ-to-string *now*)))) (execute (insert-into :tweet (set= :id 1 :user_id 1 :body "Hi." :created_at (princ-to-string *now*)))) (execute (insert-into :tweet (set= :id 2 :user_id 1 :body "Is it working?" :created_at (princ-to-string *now*))))) (disconnect execute)))


[User]
Define a macro that eliminates this repetitive pattern:
(gen-lambda-with-sticky-stop () (unless (cdr ldata) (get-next)) (setf ldata (cdr ldata)) (if (eq (car ldata) 'generator-stop) (sticky-stop) (apply #'values (ensure-list (car ldata)))))

Issue: Macro call that should be transformed by gen-lambda

(gen-lambda-with-sticky-stop () (unless (cdr ldata) (get-next)) (setf ldata (cdr ldata)) (if (eq (car ldata) 'generator-stop) (sticky-stop) (apply #'values (ensure-list (car ldata)))))

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

;; macroexpand:
(make-instance (quote basic-generator) :function (sticky-stop-lambda nil (unless (cdr ldata) (get-next)) (setf ldata (cdr ldata)) (if (eq (car ldata) (quote generator-stop)) (sticky-stop) (apply (function values) (ensure-list (car ldata))))))


[User]
Write a Common Lisp macro to handle this code pattern:
(let-syntax common-lisp:nil)

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

(let-syntax common-lisp:nil)

[Assistant]
(defmacro LET-SYNTAX ...)

;; macroexpand:
(common-lisp:progn)


[User]
Generate a defmacro form that transforms code like this:
(bind (((:struct metabang-bind-test-1- a c) (make-metabang-bind-test-1 :a 1 :b 2 :c 3))) (ensure-same '(4 1 3) (list values a c) :test 'equal))

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

(bind (((:struct metabang-bind-test-1- a c) (make-metabang-bind-test-1 :a 1 :b 2 :c 3))) (ensure-same '(4 1 3) (list values a c) :test 'equal))

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

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

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

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

;; macroexpand:
(let* ((#:|values-189| (make-metabang-bind-test-1 :a 1 :b 2 :c 3)) (a (metabang-bind-test-1-a #:|values-189|)) (c (metabang-bind-test-1-c #:|values-189|))) (declare (ignorable #:|values-189|)) (progn (ensure-same (quote (4 1 3)) (list values a c) :test (quote equal))))


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

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

(cond->
  nil
  nil)

[Assistant]
(defmacro COND-> ...)

;; macroexpand:
(let* ((#:var127 nil)
       (#:var128
        (if nil
            (->
              #:var127)
            #:var127)))
  #:var128)