[User]
Create a Common Lisp macro for the following transformation. Before code:
(make-stream-method pp-xml-value (s (value ratio) &optional colon-p at-p) (declare (ignore colon-p at-p)) (format s "~v$" *float-format-precision* value))

What needs to change: Macro call that should be transformed by make-stream-method

(make-stream-method pp-xml-value (s (value ratio) &optional colon-p at-p) (declare (ignore colon-p at-p)) (format s "~v$" *float-format-precision* value))

[Assistant]
(defmacro make-stream-method (name (s &rest args) &body body)
  `(progn
     (defmethod ,name ((,s stream) ,@args)
       ,@body)
     #+abcl
     (defmethod ,name ((,s xp::xp-structure) ,@args)
       ,@body)))

;; macroexpand:
(progn (defmethod pp-xml-value ((s stream) (value ratio) &optional colon-p at-p) (declare (ignore colon-p at-p)) (format s "~v$" *float-format-precision* value)))


[User]
Define a macro that eliminates this repetitive pattern:
(class/std example slot1 slot2 slot3)

Issue: Macro call that should be transformed by class/std

(class/std example slot1 slot2 slot3)

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

  (class/std example slot1 slot2 slot3)

  expands to:

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

  which expands to:

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

;; macroexpand:
(defclass/std example nil ((slot1 slot2 slot3)))


[User]
Generate a defmacro form that transforms code like this:
(builder (:backtrace :result-on-error `(500 (:content-type "text/plain") ("Internal Server Error"))) (lambda (env) (if (string= (getf env :path-info) "/error") (error "Error occured") '(200 () ("ok")))))

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

(builder (:backtrace :result-on-error `(500 (:content-type "text/plain") ("Internal Server Error"))) (lambda (env) (if (string= (getf env :path-info) "/error") (error "Error occured") '(200 () ("ok")))))

[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 (#:app190) (funcall (find-middleware :backtrace) #:app190 :result-on-error (sb-int:quasiquote (500 (:content-type "text/plain") ("Internal Server Error"))))))) :initial-value (to-app (lambda (env) (if (string= (getf env :path-info) "/error") (error "Error occured") (quote (200 nil ("ok")))))) :from-end t)


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

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

(dynenv-macrolet nil)

[Assistant]
(defmacro DYNENV-MACROLET ...)

;; macroexpand:
(macrolet nil)


[User]
Create a Common Lisp macro for the following transformation. Before code:
(action (:after node-application) #'rewrite-direct-application)

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

(action (:after node-application) #'rewrite-direct-application)

[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-application) (function rewrite-direct-application))


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

Issue: Macro call that should be transformed by DEFUN-ADVISABLE

(defun-advisable nil
    nil)

[Assistant]
(defmacro DEFUN-ADVISABLE ...)

;; macroexpand:
(let ((#:oldfn134
       (handler-case (symbol-function 'nil) (undefined-function nil nil))))
  (defun nil ())
  (make-advisable 'nil :arguments 'nil)
  (when
      (and #:oldfn134
           (not (eql (advisable-function-arguments #:oldfn134) :not-provided))
           (equal (advisable-function-arguments #:oldfn134) 'nil))
    (copy-advice #:oldfn134 (symbol-function 'nil))))


[User]
Define a macro that eliminates this repetitive pattern:
(ematch0 (remove-if-not (curry #'eq symbol) slots :key #'c2mop:slot-definition-name) ((list) (when slots (simple-style-warning "Found slots ~{~s~^, ~} but they are not EQ to ~s." (mapcar #'c2mop:slot-definition-name slots) symbol))) ((list slot) (return slot)))

Issue: Macro call that should be transformed by ematch0

(ematch0 (remove-if-not (curry #'eq symbol) slots :key #'c2mop:slot-definition-name) ((list) (when slots (simple-style-warning "Found slots ~{~s~^, ~} but they are not EQ to ~s." (mapcar #'c2mop:slot-definition-name slots) symbol))) ((list slot) (return slot)))

[Assistant]
(defmacro ematch0 (what &body clauses)
  `(match0 ,what
     ,@clauses
     (_ (error "level0 match error!"))))

;; macroexpand:
(match0 (remove-if-not (curry (function eq) symbol) slots :key (function sb-mop:slot-definition-name)) ((list) (when slots (simple-style-warning "Found slots ~{~s~^, ~} but they are not EQ to ~s." (mapcar (function sb-mop:slot-definition-name) slots) symbol))) ((list slot) (return slot)) (_ (error "level0 match error!")))


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

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

(make-$instance nil)

[Assistant]
(defmacro MAKE-$INSTANCE ...)

;; macroexpand:
(let ((class (symbol-value nil)))
  (funcall (mcs-slot-value class (index-of-basicnew-fn)) class))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(with-wcs-math-error-handling ((quot rem) (ftruncate x)) (check-wcs-math-result) (values rem quot))

Write a macro that addresses: Macro call that should be transformed by with-wcs-math-error-handling

(with-wcs-math-error-handling ((quot rem) (ftruncate x)) (check-wcs-math-result) (values rem quot))

[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* ((#:g233 x) (#:g234 nil) (#:g235 (list #:g233))) (declare (ignorable #:g234) (type list #:g235) (dynamic-extent #:g235)) (catch (quote return-from-with-wcs-math-error-handling) (multiple-value-bind (quot rem) (call-with-wcs-math-error-handler (quote ftruncate) #:g235) (flet ((check-wcs-math-result (&optional (ret quot) (arg-list #:g235)) (check-wcs-math-result ret arg-list))) (check-wcs-math-result) (values rem quot)))))


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

Problem: 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:
(deferror "42710" duplicate-object syntax-error-or-access-violation)

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

(deferror "42710" duplicate-object syntax-error-or-access-violation)

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

;; macroexpand:
(progn (define-condition duplicate-object (syntax-error-or-access-violation) nil) (setf (gethash "42710" *error-table*) (quote duplicate-object)))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(is 'foo 'foo "Foo with multiline description!")

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

(is 'foo 'foo "Foo with multiline description!")

[Assistant]
(defmacro is (got expected &rest args)
  (with-gensyms (duration result new-args desc)
    (once-only (expected)
      `(let* ((,new-args (list ,@args))
              (,desc (parse-description-and-test ,new-args)))
         (with-catching-errors (:description ,desc :expected ,expected)
           (with-duration ((,duration ,result) ,got)
             (test ,result ,expected ,new-args
                   :duration ,duration)))))))

;; macroexpand:
(let ((#:expected194 (quote foo))) (let* ((#:new-args192 (list "Foo with multiline description!")) (#:desc193 (parse-description-and-test #:new-args192))) (with-catching-errors (:description #:desc193 :expected #:expected194) (with-duration ((#:duration190 #:result191) (quote foo)) (test #:result191 #:expected194 #:new-args192 :duration #:duration190)))))


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

Problem: Macro call that should be transformed by ->

(-> :one :ignore-invariant t () (increment))

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

;; macroexpand:
(atomically :one :ignore-invariant t nil (increment))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(*> +comma+ +skip-space+)

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

(*> +comma+ +skip-space+)

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

;; macroexpand:
(lambda (#:*>-offset233) (multiple-value-bind (#:*>-res234 #:*>-next235) (funcall +comma+ #:*>-offset233) (if (ok? #:*>-res234) (funcall +skip-space+ #:*>-next235) (fail #:*>-next235))))


[User]
Define a macro that eliminates this repetitive pattern:
(-> :g (a) (+ a 4))

Issue: Macro call that should be transformed by ->

(-> :g (a) (+ a 4))

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

;; macroexpand:
(atomically :g (a) (+ a 4))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(defstore example (&key (a 1) (b (the number (init-b a)))))

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

(defstore example (&key (a 1) (b (the number (init-b a)))))

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

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (defun a-init-function152 (a #:a?158) (declare (ignorable a #:a?158)) (the number (init-b a))) (ensure-store (quote example) (quote (&key (a 1 #:a?158) (b (the number (a-init-function152 a #:a?158)) #:b?159))))))


[User]
You are a Common Lisp macro expert. Given this code pattern:
(define-option-expander packages (module &rest names) (setf (module-packages module) names))

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

(define-option-expander packages (module &rest names) (setf (module-packages module) names))

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

;; macroexpand:
(defmethod expand-option ((#:type142 (eql :packages)) module #:args141) (destructuring-bind (&rest names) #:args141 (setf (module-packages module) names)))


[User]
Generate a defmacro form that transforms code like this:
(defstore example (&optional (a (init-a)) (b a)))

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

(defstore example (&optional (a (init-a)) (b a)))

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

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (defun a-init-function152 nil (declare (ignorable)) (init-a)) (defun b-init-function154 (a #:a?153) (declare (ignorable a #:a?153)) a) (ensure-store (quote example) (quote (&optional (a (the t (a-init-function152)) #:a?153) (b (the t (b-init-function154 a #:a?153)) #:b?155))))))


[User]
Generate a defmacro form that transforms code like this:
(def-launched-iter nil
    :key
  nil)

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

(def-launched-iter nil
    :key
  nil)

[Assistant]
(defmacro DEF-LAUNCHED-ITER ...)

;; macroexpand:
(defun nil :key
  (let ((it
         (make-instance 'iterator :coro
                        (lambda-coro
                          nil))))
    (inext-or-error it)
    it))


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

Problem: Macro call that should be transformed by WITH*

(with* 'some-name)

[Assistant]
(defmacro WITH* ...)

;; macroexpand:
(multiple-value-bind (quote) nil (multiple-value-bind (some-name) nil))


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

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

(collect-last nil (progn))

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

;; macroexpand:
(common-lisp:let* ((#:generator-525 (generator nil))
                   #:items-519
                   (#:item-521 (progn)))
  (declare (type generator #:generator-525)
           (type (null-or t) #:item-521))
  (tagbody
   #:ll-526
    (setq #:items-519 (next-in #:generator-525 (go end)))
    (setq #:item-521 #:items-519)
    (go #:ll-526)
   end)
  #:item-521)


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

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

(loop)

[Assistant]
(defmacro LOOP ...)

;; macroexpand:
(block nil (tagbody #:g190 (progn) (go #:g190)))


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

Problem: Macro call that should be transformed by DEFMETHOD

(defmethod nil
  nil)

[Assistant]
(defmacro DEFMETHOD ...)

;; macroexpand:
(common-lisp:defmethod nil nil)


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

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

(and)

[Assistant]
(defmacro AND ...)

;; macroexpand:
t


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

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

(defsynonym nil nil)

[Assistant]
(defmacro DEFSYNONYM ...)

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (setf (get 'nil 'iterate::synonym) 'nil))


[User]
Define a macro that eliminates this repetitive pattern:
(-> 'some-name)

Issue: Macro call that should be transformed by ->

(-> 'some-name)

[Assistant]
(defmacro -> ...)

;; macroexpand:
'some-name


[User]
Generate a defmacro form that transforms code like this:
(in-compile-time nil
  nil)

Pattern to recognize: Macro call that should be transformed by IN-COMPILE-TIME

(in-compile-time nil
  nil)

[Assistant]
(defmacro IN-COMPILE-TIME ...)

;; macroexpand:
(macrolet ((#:macro142 (&environment ())
             nil))
  (#:macro142))


[User]
Generate a defmacro form that transforms code like this:
(defgenerator chain (&rest generators) "Chains a number of generators together head to tail. Eg: (chain (list->generator '(1 2 3) (list->generator '(6 7))) -> 1 2 3 6 7" (dolist (g generators) (yield-all g)))

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

(defgenerator chain (&rest generators) "Chains a number of generators together head to tail. Eg: (chain (list->generator '(1 2 3) (list->generator '(6 7))) -> 1 2 3 6 7" (dolist (g generators) (yield-all g)))

[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 chain (&rest generators) "Chains a number of generators together head to tail. Eg: (chain (list->generator '(1 2 3) (list->generator '(6 7))) -> 1 2 3 6 7" (with-yield (dolist (g generators) (yield-all g))))


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

Problem: Macro call that should be transformed by ITERATE

(iterate 'some-name)

[Assistant]
(defmacro ITERATE ...)

;; macroexpand:
(common-lisp:let* ((#:generator-265 (generator nil))
                   #:m-259
                   (#:generator-263 (generator nil))
                   #:m-260)
  (declare (type generator #:generator-265)
           (type generator #:generator-263))
  (tagbody
   #:ll-266
    (setq #:m-259 (next-in #:generator-265 (go end)))
    (setq #:m-260 (next-in #:generator-263 (go end)))
    ((lambda (quote some-name)) #:m-260 #:m-259)
    (go #:ll-266)
   end)
  nil)


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

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

(producing 'some-name)

[Assistant]
(defmacro PRODUCING ...)

;; macroexpand:
(non-opt-producing 'some-name)


[User]
Generate a defmacro form that transforms code like this:
(defun/1 ceil (x) (ceiling x))

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

(defun/1 ceil (x) (ceiling x))

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


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

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

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


[User]
Define a macro that eliminates this repetitive pattern:
(defstore nhadamard-product (y x &key (a 1)))

Issue: Macro call that should be transformed by defstore

(defstore nhadamard-product (y x &key (a 1)))

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

;; macroexpand:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (ensure-store (quote nhadamard-product) (quote (y x &key (a 1 #:a?151))))))


[User]
Create a Common Lisp macro for the following transformation. Before code:
(with-wcs-math-error-handling (ret (fceiling x)) (check-wcs-math-result))

What needs to change: Macro call that should be transformed by with-wcs-math-error-handling

(with-wcs-math-error-handling (ret (fceiling x)) (check-wcs-math-result))

[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* ((#:g242 x) (#:g243 nil) (#:g244 (list #:g242))) (declare (ignorable #:g243) (type list #:g244) (dynamic-extent #:g244)) (catch (quote return-from-with-wcs-math-error-handling) (multiple-value-bind (ret) (call-with-wcs-math-error-handler (quote fceiling) #:g244) (flet ((check-wcs-math-result (&optional (ret ret) (arg-list #:g244)) (check-wcs-math-result ret arg-list))) (check-wcs-math-result)))))


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

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

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