[User]
You are a Common Lisp macro expert. Given this code pattern:
(defhandler catch (catch tag &rest body) `(list ',catch ,(e tag) ,@(e-list body)))

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

(defhandler catch (catch tag &rest body) `(list ',catch ,(e tag) ,@(e-list body)))

[Assistant]
(defmacro defhandler (symbol lambda-list &body body)
  (let ((syms (force-list symbol)))
    (let ((func (intern (format nil "~A~A" 'hander- (first syms)))))
      `(progn
         (defun ,func ,lambda-list
           ,@body)
         (setf
          ,@(loop for sym in syms
               collect `(gethash ',sym *form-handler*)
               collect `',func))))))

;; macroexpand:
(progn (defun hander-catch (catch tag &rest body) (sb-int:quasiquote (list (quote #S(sb-impl::comma :expr catch :kind 0)) #S(sb-impl::comma :expr (e tag) :kind 0) #S(sb-impl::comma :expr (e-list body) :kind 2)))) (setf (gethash (quote catch) *form-handler*) (quote hander-catch)))


[User]
Define a macro that eliminates this repetitive pattern:
(define-mustache-character #\> (make-instance 'partial-tag :text arg-text))

Issue: Macro call that should be transformed by define

(define-mustache-character #\> (make-instance 'partial-tag :text arg-text))

[Assistant]
(defmacro define (name template)
  "Define a named renderer of string TEMPLATE."
  `(setf (symbol-function ',name)
         (compile-template ,template)))

;; macroexpand:
(set-mustache-character #\GREATER-THAN_SIGN (lambda (raw-text arg-text escapep start end) (declare (ignorable raw-text arg-text escapep start end) (type simple-string raw-text arg-text) (boolean escapep) (offset start end)) (make-instance (quote partial-tag) :text arg-text)))


[User]
Define a macro that eliminates this repetitive pattern:
(defannotation annotation (options function-definition-form) (:arity 2) (let ((name (definition-form-symbol (progn-form-last function-definition-form)))) `(progn (set-annotation-options ',name ',options) ,function-definition-form)))

Issue: Macro call that should be transformed by defannotation

(defannotation annotation (options function-definition-form) (:arity 2) (let ((name (definition-form-symbol (progn-form-last function-definition-form)))) `(progn (set-annotation-options ',name ',options) ,function-definition-form)))

[Assistant]
(defmacro defannotation (name lambda-list options &body body)
  `(progn
     (set-annotation-options ',name ',options)
     (defmacro ,name ,lambda-list ,@body)))

;; macroexpand:
(progn (set-annotation-options (quote annotation) (quote (:arity 2))) (defmacro annotation (options function-definition-form) (let ((name (definition-form-symbol (progn-form-last function-definition-form)))) (sb-int:quasiquote (progn (set-annotation-options (quote #S(sb-impl::comma :expr name :kind 0)) (quote #S(sb-impl::comma :expr options :kind 0))) #S(sb-impl::comma :expr function-definition-form :kind 0))))))


[User]
Generate a defmacro form that transforms code like this:
(enable-sharp-number-syntax)

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

(enable-sharp-number-syntax)

[Assistant]
(defmacro ENABLE-SHARP-NUMBER-SYNTAX ...)

;; macroexpand:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-sharp-number-syntax-in-readtable)
  (values))


[User]
Generate a defmacro form that transforms code like this:
(define-bug no-args-remove-in-unrep-inlining () (func args args-code) " Sorry that you have hit this bug, if you have time please copy this error, your stack trace and (if possible) the code that triggered this error and raise an issue at https://github.com/cbaggers/varjo/issues Thankyou, and our apologies. ---- When trying to compile the function ~a we knew we had to inline as a local function to to one of the arguments being of an unrepresentable type. However No arguments were identified for moving from the function to the surrounding let. func: ~a args: ~a args-code: ~a " (slot-value func 'name) func args args-code)

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

(define-bug no-args-remove-in-unrep-inlining () (func args args-code) " Sorry that you have hit this bug, if you have time please copy this error, your stack trace and (if possible) the code that triggered this error and raise an issue at https://github.com/cbaggers/varjo/issues Thankyou, and our apologies. ---- When trying to compile the function ~a we knew we had to inline as a local function to to one of the arguments being of an unrepresentable type. However No arguments were identified for moving from the function to the surrounding let. func: ~a args: ~a args-code: ~a " (slot-value func 'name) func args args-code)

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

;; macroexpand:
(defcondition no-args-remove-in-unrep-inlining (:error-type varjo-error :prefix "Varjo Bug") (func args args-code) " Sorry that you have hit this bug, if you have time please copy this error, your stack trace and (if possible) the code that triggered this error and raise an issue at https://github.com/cbaggers/varjo/issues Thankyou, and our apologies. ---- When trying to compile the function ~a we knew we had to inline as a local function to to one of the arguments being of an unrepresentable type. However No arguments were identified for moving from the function to the surrounding let. func: ~a args: ~a args-code: ~a " (slot-value func (quote name)) func args args-code)


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

Problem: Macro call that should be transformed by DO-COMBINATIONS

(do-combinations 'some-name)

[Assistant]
(defmacro DO-COMBINATIONS ...)

;; macroexpand:
(progn)


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

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

(false NIL)

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

;; macroexpand:
(eval-in-context *context* (make-instance (quote comparison-result) :expression (quote (false nil)) :value-form (quote nil) :body (lambda nil nil) :expected (quote nil) :comparison (quote geq)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defjs map3() (emit this.name (ps:create :count 1)))

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

(defjs map3() (emit this.name (ps:create :count 1)))

[Assistant]
(defmacro defjs (name args &body body)
  "Define client side javascript. Works like defun; body is in lisp, with parenscript
   additions, like return. So (defjs hello (x y) (return (+ x y))) defines an adder.
   macro creates a lisp function which sends the javascript function over to the mongo
   server to be evaluated. Result is processed and returned to the reader.
   This will execute 10 times on the server :
   (mapcar (lambda (x) (hello 10 x)) (list 1 2 3 4 5 6 7 8 9 10))"
  `(let* ((js-body (parenscript:ps (lambda ,args ,@body))))
     (setf (gethash ',name *js-definitions*) js-body)
     (defun ,name ,args
       (get-element "retval" (car (docs (db.eval js-body ,@args)))))))

;; macroexpand:
(let* ((js-body (parenscript:ps (lambda nil (emit this.name (parenscript:create :count 1)))))) (setf (gethash (quote map3) *js-definitions*) js-body) (defun map3 nil (get-element "retval" (car (docs (db.eval js-body))))))


[User]
Define a macro that eliminates this repetitive pattern:
(define-error stage-order-error () (stage-type) "stage of type ~s is not valid at this place in the pipeline, this is either out of order or a stage of this type already exists" stage-type)

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

(define-error stage-order-error () (stage-type) "stage of type ~s is not valid at this place in the pipeline, this is either out of order or a stage of this type already exists" stage-type)

[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 stage-order-error (:error-type varjo-error :prefix "Varjo") (stage-type) "stage of type ~s is not valid at this place in the pipeline, this is either out of order or a stage of this type already exists" stage-type)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(c-assert fm-parent)

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

(c-assert fm-parent)

[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 fm-parent (c-break "failed assertion: ~a" (quote fm-parent))))


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

Issue: Macro call that should be transformed by LETV

(letv)

[Assistant]
(defmacro LETV ...)

;; macroexpand:
(block nil)


[User]
Generate a defmacro form that transforms code like this:
(define-error symbol-unidentified (:error-type varjo-critical-error) (sym) "Symbol '~s' is unidentified. ~@[However the symbol is valid in these stages: ~{~%- ~a~}~]" sym (mapcar #'string-downcase (mapcar #'string (find-stages-that-have-var sym))))

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

(define-error symbol-unidentified (:error-type varjo-critical-error) (sym) "Symbol '~s' is unidentified. ~@[However the symbol is valid in these stages: ~{~%- ~a~}~]" sym (mapcar #'string-downcase (mapcar #'string (find-stages-that-have-var sym))))

[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 symbol-unidentified (:error-type varjo-critical-error :prefix "Varjo") (sym) "Symbol '~s' is unidentified. ~@[However the symbol is valid in these stages: ~{~%- ~a~}~]" sym (mapcar (function string-downcase) (mapcar (function string) (find-stages-that-have-var sym))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defannotation doc (docstring definition-form) (:arity 2) "Add DOCSTRING documentation for DEFINITION-FORM." (progn-form-replace-last (lambda (definition-form) (case (definition-form-type definition-form) ((defvar defparameter defconstant defun defmethod defmacro deftype define-compiler-macro) (destructuring-bind (def name arg . body) definition-form `(,def ,name ,arg ,docstring ,@body))) ((defstruct) (destructuring-bind (def name-and-options . slots) definition-form `(,def ,name-and-options ,docstring ,@slots))) ((defclass define-condition) (destructuring-bind (def name supers slots . opts) definition-form (pushnew `(:documentation ,docstring) opts :key #'car) `(,def ,name ,supers ,slots ,@opts))) ((defgeneric) (destructuring-bind (def name args . opts) definition-form (pushnew `(:documentation ,docstring) opts :key #'car) `(,def ,name ,args ,@opts))) (t (error "Documentation not supported: ~a" definition-form)))) definition-form))

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

(defannotation doc (docstring definition-form) (:arity 2) "Add DOCSTRING documentation for DEFINITION-FORM." (progn-form-replace-last (lambda (definition-form) (case (definition-form-type definition-form) ((defvar defparameter defconstant defun defmethod defmacro deftype define-compiler-macro) (destructuring-bind (def name arg . body) definition-form `(,def ,name ,arg ,docstring ,@body))) ((defstruct) (destructuring-bind (def name-and-options . slots) definition-form `(,def ,name-and-options ,docstring ,@slots))) ((defclass define-condition) (destructuring-bind (def name supers slots . opts) definition-form (pushnew `(:documentation ,docstring) opts :key #'car) `(,def ,name ,supers ,slots ,@opts))) ((defgeneric) (destructuring-bind (def name args . opts) definition-form (pushnew `(:documentation ,docstring) opts :key #'car) `(,def ,name ,args ,@opts))) (t (error "Documentation not supported: ~a" definition-form)))) definition-form))

[Assistant]
(defmacro defannotation (name lambda-list options &body body)
  `(progn
     (set-annotation-options ',name ',options)
     (defmacro ,name ,lambda-list ,@body)))

;; macroexpand:
(progn (set-annotation-options (quote doc) (quote (:arity 2))) (defmacro doc (docstring definition-form) "Add DOCSTRING documentation for DEFINITION-FORM." (progn-form-replace-last (lambda (definition-form) (case (definition-form-type definition-form) ((defvar defparameter defconstant defun defmethod defmacro deftype define-compiler-macro) (destructuring-bind (def name arg . body) definition-form (sb-int:quasiquote (#S(sb-impl::comma :expr def :kind 0) #S(sb-impl::comma :expr name :kind 0) #S(sb-impl::comma :expr arg :kind 0) #S(sb-impl::comma :expr docstring :kind 0) #S(sb-impl::comma :expr body :kind 2))))) ((defstruct) (destructuring-bind (def name-and-options . slots) definition-form (sb-int:quasiquote (#S(sb-impl::comma :expr def :kind 0) #S(sb-impl::comma :expr name-and-options :kind 0) #S(sb-impl::comma :expr docstring :kind 0) #S(sb-impl::comma :expr slots :kind 2))))) ((defclass define-condition) (destructuring-bind (def name supers slots . opts) definition-form (pushnew (sb-int:quasiquote (:documentation #S(sb-impl::comma :expr docstring :kind 0))) opts :key (function car)) (sb-int:quasiquote (#S(sb-impl::comma :expr def :kind 0) #S(sb-impl::comma :expr name :kind 0) #S(sb-impl::comma :expr supers :kind 0) #S(sb-impl::comma :expr slots :kind 0) #S(sb-impl::comma :expr opts :kind 2))))) ((defgeneric) (destructuring-bind (def name args . opts) definition-form (pushnew (sb-int:quasiquote (:documentation #S(sb-impl::comma :expr docstring :kind 0))) opts :key (function car)) (sb-int:quasiquote (#S(sb-impl::comma :expr def :kind 0) #S(sb-impl::comma :expr name :kind 0) #S(sb-impl::comma :expr args :kind 0) #S(sb-impl::comma :expr opts :kind 2))))) (t (error "Documentation not supported: ~a" definition-form)))) definition-form)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(make-float-converters encode-float64 decode-float64 11 52 nil)

Write a macro that addresses: Macro call that should be transformed by make-float-converters

(make-float-converters encode-float64 decode-float64 11 52 nil)

[Assistant]
(defmacro make-float-converters (encoder-name
                                 decoder-name
                                 exponent-bits
                                 significand-bits
                                 support-nan-and-infinity-p)
  "Writes an encoder and decoder function for floating point
numbers with the given amount of exponent and significand
bits (plus an extra sign bit). If support-nan-and-infinity-p is
true, the decoders will also understand these special cases. NaN
is represented as :not-a-number, and the infinities as
:positive-infinity and :negative-infinity. Note that this means
that the in- or output of these functions is not just floating
point numbers anymore, but also keywords."
  (let* ((total-bits (+ 1 exponent-bits significand-bits))
         (exponent-offset (1- (expt 2 (1- exponent-bits)))) ; (A)
         (sign-part `(ldb (byte 1 ,(1- total-bits)) bits))
         (exponent-part `(ldb (byte ,exponent-bits ,significand-bits) bits))
         (significand-part `(ldb (byte ,significand-bits 0) bits))
         (nan support-nan-and-infinity-p)
         (max-exponent (1- (expt 2 exponent-bits)))) ; (B)
    `(progn
       (defun ,encoder-name (float)
         ,@(unless nan `((declare (type float float))))
         (multiple-value-bind (sign significand exponent)
             (cond ,@(when nan `(((eq float :not-a-number)
                                  (values 0 1 ,max-exponent))
                                 ((eq float :positive-infinity)
                                  (values 0 0 ,max-exponent))
                                 ((eq float :negative-infinity)
                                  (values 1 0 ,max-exponent))))
                   ((zerop float)
                    (values 0 0 0))
                   (t
                    (multiple-value-bind (significand exponent sign)
                        (decode-float float)
                      (let ((exponent (+ (1- exponent) ,exponent-offset))
                            (sign (if (= sign 1.0) 0 1)))
                        (unless (< exponent ,(expt 2 exponent-bits))
                          (error "Floating point overflow when encoding ~A."
                                 float))
                        (if (< exponent 0) ; (C)
                            (values sign (ash (round (* ,(expt 2 significand-bits)
                                                        significand))
                                              exponent)
                                    0)
                            (values sign (round (* ,(expt 2 significand-bits)
                                                   (1- (* significand 2))))
                                    exponent))))))
           (let ((bits 0))
             (declare (type (unsigned-byte ,total-bits) bits))
             (setf ,sign-part sign
                   ,exponent-part exponent
                   ,significand-part significand)
             bits)))

       (defun ,decoder-name (bits)
         (declare (type (unsigned-byte ,total-bits) bits))
         (let* ((sign ,sign-part)
                (exponent ,exponent-part)
                (significand ,significand-part))
           ,@(when nan `((when (= exponent ,max-exponent)
                           (return-from ,decoder-name
                             (cond ((not (zerop significand)) :not-a-number)
                                   ((zerop sign) :positive-infinity)
                                   (t :negative-infinity))))))
           (if (zerop exponent) ; (D)
               (setf exponent 1)
               (setf (ldb (byte 1 ,significand-bits) significand) 1))
           (unless (zerop sign)
             (setf significand (- significand)))
           (scale-float (float significand ,(if (> total-bits 32) 1.0d0 1.0))
                        (- exponent ,(+ exponent-offset significand-bits))))))))

;; macroexpand:
(progn (defun encode-float64 (float) (declare (type float float)) (multiple-value-bind (sign significand exponent) (cond ((zerop float) (values 0 0 0)) (t (multiple-value-bind (significand exponent sign) (decode-float float) (let ((exponent (+ (1- exponent) 1023)) (sign (if (= sign 1.0) 0 1))) (unless (< exponent 2048) (error "Floating point overflow when encoding ~A." float)) (if (< exponent 0) (values sign (ash (round (* 4503599627370496 significand)) exponent) 0) (values sign (round (* 4503599627370496 (1- (* significand 2)))) exponent)))))) (let ((bits 0)) (declare (type (unsigned-byte 64) bits)) (setf (ldb (byte 1 63) bits) sign (ldb (byte 11 52) bits) exponent (ldb (byte 52 0) bits) significand) bits))) (defun decode-float64 (bits) (declare (type (unsigned-byte 64) bits)) (let* ((sign (ldb (byte 1 63) bits)) (exponent (ldb (byte 11 52) bits)) (significand (ldb (byte 52 0) bits))) (if (zerop exponent) (setf exponent 1) (setf (ldb (byte 1 52) significand) 1)) (unless (zerop sign) (setf significand (- significand))) (scale-float (float significand 1.0d0) (- exponent 1075)))))


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

Issue: Macro call that should be transformed by PSETF

(psetf)

[Assistant]
(defmacro PSETF ...)

;; macroexpand:
nil


[User]
Generate a defmacro form that transforms code like this:
(c?-with-stored (v :bar store 'nothing) (bwhen (val (value v)) val))

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

(c?-with-stored (v :bar store 'nothing) (bwhen (val (value v)) val))

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

;; macroexpand:
(c? (bwhen-c-stored (v :bar store (quote nothing)) (bwhen (val (value v)) val)))


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

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

(drelet nil
  (progn))

[Assistant]
(defmacro DRELET ...)

;; macroexpand:
(dynamic-relet nil
  (progn))


[User]
Generate a defmacro form that transforms code like this:
(defun/1 gets (str) (fgets-is-dumb str most-positive-fixnum stdin t))

Pattern to recognize: Macro call that should be transformed by defun/1

(defun/1 gets (str) (fgets-is-dumb str most-positive-fixnum stdin t))

[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 gets (str) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (fgets-is-dumb str most-positive-fixnum stdin t)) (defparameter gets (vacietis.c:mkptr& (symbol-function (quote gets)))))


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

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

(mvlet nil
  nil)

[Assistant]
(defmacro MVLET ...)

;; macroexpand:
(progn nil)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(dynamic-relet* nil)

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

(dynamic-relet* nil)

[Assistant]
(defmacro DYNAMIC-RELET* ...)

;; macroexpand:
(progn)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(some-> nil :key nil)

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

(some-> nil :key nil)

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

;; macroexpand:
(let* ((#:g144 nil)
       (#:g144
        (if (null #:g144)
            nil
            (-> #:g144 :key))))
  (if (null #:g144)
      nil
      (-> #:g144 nil)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(define-library libwinpthread)

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

(define-library libwinpthread)

[Assistant]
(defmacro define-library (name &body initargs)
  #+cffi
  `(change-class (cffi::get-foreign-library ',name)
                 'library
                 ,@initargs)
  #-cffi
  `(make-instance 'library ,@initargs))

;; macroexpand:
(change-class (cffi::get-foreign-library (quote libwinpthread)) (quote library))


[User]
Define a macro that eliminates this repetitive pattern:
(defun-compile-time walk-function (map-function reduce-function screamer? partial? nested? form environment) (unless (null (rest (last form))) (error "Improper FUNCTION: ~S" form)) (unless (= (length form) 2) (error "FUNCTION must have one argument: ~S" form)) (cond ((lambda-expression? (second form)) (if (and reduce-function nested?) (funcall reduce-function (funcall map-function form 'function-lambda) (funcall reduce-function (walk-lambda-list map-function reduce-function screamer? partial? nested? (second (second form)) environment) (reduce reduce-function (mapcar #'(lambda (subform) (walk map-function reduce-function screamer? partial? nested? subform environment)) (peal-off-documentation-string-and-declarations (rest (rest (second form))) t))))) (funcall map-function form 'function-lambda))) ((valid-function-name? (second form)) (cond ((symbolp (second form)) (if (or (special-operator-p (second form)) (macro-function (second form) environment)) (error "You can't reference the FUNCTION of a special form or~%~ macro: ~S" form) (funcall map-function form 'function-symbol))) (t (funcall map-function form 'function-setf)))) (t (error "Invalid argument to FUNCTION: ~S" form))))

Issue: Macro call that should be transformed by defun-compile-time

(defun-compile-time walk-function (map-function reduce-function screamer? partial? nested? form environment) (unless (null (rest (last form))) (error "Improper FUNCTION: ~S" form)) (unless (= (length form) 2) (error "FUNCTION must have one argument: ~S" form)) (cond ((lambda-expression? (second form)) (if (and reduce-function nested?) (funcall reduce-function (funcall map-function form 'function-lambda) (funcall reduce-function (walk-lambda-list map-function reduce-function screamer? partial? nested? (second (second form)) environment) (reduce reduce-function (mapcar #'(lambda (subform) (walk map-function reduce-function screamer? partial? nested? subform environment)) (peal-off-documentation-string-and-declarations (rest (rest (second form))) t))))) (funcall map-function form 'function-lambda))) ((valid-function-name? (second form)) (cond ((symbolp (second form)) (if (or (special-operator-p (second form)) (macro-function (second form) environment)) (error "You can't reference the FUNCTION of a special form or~%~ macro: ~S" form) (funcall map-function form 'function-symbol))) (t (funcall map-function form 'function-setf)))) (t (error "Invalid argument to FUNCTION: ~S" form))))

[Assistant]
(defmacro defun-compile-time (function-name lambda-list &body body)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (cl:defun ,function-name ,lambda-list ,@body)
     (eval-when (:compile-toplevel) (compile ',function-name))))

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (common-lisp:defun walk-function (map-function reduce-function screamer? partial? nested? form environment) (unless (null (rest (last form))) (error "Improper FUNCTION: ~S" form)) (unless (= (length form) 2) (error "FUNCTION must have one argument: ~S" form)) (cond ((lambda-expression? (second form)) (if (and reduce-function nested?) (funcall reduce-function (funcall map-function form (quote function-lambda)) (funcall reduce-function (walk-lambda-list map-function reduce-function screamer? partial? nested? (second (second form)) environment) (reduce reduce-function (mapcar (function (lambda (subform) (walk map-function reduce-function screamer? partial? nested? subform environment))) (peal-off-documentation-string-and-declarations (rest (rest (second form))) t))))) (funcall map-function form (quote function-lambda)))) ((valid-function-name? (second form)) (cond ((symbolp (second form)) (if (or (special-operator-p (second form)) (macro-function (second form) environment)) (error "You can't reference the FUNCTION of a special form or~%~ macro: ~S" form) (funcall map-function form (quote function-symbol)))) (t (funcall map-function form (quote function-setf))))) (t (error "Invalid argument to FUNCTION: ~S" form)))) (eval-when (:compile-toplevel) (compile (quote walk-function))))


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

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

(collect-max 'some-name)

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

;; macroexpand:
(common-lisp:let* ((#:generator-387 (generator 'some-name))
                   #:numbers-381
                   (#:number-383 nil))
  (declare (type generator #:generator-387))
  (tagbody
   #:ll-388
    (setq #:numbers-381 (next-in #:generator-387 (go end)))
    (if (or (null #:number-383) (< #:number-383 #:numbers-381))
        (setq #:number-383 #:numbers-381))
    (go #:ll-388)
   end)
  (if (null #:number-383)
      (setq #:number-383 nil))
  #:number-383)


[User]
Define a macro that eliminates this repetitive pattern:
(builder :session (lambda (env) (when (string= (getf env :path-info) "/expire") (setf (getf (getf env :lack.session.options) :expire) t)) '(200 () ("hi"))))

Issue: Macro call that should be transformed by builder

(builder :session (lambda (env) (when (string= (getf env :path-info) "/expire") (setf (getf (getf env :lack.session.options) :expire) t)) '(200 () ("hi"))))

[Assistant]
(defmacro builder (&rest app-or-middlewares)
  (let ((middlewares (butlast app-or-middlewares)))
    `(reduce #'funcall
             (remove-if
              #'null
              (list
               ,@(loop for mw in middlewares
                       when mw
                         collect (convert-to-middleware-form mw))))
             :initial-value (to-app ,(car (last app-or-middlewares)))
             :from-end t)))

;; macroexpand:
(reduce (function funcall) (remove-if (function null) (list (find-middleware :session))) :initial-value (to-app (lambda (env) (when (string= (getf env :path-info) "/expire") (setf (getf (getf env :lack.session.options) :expire) t)) (quote (200 nil ("hi"))))) :from-end t)


[User]
You are a Common Lisp macro expert. Given this code pattern:
($op* op l)

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

($op* op l)

[Assistant]
(defmacro $op* (op &rest args)
  (let ((keys (gensym))
	(key  (gensym))
	(kvc  (gensym))
	(val  (gensym)))
    `(multiple-value-bind (,keys ,val) (op-split (unwrap (list ($exp+ ,@args))))
       (let ((,kvc (kv (car ,keys) (kv ,op ,val))))
	 (dolist (,key (cdr ,keys))
	   (setf ,kvc (kv ,kvc (kv ,key (kv ,op ,val)))))
	 ,kvc))))

;; macroexpand:
(multiple-value-bind (#:g321 #:g324) (op-split (unwrap (list ($exp+ l)))) (let ((#:g323 (kv (car #:g321) (kv op #:g324)))) (dolist (#:g322 (cdr #:g321)) (setf #:g323 (kv #:g323 (kv #:g322 (kv op #:g324))))) #:g323))


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

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

(some->> 'some-name)

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

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


[User]
Write a Common Lisp macro to handle this code pattern:
(with-html (:doctype) (:html (:body (:div (:p lorem-ipsum (:span) (:a :href "" :data-instant t "Hello") lorem-ipsum)))))

Problem: Macro call that should be transformed by with-html

(with-html (:doctype) (:html (:body (:div (:p lorem-ipsum (:span) (:a :href "" :data-instant t "Hello") lorem-ipsum)))))

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

;; macroexpand:
(let ((*html* (ensure-html-stream *html*))) (progn (doctype) (with-tag (:html :lang *html-lang*) (with-tag (:body) (with-tag (:div) (with-tag (:p) lorem-ipsum (with-tag (:span)) (with-tag (:a :href "" :data-instant t) "Hello") lorem-ipsum))))))


[User]
Generate a defmacro form that transforms code like this:
(undefcategory :debug)

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

(undefcategory :debug)

[Assistant]
(defmacro undefcategory (category &optional set)
  `(undefcategory-fn ',category ,set))

;; macroexpand:
(undefcategory-fn (quote :debug) nil)


[User]
Write a Common Lisp macro to handle this code pattern:
(signal-syntax-error* (1- (lexer-pos lexer)) "Character '~A' may not follow '(?'." next-char)

Problem: Macro call that should be transformed by signal-syntax-error*

(signal-syntax-error* (1- (lexer-pos lexer)) "Character '~A' may not follow '(?'." next-char)

[Assistant]
(defmacro signal-syntax-error* (pos format-control &rest format-arguments)
  `(error 'ppcre-syntax-error
          :pos ,pos
          :format-control ,format-control
          :format-arguments (list ,@format-arguments)))

;; macroexpand:
(error (quote ppcre-syntax-error) :pos (1- (lexer-pos lexer)) :format-control "Character '~A' may not follow '(?'." :format-arguments (list next-char))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(-> :g () (put 0) 1)

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

(-> :g () (put 0) 1)

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

;; macroexpand:
(atomically :g nil (put 0) 1)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(-> :p (a) (declare (type fixnum a)) (the fixnum (+ a i)))

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

(-> :p (a) (declare (type fixnum a)) (the fixnum (+ a i)))

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

;; macroexpand:
(atomically :p (a) (declare (type fixnum a)) (the fixnum (+ a i)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(define-interpreter oid:+char+ "char" int 1)

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

(define-interpreter oid:+char+ "char" int 1)

[Assistant]
(defmacro define-interpreter (oid name fields &body value)
  "Shorthand for defining binary readers."
  (declare (ignore name)) ;; Names are there just for clarity
  `(set-sql-reader ,oid (binary-reader ,fields ,@value) :binary-p t))

;; macroexpand:
(set-sql-reader cl-postgres-oid:+char+ (binary-reader int 1) :binary-p t)


[User]
Create a Common Lisp macro for the following transformation. Before code:
(aand 1 t (values it 2))

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

(aand 1 t (values it 2))

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

;; macroexpand:
(anaphoric and 1 t (values it 2))


[User]
Generate a defmacro form that transforms code like this:
(with-decoder-simple-list-semantics (is (equalp (decode-json-from-string (format nil input "{\"lispPackage\":\"jsonTest\", \"lispClass\":\"frob\"}")) '((:bar . 46) (:xyzzy . t) (:quux . 98) (:prototype . ((:lisp-package . "jsonTest") (:lisp-class . "frob")))))))

Pattern to recognize: Macro call that should be transformed by with-decoder-simple-list-semantics

(with-decoder-simple-list-semantics (is (equalp (decode-json-from-string (format nil input "{\"lispPackage\":\"jsonTest\", \"lispClass\":\"frob\"}")) '((:bar . 46) (:xyzzy . t) (:quux . 98) (:prototype . ((:lisp-package . "jsonTest") (:lisp-class . "frob")))))))

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

;; macroexpand:
(with-shadowed-custom-vars (set-decoder-simple-list-semantics) (is (equalp (decode-json-from-string (format nil input "{\"lispPackage\":\"jsonTest\", \"lispClass\":\"frob\"}")) (quote ((:bar . 46) (:xyzzy . t) (:quux . 98) (:prototype (:lisp-package . "jsonTest") (:lisp-class . "frob")))))))


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

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

(f_n
  nil
  nil)

[Assistant]
(defmacro F_N ...)

;; macroexpand:
(lambda (&rest _) nil nil)


[User]
Write a Common Lisp macro to handle this code pattern:
(with-forced-status (:failed) (false NIL))

Problem: Macro call that should be transformed by with-forced-status

(with-forced-status (:failed) (false NIL))

[Assistant]
(defmacro with-forced-status ((status &optional description &rest format-args) &body tests)
  `(eval-in-context
    *context*
    (make-instance 'controlling-result
                   :expression ,status
                   :child-status ,status
                   :body (lambda () ,@tests)
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))

;; macroexpand:
(eval-in-context *context* (make-instance (quote controlling-result) :expression :failed :child-status :failed :body (lambda nil (false nil))))


[User]
Generate a defmacro form that transforms code like this:
(with-wcs-math-error-handling ((quot rem) (fround x y)) (check-wcs-math-result) rem)

Pattern to recognize: Macro call that should be transformed by with-wcs-math-error-handling

(with-wcs-math-error-handling ((quot rem) (fround x y)) (check-wcs-math-result) rem)

[Assistant]
(defmacro with-wcs-math-error-handling
    ((var-or-var-list
      (function x &optional (y nil y-supplied-p))
      &rest keyargs
      &key underflow-value)
     &body body)
  (declare (ignorable underflow-value))
  (let ((x_ (gensym)) (y_ (gensym)) (args_ (gensym))
        (var-list (ensure-list var-or-var-list)))
    `(let* ((,x_ ,x)
            (,y_ ,y)
            (,args_ (list ,x_ ,@(if y-supplied-p `(,y_)))))
       (declare (ignorable ,y_)
                (type list ,args_)
                (dynamic-extent ,args_))
       (catch 'return-from-with-wcs-math-error-handling
         (multiple-value-bind ,var-list
             (call-with-wcs-math-error-handler ',function ,args_
                                               ,@keyargs)
           (flet ((check-wcs-math-result
                      (&optional (ret ,(first var-list))
                                 (arg-list ,args_))
                    (check-wcs-math-result ret arg-list)))
             ,@body))))))

;; macroexpand:
(let* ((#:g257 x) (#:g258 y) (#:g259 (list #:g257 #:g258))) (declare (ignorable #:g258) (type list #:g259) (dynamic-extent #:g259)) (catch (quote return-from-with-wcs-math-error-handling) (multiple-value-bind (quot rem) (call-with-wcs-math-error-handler (quote fround) #:g259) (flet ((check-wcs-math-result (&optional (ret quot) (arg-list #:g259)) (check-wcs-math-result ret arg-list))) (check-wcs-math-result) rem))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(lambda () :key nil)

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

(lambda () :key nil)

[Assistant]
(defmacro LAMBDA ...)

;; macroexpand:
#'(lambda () :key nil)


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

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

(gathering nil)

[Assistant]
(defmacro GATHERING ...)

;; macroexpand:
(common-lisp:let ()
  (values))


[User]
Write a Common Lisp macro to handle this code pattern:
(with-preprocessor-state-slots (state) (when if-section-skip-reason (begin-if-section state '(:skipped :if) nil) (return-from process-preprocessing-directive nil)) (unless (preprocessor-token-exists-p directive-token-list) (raise-no-preprocessor-token-error directive-symbol)) (let ((result (eval-if-expression directive-symbol directive-token-list state))) (begin-if-section state directive-token-list result)))

Problem: Macro call that should be transformed by with-preprocessor-state-slots

(with-preprocessor-state-slots (state) (when if-section-skip-reason (begin-if-section state '(:skipped :if) nil) (return-from process-preprocessing-directive nil)) (unless (preprocessor-token-exists-p directive-token-list) (raise-no-preprocessor-token-error directive-symbol)) (let ((result (eval-if-expression directive-symbol directive-token-list state))) (begin-if-section state directive-token-list result)))

[Assistant]
(defmacro with-preprocessor-state-slots ((state) &body body)
  `(with-accessors ((file-pathname pp-state-file-pathname)
                    (token-list pp-state-token-list)
                    (result-list pp-state-result-list)
                    (line-number pp-state-line-number)
                    (tokens-in-line pp-state-tokens-in-line)
                    (macro-alist pp-state-macro-alist)
                    (if-section-stack pp-state-if-section-stack)
                    (if-section-skip-reason pp-state-if-section-skip-reason)
                    (include-stack pp-state-include-stack))
       ,state
     ,@body))

;; macroexpand:
(with-accessors ((file-pathname pp-state-file-pathname) (token-list pp-state-token-list) (result-list pp-state-result-list) (line-number pp-state-line-number) (tokens-in-line pp-state-tokens-in-line) (macro-alist pp-state-macro-alist) (if-section-stack pp-state-if-section-stack) (if-section-skip-reason pp-state-if-section-skip-reason) (include-stack pp-state-include-stack)) state (when if-section-skip-reason (begin-if-section state (quote (:skipped :if)) nil) (return-from process-preprocessing-directive nil)) (unless (preprocessor-token-exists-p directive-token-list) (raise-no-preprocessor-token-error directive-symbol)) (let ((result (eval-if-expression directive-symbol directive-token-list state))) (begin-if-section state directive-token-list result)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(builder (:mount "/admin" (lambda (env) `(200 () ("admin" ,(getf env :path-info))))) *app*)

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

(builder (:mount "/admin" (lambda (env) `(200 () ("admin" ,(getf env :path-info))))) *app*)

[Assistant]
(defmacro builder (&rest app-or-middlewares)
  (let ((middlewares (butlast app-or-middlewares)))
    `(reduce #'funcall
             (remove-if
              #'null
              (list
               ,@(loop for mw in middlewares
                       when mw
                         collect (convert-to-middleware-form mw))))
             :initial-value (to-app ,(car (last app-or-middlewares)))
             :from-end t)))

;; macroexpand:
(reduce (function funcall) (remove-if (function null) (list (lambda (#:app172) (funcall (find-middleware :mount) #:app172 "/admin" (lambda (env) (sb-int:quasiquote (200 nil ("admin" #S(sb-impl::comma :expr (getf env :path-info) :kind 0))))))))) :initial-value (to-app *app*) :from-end t)


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

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

(lambda () nil)

[Assistant]
(defmacro LAMBDA ...)

;; macroexpand:
#'(lambda () nil)


[User]
Generate a defmacro form that transforms code like this:
(is (not (plusp 1)))

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

(is (not (plusp 1)))

[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:
(let ((#:v197 1)) (if (not (plusp #:v197)) (add-result (quote test-passed) :test-expr (quote (not (plusp 1)))) (process-failure (quote (not (plusp 1))) "~2&~S~2% evaluated to ~2&~S~2% which satisfies ~2&~S~2% (it should not)" (quote 1) #:v197 (quote plusp))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(labels* nil)

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

(labels* nil)

[Assistant]
(defmacro LABELS* ...)

;; macroexpand:
(labels nil)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(defclause-driver (for var-spec &sequence) "Numbers" (top-level-check) (if with-index (clause-error "WITH-INDEX should not be specified for this clause")) (check-sequence-keywords from upfrom downfrom to downto above below nil) (let* ((var (extract-var var-spec)) (initial (or from upfrom downfrom 0)) (limit (or to downto above below)) (step-func (if (or downfrom downto above) '- '+)) (test-func (cond (to '>) (downto '<) (below '>=) (above '<=))) (limit-var (if (and limit (not (constant? limit))) (make-var-and-binding 'limit limit :using-type-of (if (expression-type limit) limit var)))) (step-var (if (not (constantp by)) (make-var-and-binding 'step by :using-type-of by))) (step-thing (or step-var by)) (limit-code (or limit-var limit)) (init-val (eval-const-expr (list (if (eq step-func '+) '- '+) initial step-thing))) (test (if limit (progn (setq *loop-end-used?* t) `((if (,test-func ,var ,limit-code) (go ,*loop-end*)))) nil)) (next `((setq ,var (,step-func ,var ,step-thing)) .,test))) (make-binding var-spec init-val :type 'number) (return-driver-code :next next :variable var)))

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

(defclause-driver (for var-spec &sequence) "Numbers" (top-level-check) (if with-index (clause-error "WITH-INDEX should not be specified for this clause")) (check-sequence-keywords from upfrom downfrom to downto above below nil) (let* ((var (extract-var var-spec)) (initial (or from upfrom downfrom 0)) (limit (or to downto above below)) (step-func (if (or downfrom downto above) '- '+)) (test-func (cond (to '>) (downto '<) (below '>=) (above '<=))) (limit-var (if (and limit (not (constant? limit))) (make-var-and-binding 'limit limit :using-type-of (if (expression-type limit) limit var)))) (step-var (if (not (constantp by)) (make-var-and-binding 'step by :using-type-of by))) (step-thing (or step-var by)) (limit-code (or limit-var limit)) (init-val (eval-const-expr (list (if (eq step-func '+) '- '+) initial step-thing))) (test (if limit (progn (setq *loop-end-used?* t) `((if (,test-func ,var ,limit-code) (go ,*loop-end*)))) nil)) (next `((setq ,var (,step-func ,var ,step-thing)) .,test))) (make-binding var-spec init-val :type 'number) (return-driver-code :next next :variable var)))

[Assistant]
(defmacro defclause (clause-template &body body)
  (define-clause 'defun clause-template body nil))

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (defun clause-for-3 (&key ((:for var-spec)) ((:from from)) ((:upfrom upfrom)) ((:downfrom downfrom)) ((:to to)) ((:downto downto)) ((:above above)) ((:below below)) ((:by by) 1) ((:with-index with-index)) generate) "Numbers" (top-level-check) (if with-index (clause-error "WITH-INDEX should not be specified for this clause")) (check-sequence-keywords from upfrom downfrom to downto above below nil) (let* ((var (extract-var var-spec)) (initial (or from upfrom downfrom 0)) (limit (or to downto above below)) (step-func (if (or downfrom downto above) (quote -) (quote +))) (test-func (cond (to (quote >)) (downto (quote <)) (below (quote >=)) (above (quote <=)))) (limit-var (if (and limit (not (constant? limit))) (make-var-and-binding (quote limit) limit :using-type-of (if (expression-type limit) limit var)))) (step-var (if (not (constantp by)) (make-var-and-binding (quote step) by :using-type-of by))) (step-thing (or step-var by)) (limit-code (or limit-var limit)) (init-val (eval-const-expr (list (if (eq step-func (quote +)) (quote -) (quote +)) initial step-thing))) (test (if limit (progn (setq *loop-end-used?* t) (sb-int:quasiquote ((if (#S(sb-impl::comma :expr test-func :kind 0) #S(sb-impl::comma :expr var :kind 0) #S(sb-impl::comma :expr limit-code :kind 0)) (go #S(sb-impl::comma :expr *loop-end* :kind 0)))))) nil)) (next (sb-int:quasiquote ((setq #S(sb-impl::comma :expr var :kind 0) (#S(sb-impl::comma :expr step-func :kind 0) #S(sb-impl::comma :expr var :kind 0) #S(sb-impl::comma :expr step-thing :kind 0))) . #S(sb-impl::comma :expr test :kind 0))))) (make-binding var-spec init-val :type (quote number)) (return-driver-code :next next :variable var))) (install-clause-info (quote (for)) (quote (for &optional :from :upfrom :downfrom :to :downto :above :below :by :with-index)) (quote clause-for-3) "Numbers" t) (quote (for var-spec &optional :from from :upfrom upfrom :downfrom downfrom :to to :downto downto :above above :below below :by (by 1) :with-index with-index)))


[User]
Define a macro that eliminates this repetitive pattern:
(enable-quasi-quote-syntax nil nil)

Issue: Macro call that should be transformed by ENABLE-QUASI-QUOTE-SYNTAX

(enable-quasi-quote-syntax nil nil)

[Assistant]
(defmacro ENABLE-QUASI-QUOTE-SYNTAX ...)

;; macroexpand:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-quasi-quote-syntax-in-readtable nil nil :nested-quasi-quote-wrapper
                                       quasi-quote-wrapper :start-character nil
                                       :dispatch-character nil :end-character
                                       nil :unquote-character #\COMMA
                                       :splice-character #\COMMERCIAL_AT
                                       :destructive-splice-character
                                       #\FULL_STOP :dispatched-quasi-quote-name
                                       nil :toplevel-reader-wrapper #'identity
                                       :unquote-readtable-case nil :body-reader
                                       nil :readtable-case nil)
  (values))


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

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

(define-modf-rewrite fifth (expr) `(car (cddddr ,(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 fifth) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (car (cddddr #S(sb-impl::comma :expr (second expr) :kind 0)))))))


[User]
Generate a defmacro form that transforms code like this:
(defun/1 tolower (c) (char-downcase (code-char c)))

Pattern to recognize: Macro call that should be transformed by defun/1

(defun/1 tolower (c) (char-downcase (code-char c)))

[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 tolower (c) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (char-downcase (code-char c))) (defparameter tolower (vacietis.c:mkptr& (symbol-function (quote tolower)))))


[User]
Write a Common Lisp macro to handle this code pattern:
(define-method-combination% and :operator and :identity-with-one-argument t)

Problem: Macro call that should be transformed by define-method-combination%

(define-method-combination% and :operator and :identity-with-one-argument t)

[Assistant]
(defmacro define-method-combination% (name &rest args)
  "Define a method-combination for the static-dispatch system only.

   Arguments are of the same form as to CL:DEFINE-METHOD-COMBINATION."

  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf
      (combination-function ',name)
      ,(match args
         ((or nil
              (list* (and (type symbol) (not nil)) _))

          (destructuring-bind (&key (operator name) (identity-with-one-argument nil))
              args

            `(method-combination-function-short ,name ,operator ,identity-with-one-argument)))

         (_
          `(method-combination-function ,name ,@args))))))

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (setf (combination-function (quote and)) (method-combination-function-short and and t)))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(doseq! (item seq :start start :end end) (setf item value))

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

(doseq! (item seq :start start :end end) (setf item value))

[Assistant]
(defmacro doseq (name/seq &body body)
  "Iterate over the elements of a single sequence SEQUENCE.

   Same as DO-SEQUENCES but for the special case of iterating over a
   single sequence.

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

    1. (NAME (ELEMENT SEQUENCE &REST ARGS) &BODY BODY)

    2. ((ELEMENT SEQUENCE &REST ARGS) &BODY BODY)

   NAME is the block name, NIL if not given.

   ELEMENT is the variable to which each element of the sequence is
   bound.

   SEQUENCE is the sequence, with ARGS being the remaining arguments
   passed to the ITERATOR function.

   BODY is the list of forms evaluated on each iteration."

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

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

;; macroexpand:
(do-sequences! nil ((item seq :start start :end end)) (setf item value))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(def-neo4j-fun get-path (node-id to-node-id relationships (max-depth 3) (algorithm :shortest-path)) :post (:uri-spec (format nil "node/~A/path" node-id)) (:encode (list (list (cons "to" to-node-id) :node-url) (list (cons "relationships" relationships)) (list (cons "max_depth" max-depth)) (list (cons "algorithm" (case algorithm (:shortest-path "shortestPath") (:all-paths "allPaths") (:all-simple-paths "allSimplePaths") (:dijkstra "dijkstra"))))) :object) (:status-handlers (200 (decode-neo4j-json-output body)) (404 (error 'path-not-found-error :uri uri))))

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

(def-neo4j-fun get-path (node-id to-node-id relationships (max-depth 3) (algorithm :shortest-path)) :post (:uri-spec (format nil "node/~A/path" node-id)) (:encode (list (list (cons "to" to-node-id) :node-url) (list (cons "relationships" relationships)) (list (cons "max_depth" max-depth)) (list (cons "algorithm" (case algorithm (:shortest-path "shortestPath") (:all-paths "allPaths") (:all-simple-paths "allSimplePaths") (:dijkstra "dijkstra"))))) :object) (:status-handlers (200 (decode-neo4j-json-output body)) (404 (error 'path-not-found-error :uri uri))))

[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 get-path (&key node-id to-node-id relationships (max-depth 3) (algorithm :shortest-path)) (let ((uri (format nil "node/~A/path" node-id)) (json (encode-neo4j-json-payload (list (list (cons "to" to-node-id) :node-url) (list (cons "relationships" relationships)) (list (cons "max_depth" max-depth)) (list (cons "algorithm" (case algorithm (:shortest-path "shortestPath") (:all-paths "allPaths") (:all-simple-paths "allSimplePaths") (:dijkstra "dijkstra"))))) :object))) (make-neo4j-request :post uri json (list (list 200 (lambda (body uri json) (decode-neo4j-json-output body))) (list 404 (lambda (body uri json) (error (quote path-not-found-error) :uri uri))))))))


[User]
Define a macro that eliminates this repetitive pattern:
(with-decoder-simple-list-semantics (setf x (decode-json-from-string "{\"x\":1}")) (is (equal (symbol-package (caar x)) (find-package :cl-user))))

Issue: Macro call that should be transformed by with-decoder-simple-list-semantics

(with-decoder-simple-list-semantics (setf x (decode-json-from-string "{\"x\":1}")) (is (equal (symbol-package (caar x)) (find-package :cl-user))))

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

;; macroexpand:
(with-shadowed-custom-vars (set-decoder-simple-list-semantics) (setf x (decode-json-from-string "{\"x\":1}")) (is (equal (symbol-package (caar x)) (find-package :cl-user))))


[User]
Generate a defmacro form that transforms code like this:
(define-error invalid-form-list () (code) "Tried to compile form however the first element of the form was a list: ~s" code)

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

(define-error invalid-form-list () (code) "Tried to compile form however the first element of the form was a list: ~s" code)

[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 invalid-form-list (:error-type varjo-error :prefix "Varjo") (code) "Tried to compile form however the first element of the form was a list: ~s" code)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(augment arglist (list 'generate))

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

(augment arglist (list 'generate))

[Assistant]
(defmacro augment (var stuff)
  `(setf ,var (nconc ,var ,stuff)))

;; macroexpand:
(setf arglist (nconc arglist (list (quote generate))))


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

Problem: Macro call that should be transformed by LAMBDA*

(lambda* nil)

[Assistant]
(defmacro LAMBDA* ...)

;; macroexpand:
(lambda () (the t nil))


[User]
Define a macro that eliminates this repetitive pattern:
(with-file-name-lock-held () (format nil "~:@(~36,8,'0R~)" (random (expt 36 8) *name-random-state*)))

Issue: Macro call that should be transformed by with-file-name-lock-held

(with-file-name-lock-held () (format nil "~:@(~36,8,'0R~)" (random (expt 36 8) *name-random-state*)))

[Assistant]
(defmacro with-file-name-lock-held (() &body body)
  `(bordeaux-threads:with-lock-held (*create-file-name-lock*)
     ,@body))

;; macroexpand:
(bordeaux-threads:with-lock-held (*create-file-name-lock*) (format nil "~:@(~36,8,'0R~)" (random (expt 36 8) *name-random-state*)))


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

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

(defsynonym finally :finally)

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

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


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defclause symbols-in (package-or-packages &rest symbol-types) "Iterates over the symbols in one or more packages. Symbol-types follows the specification of cl:with-package-iterator." (let ((variables (ensure-list *iteration-variable*)) (package-list (ensure-list package-or-packages)) (symbol-types (or symbol-types '(:external))) (iterator (gensym "PACKAGE-ITERATOR")) (test (gensym "TEST"))) (unless (<= 1 (length variables) 3) (error "Invalid variable specification for package entry, expected (symbol &optional accessibility package) but got ~S" *iteration-variable*)) `(,(make-wrapper :function (lambda (body) `(with-package-iterator (,iterator (list ,@package-list) ,@symbol-types) ,body))) ,(make-iteration :bindings `(,test ,@variables) :initializations `((setf (values ,test ,@variables) (,iterator))) :steps `((setf (values ,test ,@variables) (,iterator))) :postconditions `((not (null ,test)))))))

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

(defclause symbols-in (package-or-packages &rest symbol-types) "Iterates over the symbols in one or more packages. Symbol-types follows the specification of cl:with-package-iterator." (let ((variables (ensure-list *iteration-variable*)) (package-list (ensure-list package-or-packages)) (symbol-types (or symbol-types '(:external))) (iterator (gensym "PACKAGE-ITERATOR")) (test (gensym "TEST"))) (unless (<= 1 (length variables) 3) (error "Invalid variable specification for package entry, expected (symbol &optional accessibility package) but got ~S" *iteration-variable*)) `(,(make-wrapper :function (lambda (body) `(with-package-iterator (,iterator (list ,@package-list) ,@symbol-types) ,body))) ,(make-iteration :bindings `(,test ,@variables) :initializations `((setf (values ,test ,@variables) (,iterator))) :steps `((setf (values ,test ,@variables) (,iterator))) :postconditions `((not (null ,test)))))))

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

;; macroexpand:
(progn (defmacro symbols-in (package-or-packages &rest symbol-types) "Iterates over the symbols in one or more packages. Symbol-types follows the specification of cl:with-package-iterator." (let ((variables (ensure-list *iteration-variable*)) (package-list (ensure-list package-or-packages)) (symbol-types (or symbol-types (quote (:external)))) (iterator (gensym "PACKAGE-ITERATOR")) (test (gensym "TEST"))) (unless (<= 1 (length variables) 3) (error "Invalid variable specification for package entry, expected (symbol &optional accessibility package) but got ~S" *iteration-variable*)) (sb-int:quasiquote (#S(sb-impl::comma :expr (make-wrapper :function (lambda (body) (sb-int:quasiquote (with-package-iterator (#S(sb-impl::comma :expr iterator :kind 0) (list #S(sb-impl::comma :expr package-list :kind 2)) #S(sb-impl::comma :expr symbol-types :kind 2)) #S(sb-impl::comma :expr body :kind 0))))) :kind 0) #S(sb-impl::comma :expr (make-iteration :bindings (sb-int:quasiquote (#S(sb-impl::comma :expr test :kind 0) #S(sb-impl::comma :expr variables :kind 2))) :initializations (sb-int:quasiquote ((setf (values #S(sb-impl::comma :expr test :kind 0) #S(sb-impl::comma :expr variables :kind 2)) (#S(sb-impl::comma :expr iterator :kind 0))))) :steps (sb-int:quasiquote ((setf (values #S(sb-impl::comma :expr test :kind 0) #S(sb-impl::comma :expr variables :kind 2)) (#S(sb-impl::comma :expr iterator :kind 0))))) :postconditions (sb-int:quasiquote ((not (null #S(sb-impl::comma :expr test :kind 0)))))) :kind 0))))) (pushnew (quote symbols-in) *clauses*))


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

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

(collect-nth nil (progn))

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

;; macroexpand:
(common-lisp:let* ((#:generator-409 (generator (progn)))
                   #:items-401
                   (#:counter-403 nil)
                   (#:item-404 nil))
  (declare (type generator #:generator-409)
           (type (null-or fixnum) #:counter-403)
           (type (null-or t) #:item-404))
  (tagbody
   #:ll-410
    (setq #:items-401 (next-in #:generator-409 (go end)))
    (when (zerop #:counter-403) (setq #:item-404 #:items-401) (go end))
    (decf #:counter-403)
    (go #:ll-410)
   end)
  #:item-404)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(with-yield-binds (format nil "ALTER COLUMN ~A~:[~; TYPE ~:*~A~]~:[~; SET DEFAULT ~:*~A~]~:[~; DROP DEFAULT~]~A" (yield (alter-column-clause-column-name clause)) (and (alter-column-clause-type clause) (let ((*use-placeholder* nil)) (yield (alter-column-clause-type clause)))) (and (alter-column-clause-set-default clause) (yield (alter-column-clause-set-default clause))) (alter-column-clause-drop-default clause) (cond ((eq (alter-column-clause-not-null clause) :unspecified) "") ((alter-column-clause-not-null clause) " SET NOT NULL") (T " DROP NOT NULL"))))

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

(with-yield-binds (format nil "ALTER COLUMN ~A~:[~; TYPE ~:*~A~]~:[~; SET DEFAULT ~:*~A~]~:[~; DROP DEFAULT~]~A" (yield (alter-column-clause-column-name clause)) (and (alter-column-clause-type clause) (let ((*use-placeholder* nil)) (yield (alter-column-clause-type clause)))) (and (alter-column-clause-set-default clause) (yield (alter-column-clause-set-default clause))) (alter-column-clause-drop-default clause) (cond ((eq (alter-column-clause-not-null clause) :unspecified) "") ((alter-column-clause-not-null clause) " SET NOT NULL") (T " DROP NOT NULL"))))

[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 (format nil "ALTER COLUMN ~A~:[~; TYPE ~:*~A~]~:[~; SET DEFAULT ~:*~A~]~:[~; DROP DEFAULT~]~A" (yield (alter-column-clause-column-name clause)) (and (alter-column-clause-type clause) (let ((*use-placeholder* nil)) (yield (alter-column-clause-type clause)))) (and (alter-column-clause-set-default clause) (yield (alter-column-clause-set-default clause))) (alter-column-clause-drop-default clause) (cond ((eq (alter-column-clause-not-null clause) :unspecified) "") ((alter-column-clause-not-null clause) " SET NOT NULL") (t " DROP NOT NULL")))) (loop for bind in (reverse *bind-values*) append bind)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(do+ outer-loop (do+ inner-loop (do+ (terminate outer-loop 3))))

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

(do+ outer-loop (do+ inner-loop (do+ (terminate outer-loop 3))))

[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 outer-loop (do+ inner-loop (do+ (terminate outer-loop 3))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(with-color (:cyan :stream stream) (with-additional-indent (reporter stream "- ") (let ((description (possible-report-description report))) (when description (format/indent reporter stream description)))) (terpri stream))

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

(with-color (:cyan :stream stream) (with-additional-indent (reporter stream "- ") (let ((description (possible-report-description report))) (when description (format/indent reporter stream description)))) (terpri stream))

[Assistant]
(defmacro with-color ((color &rest args) &body body)
  (cond
    ((or (eq color :gray)
         (eq color :grey))
     `(if *enable-colors*
          (with-gray ,(or (getf args :stream) t) ,@body)
          (progn ,@body)))
    (T `(if *enable-colors*
            (if (or (eq ,color :gray)
                    (eq ,color :grey)
                    (eq ,color cl-colors:+gray+)
                    (eq ,color cl-colors:+grey+))
                (with-gray ,(or (getf args :stream) t) ,@body)
                (cl-ansi-text:with-color (,color ,@args) ,@body))
            (progn ,@body)))))

;; macroexpand:
(if *enable-colors* (if (or (eq :cyan :gray) (eq :cyan :grey) (eq :cyan +gray+) (eq :cyan +grey+)) (with-gray stream (with-additional-indent (reporter stream "- ") (let ((description (possible-report-description report))) (when description (format/indent reporter stream description)))) (terpri stream)) (cl-ansi-text:with-color (:cyan :stream stream) (with-additional-indent (reporter stream "- ") (let ((description (possible-report-description report))) (when description (format/indent reporter stream description)))) (terpri stream))) (progn (with-additional-indent (reporter stream "- ") (let ((description (possible-report-description report))) (when description (format/indent reporter stream description)))) (terpri stream)))


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

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

($send nil (progn))

[Assistant]
(defmacro $SEND ...)

;; macroexpand:
(send-message nil (progn))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(define-shell-component myth :input-type "myth" :output-type "css" :shell-command "myth")

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

(define-shell-component myth :input-type "myth" :output-type "css" :shell-command "myth")

[Assistant]
(defmacro define-shell-component (name &key input-type output-type shell-command)
  "Define an ASDF component that's compiled by running a shell command."
  `(define-component ,name
     :input-type ,input-type
     :output-type ,output-type
     :compile-function (lambda (input-pathname output-pathname)
                         (inferior-shell:run (list ,@(ensure-list shell-command)
                                                    input-pathname
                                                    output-pathname)
                                             :show t))))

;; macroexpand:
(define-component myth :input-type "myth" :output-type "css" :compile-function (lambda (input-pathname output-pathname) (inferior-shell:run (list "myth" input-pathname output-pathname) :show t)))


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

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

(define-global-var nil nil)

[Assistant]
(defmacro DEFINE-GLOBAL-VAR ...)

;; macroexpand:
(sb-ext:defglobal nil nil)


[User]
Write a Common Lisp macro to handle this code pattern:
(with-html-string (:x-y "Hello"))

Problem: Macro call that should be transformed by with-html

(with-html-string (:x-y "Hello"))

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

;; macroexpand:
(with-output-to-string (*html*) (with-html (:x-y "Hello")))


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

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

(reduced-typecase 'some-name)

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

;; macroexpand:
(typecase 'some-name)


[User]
You are a Common Lisp macro expert. Given this code pattern:
(c?-with-stored (v :foo store 'nothing) (bwhen (val (value v)) (1+ val)))

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

(c?-with-stored (v :foo store 'nothing) (bwhen (val (value v)) (1+ val)))

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

;; macroexpand:
(c? (bwhen-c-stored (v :foo store (quote nothing)) (bwhen (val (value v)) (1+ val))))


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

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

(define-final-class nil :key nil)

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

;; macroexpand:
(defclass nil :key nil (:metaclass final-class))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(assoc-cdr :authorization--endpoint disc)

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

(assoc-cdr :authorization--endpoint disc)

[Assistant]
(defmacro assoc-cdr (key alist &optional (test '#'eql))
  `(cdr (assoc ,key ,alist :test ,test)))

;; macroexpand:
(cdr (assoc :authorization--endpoint disc :test (function eql)))


[User]
Write a Common Lisp macro to handle this code pattern:
(-> :p (a) (declare (type fixnum a)) (the fixnum (1+ a)))

Problem: Macro call that should be transformed by ->

(-> :p (a) (declare (type fixnum a)) (the fixnum (1+ a)))

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

;; macroexpand:
(atomically :p (a) (declare (type fixnum a)) (the fixnum (1+ a)))


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

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

(with-yield)

[Assistant]
(defmacro WITH-YIELD ...)

;; macroexpand:
(isolate-cont
  (enable-yield
    nil))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(defclause initially (&rest forms) "Evaluates <form> before the first iteration." (mapcar (lambda (form) (make-initialization :form form)) forms))

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

(defclause initially (&rest forms) "Evaluates <form> before the first iteration." (mapcar (lambda (form) (make-initialization :form form)) forms))

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

;; macroexpand:
(progn (defmacro initially (&rest forms) "Evaluates <form> before the first iteration." (mapcar (lambda (form) (make-initialization :form form)) forms)) (pushnew (quote initially) *clauses*))


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

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

(-<>
  nil
  nil)

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

;; macroexpand:
(let* ((#:var204 nil) (#:var205 (nil #:var204)))
  #:var205)


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

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

(cond->> 'some-name)

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

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


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

Issue: Macro call that should be transformed by DEFVARIANT

(defvariant nil
  nil)

[Assistant]
(defmacro DEFVARIANT ...)

;; macroexpand:
(progn
 (defstruct (nil (:constructor nil)))
 (defstruct (nil-nil (:include nil)))
 (defmacro match-nil (expr &body match-cases)
   #A((34) base-char . "Match values of variant type: NIL.")
   (let ((expr-var (gensym "-val")))
     `(let ((,expr-var ,expr))
        ,(build-dispatch `,'nil `,'(nil) match-cases expr-var)))))


[User]
Generate a defmacro form that transforms code like this:
(with-indentation (with-xml-group-element (s "tspan" opts) (string->xml s text)))

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

(with-indentation (with-xml-group-element (s "tspan" opts) (string->xml s text)))

[Assistant]
(defmacro with-indentation (&body body)
  `(let ((*indent-level* (+ *indent-level* *indent-spacing*)))
     ,@body))

;; macroexpand:
(let ((*indent-level* (+ *indent-level* *indent-spacing*))) (with-xml-group-element (s "tspan" opts) (string->xml s text)))


[User]
Define a macro that eliminates this repetitive pattern:
(builder (:backtrace :output *test-error-output* :result-on-error '(500 (:content-type "text/plain") ("Internal Server Error"))) (lambda (env) (declare (ignore env)) (error "Error occured")))

Issue: Macro call that should be transformed by builder

(builder (:backtrace :output *test-error-output* :result-on-error '(500 (:content-type "text/plain") ("Internal Server Error"))) (lambda (env) (declare (ignore env)) (error "Error occured")))

[Assistant]
(defmacro builder (&rest app-or-middlewares)
  (let ((middlewares (butlast app-or-middlewares)))
    `(reduce #'funcall
             (remove-if
              #'null
              (list
               ,@(loop for mw in middlewares
                       when mw
                         collect (convert-to-middleware-form mw))))
             :initial-value (to-app ,(car (last app-or-middlewares)))
             :from-end t)))

;; macroexpand:
(reduce (function funcall) (remove-if (function null) (list (lambda (#:app196) (funcall (find-middleware :backtrace) #:app196 :output *test-error-output* :result-on-error (quote (500 (:content-type "text/plain") ("Internal Server Error"))))))) :initial-value (to-app (lambda (env) (declare (ignore env)) (error "Error occured"))) :from-end t)


[User]
Generate a defmacro form that transforms code like this:
(draw group (:line :x1 x :y1 y :x2 dx :y2 dy))

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

(draw group (:line :x1 x :y1 y :x2 dx :y2 dy))

[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 ((#:g158 (funcall (function make-svg-element) :line (append (list :x1 x :y1 y :x2 dx :y2 dy) (list))))) (add-element group #:g158) #:g158)


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

Problem: Macro call that should be transformed by ->

(-> :one () (increment))

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

;; macroexpand:
(atomically :one nil (increment))


[User]
Define a macro that eliminates this repetitive pattern:
(ps-html nil)

Issue: Macro call that should be transformed by PS-HTML

(ps-html nil)

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

;; macroexpand:
(stringify nil)


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

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

(with-slots nil
    (progn))

[Assistant]
(defmacro WITH-SLOTS ...)

;; macroexpand:
(let ((#:g179 (progn)))
  (declare (ignorable #:g179))
  (symbol-macrolet ()))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defsynonym :finding :find)

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

(defsynonym :finding :find)

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

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


[User]
Generate a defmacro form that transforms code like this:
(deferror "22012" db-division-by-zero data-exception)

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

(deferror "22012" db-division-by-zero data-exception)

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

;; macroexpand:
(progn (define-condition db-division-by-zero (data-exception) nil) (setf (gethash "22012" *error-table*) (quote db-division-by-zero)))


[User]
Define a macro that eliminates this repetitive pattern:
(define-test subtest :parent example (fail (error "An expected failure.")) (fail (warn "An expected warning.") warning))

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

(define-test subtest :parent example (fail (error "An expected failure.")) (fail (warn "An expected warning.") warning))

[Assistant]
(defmacro define-test (name &body arguments-and-body)
  (destructuring-bind (nparent name) (if (listp name) name (list NIL name))
    (form-fiddle:with-body-options (body options parent home (test-class 'test) (compile-at :compile-time) defun) arguments-and-body
      (let ((body (remove 'define-test body :key (lambda (a) (when (listp a) (car a))) :test #'eql))
            (defs (remove 'define-test body :key (lambda (a) (when (listp a) (car a))) :test-not #'eql))
            (home-form (or home `(find-package ,(package-name *package*)))))
        (when (and parent nparent)
          (error "Cannot specify parent through name and through a keyword argument at the same time!"))
        `(let ((*package* (find-package ,(package-name *package*)))) ; Make sure package stays consistent throughout initialisation.
           (setf (find-test ',name ,home-form)
                 (ensure-test ',test-class
                              :name ',name
                              :home ,home-form
                              :tests (list ,@(loop for form in body
                                                   collect (ecase compile-at
                                                             (:compile-time `(lambda () ,form))
                                                             (:execute `(lambda () (call-compile ',form))))))
                              :parent ',(or parent nparent)
                              ,@(loop for option in options
                                      collect `',option)))
           ,@(loop for (def subname . body) in defs
                   collect `(,def (,name ,subname)
                              :home ,home
                              ,@body))
           ,@(when defun
               `((defun ,(if (stringp name) (read-symbol name) name) (&rest test-args)
                   (apply #'test (find-test ',name ,home-form) test-args))))
           ',name)))))

;; macroexpand:
(let ((*package* (find-package #A((9) base-char . "PARACHUTE")))) (setf (find-test (quote subtest) (find-package #A((9) base-char . "PARACHUTE"))) (ensure-test (quote test) :name (quote subtest) :home (find-package #A((9) base-char . "PARACHUTE")) :tests (list (lambda nil (fail (error "An expected failure."))) (lambda nil (fail (warn "An expected warning.") warning))) :parent (quote example))) (quote subtest))


[User]
Define a macro that eliminates this repetitive pattern:
(defclause summing-to-and-returning (vars &optional result-processor) "Same as summing-to, but also returns the value of each <vars> at the end of the loop." `((summing-to ,vars ,result-processor) ,@(mapcar (lambda (var) `(returning ,var)) (ensure-list vars))))

Issue: Macro call that should be transformed by defclause

(defclause summing-to-and-returning (vars &optional result-processor) "Same as summing-to, but also returns the value of each <vars> at the end of the loop." `((summing-to ,vars ,result-processor) ,@(mapcar (lambda (var) `(returning ,var)) (ensure-list vars))))

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

;; macroexpand:
(progn (defmacro summing-to-and-returning (vars &optional result-processor) "Same as summing-to, but also returns the value of each <vars> at the end of the loop." (sb-int:quasiquote ((summing-to #S(sb-impl::comma :expr vars :kind 0) #S(sb-impl::comma :expr result-processor :kind 0)) #S(sb-impl::comma :expr (mapcar (lambda (var) (sb-int:quasiquote (returning #S(sb-impl::comma :expr var :kind 0)))) (ensure-list vars)) :kind 2)))) (pushnew (quote summing-to-and-returning) *clauses*))


[User]
Write a Common Lisp macro to handle this code pattern:
(action (:after node-match) #'apply-lift)

Problem: Macro call that should be transformed by action

(action (:after node-match) #'apply-lift)

[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-match) (function apply-lift))


[User]
Write a Common Lisp macro to handle this code pattern:
(with-handle-interrupt (lambda () (format *error-output* "Interrupted")) (prog1 (apply #'clack.handler:run app server :port port :debug debug :use-thread use-thread (delete-from-plist args :server :port :debug :use-thread)) (when (and use-thread (not silent)) (format t "~&~:(~A~) server is started.~%Listening on ~A:~A.~%" server address port))))

Problem: Macro call that should be transformed by with-handle-interrupt

(with-handle-interrupt (lambda () (format *error-output* "Interrupted")) (prog1 (apply #'clack.handler:run app server :port port :debug debug :use-thread use-thread (delete-from-plist args :server :port :debug :use-thread)) (when (and use-thread (not silent)) (format t "~&~:(~A~) server is started.~%Listening on ~A:~A.~%" server address port))))

[Assistant]
(defmacro with-handle-interrupt (int-handler &body body)
  (let ((main (gensym "MAIN")))
    `(flet ((,main () ,@body))
       #+(or sbcl ccl clisp allegro ecl)
       (handler-case
           (let (#+ccl (ccl:*break-hook* (lambda (condition hook)
                                           (declare (ignore hook))
                                           (error condition))))
             (,main))
         (#+sbcl sb-sys:interactive-interrupt
          #+ccl  ccl:interrupt-signal-condition
          #+clisp system::simple-interrupt-condition
          #+ecl ext:interactive-interrupt
          #+allegro excl:interrupt-signal
          ()
           (funcall ,int-handler)))
       #-(or sbcl ccl clisp allegro ecl)
       (,main))))

;; macroexpand:
(flet ((#:main163 nil (prog1 (apply (function run) app server :port port :debug debug :use-thread use-thread (delete-from-plist args :server :port :debug :use-thread)) (when (and use-thread (not silent)) (format t "~&~:(~A~) server is started.~%Listening on ~A:~A.~%" server address port))))) (handler-case (let nil (#:main163)) (sb-sys:interactive-interrupt nil (funcall (lambda nil (format *error-output* "Interrupted"))))))


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

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

(acond (:foo))

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

;; macroexpand:
(let ((#:it :foo)) (if #:it #:it (acond)))


[User]
Write a Common Lisp macro to handle this code pattern:
(when (or (typep (node-slot expression) 'function-call) (typep (node-slot expression) 'infix-expression) (typep (node-slot expression) 'prefix-expression) (typep (node-slot expression) 'postfix-expression)) (format stream "~&~a" indent))

Problem: Macro call that should be transformed by when

(when (or (typep (node-slot expression) 'function-call) (typep (node-slot expression) 'infix-expression) (typep (node-slot expression) 'prefix-expression) (typep (node-slot expression) 'postfix-expression)) (format stream "~&~a" indent))

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

;; macroexpand:
(if (or (typep (node-slot expression) (quote function-call)) (typep (node-slot expression) (quote infix-expression)) (typep (node-slot expression) (quote prefix-expression)) (typep (node-slot expression) (quote postfix-expression))) (format stream "~&~a" indent))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(defgenerator product (&rest lists) "Iterates through each of the supplied lists with nested dolists, yielding an element from each for every iteration of the innermost loop. The yielded values cycle in an odometer-like fashion, with the first value changing seldom and the last changing on every yield. Eg: (product '(a b c d) '(x y)) -(values)-> (a x) (a y) (b x) (b y) (c x) (c y)... " (labels ((listholder (lists) (if (null lists) (lambda (stack) (apply #'yield (reverse stack))) (let ((nextfunc (listholder (cdr lists)))) (lambda (stack) (dolist (itm (car lists)) (funcall nextfunc (cons itm stack)))))))) (funcall (listholder lists) nil)))

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

(defgenerator product (&rest lists) "Iterates through each of the supplied lists with nested dolists, yielding an element from each for every iteration of the innermost loop. The yielded values cycle in an odometer-like fashion, with the first value changing seldom and the last changing on every yield. Eg: (product '(a b c d) '(x y)) -(values)-> (a x) (a y) (b x) (b y) (c x) (c y)... " (labels ((listholder (lists) (if (null lists) (lambda (stack) (apply #'yield (reverse stack))) (let ((nextfunc (listholder (cdr lists)))) (lambda (stack) (dolist (itm (car lists)) (funcall nextfunc (cons itm stack)))))))) (funcall (listholder lists) nil)))

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

;; macroexpand:
(defun product (&rest lists) "Iterates through each of the supplied lists with nested dolists, yielding an element from each for every iteration of the innermost loop. The yielded values cycle in an odometer-like fashion, with the first value changing seldom and the last changing on every yield. Eg: (product '(a b c d) '(x y)) -(values)-> (a x) (a y) (b x) (b y) (c x) (c y)... " (with-yield (labels ((listholder (lists) (if (null lists) (lambda (stack) (apply (function yield) (reverse stack))) (let ((nextfunc (listholder (cdr lists)))) (lambda (stack) (dolist (itm (car lists)) (funcall nextfunc (cons itm stack)))))))) (funcall (listholder lists) nil))))


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

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

(iterate nil)

[Assistant]
(defmacro ITERATE ...)

;; macroexpand:
(progn (tagbody #:ll-246 ((lambda ())) (go #:ll-246)) nil)


[User]
Define a macro that eliminates this repetitive pattern:
(is-true (with-*test-dribble* nil (explain! (run 'is1))))

Issue: Macro call that should be transformed by is-true

(is-true (with-*test-dribble* nil (explain! (run 'is1))))

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

;; macroexpand:
(if (with-*test-dribble* nil (explain! (run (quote is1)))) (add-result (quote test-passed) :test-expr (quote (with-*test-dribble* nil (explain! (run (quote is1)))))) (process-failure (quote (with-*test-dribble* nil (explain! (run (quote is1))))) "~S did not return a true value" (quote (with-*test-dribble* nil (explain! (run (quote is1)))))))


[User]
Write a Common Lisp macro to handle this code pattern:
(when (first in-decl) (push nil in-decl-item))

Problem: Macro call that should be transformed by when

(when (first in-decl) (push nil in-decl-item))

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

;; macroexpand:
(if (first in-decl) (push nil in-decl-item))


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

Problem: Macro call that should be transformed by THE

(the nil nil)

[Assistant]
(defmacro THE ...)

;; macroexpand:
(send self nil nil)


[User]
Define a macro that eliminates this repetitive pattern:
(defjs hello (x y) (return (+ x y)))

Issue: Macro call that should be transformed by defjs

(defjs hello (x y) (return (+ x y)))

[Assistant]
(defmacro defjs (name args &body body)
  "Define client side javascript. Works like defun; body is in lisp, with parenscript
   additions, like return. So (defjs hello (x y) (return (+ x y))) defines an adder.
   macro creates a lisp function which sends the javascript function over to the mongo
   server to be evaluated. Result is processed and returned to the reader.
   This will execute 10 times on the server :
   (mapcar (lambda (x) (hello 10 x)) (list 1 2 3 4 5 6 7 8 9 10))"
  `(let* ((js-body (parenscript:ps (lambda ,args ,@body))))
     (setf (gethash ',name *js-definitions*) js-body)
     (defun ,name ,args
       (get-element "retval" (car (docs (db.eval js-body ,@args)))))))

;; macroexpand:
(let* ((js-body (parenscript:ps (lambda (x y) (return (+ x y)))))) (setf (gethash (quote hello) *js-definitions*) js-body) (defun hello (x y) (get-element "retval" (car (docs (db.eval js-body x y))))))


[User]
Generate a defmacro form that transforms code like this:
(do+ (for x (in '(1 2 3))) (do+ (for y (in '(a b))) (collect (list x y) :into foo)))

Pattern to recognize: Macro call that should be transformed by do+

(do+ (for x (in '(1 2 3))) (do+ (for y (in '(a b))) (collect (list x y) :into foo)))

[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 (in (quote (1 2 3)))) (do+ (for y (in (quote (a b)))) (collect (list x y) :into foo)))


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

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

(lambda+ nil
  :key
  nil)

[Assistant]
(defmacro LAMBDA+ ...)

;; macroexpand:
(lambda ()
  (let+ nil
    :key
    nil))