Instruction:
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

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

Output:
(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)))

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


Instruction:
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

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

Output:
(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))))

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


Instruction:
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

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

Output:
(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)))

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


Instruction:
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

Input:
(def-launched-iter nil
    :key
  nil)

Output: (defmacro DEF-LAUNCHED-ITER ...)

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


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

Problem: Macro call that should be transformed by WITH*

Input: (with* 'some-name)

Output: (defmacro WITH* ...)

(multiple-value-bind (quote) nil (multiple-value-bind (some-name) nil))


Instruction:
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

Input: (collect-last nil (progn))

Output: (defmacro COLLECT-LAST ...)

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


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

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

Input: (loop)

Output: (defmacro LOOP ...)

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


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

Problem: Macro call that should be transformed by DEFMETHOD

Input:
(defmethod nil
  nil)

Output: (defmacro DEFMETHOD ...)


Instruction:
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

Input: (and)

Output: (defmacro AND ...)


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

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

Input: (defsynonym nil nil)

Output: (defmacro DEFSYNONYM ...)

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


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

Issue: Macro call that should be transformed by ->

Input: (-> 'some-name)

Output: (defmacro -> ...)


Instruction:
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

Input:
(in-compile-time nil
  nil)

Output: (defmacro IN-COMPILE-TIME ...)

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


Instruction:
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

Input: (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)))

Output:
(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))))

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


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

Problem: Macro call that should be transformed by ITERATE

Input: (iterate 'some-name)

Output: (defmacro ITERATE ...)

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


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

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

Input: (producing 'some-name)

Output: (defmacro PRODUCING ...)


Instruction:
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

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

Output:
(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)))))

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


Instruction:
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

Input: (define-modf-rewrite ninth (expr) `(car (cddddr (cddddr ,(second expr)))))

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

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


Instruction:
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

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

Output:
(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)))

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


Instruction:
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

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

Output:
(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))))))

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


Instruction:
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

Input: (define-modf-rewrite caaddr (expr) `(car (caddr ,(second expr))))

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

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