j14i/cl-macros huggingface dataset:
You are a Common Lisp macro expert. Given this code pattern:
(define-modf-rewrite cadadr (expr) `(car (cdadr ,(second expr))))

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

Macro definition:
(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))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (setf (gethash (quote cadadr) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (car (cdadr #S(sb-impl::comma :expr (second expr) :kind 0)))))))
You are a Common Lisp macro expert. Given this code pattern:
(draw scene (:rect :x 10 :y 10 :width 3980 :height 1980) :fill "none" :stroke "blue" :stroke-width 10)

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

Macro definition:
(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)))

Macroexpansion:
(let ((#:g152 (funcall (function make-svg-element) :rect (append (list :x 10 :y 10 :width 3980 :height 1980) (list :fill "none" :stroke "blue" :stroke-width 10))))) (add-element scene #:g152) #:g152)
Write a Common Lisp macro to handle this code pattern:
(for nil
    nil)

Problem: Macro call that should be transformed by FOR

Macro definition:
(defmacro FOR ...)

Macroexpansion:
(let ((#:|generator!120| nil))
  (assert (typep #:|generator!120| 'generator!))
  (unwind-protect
      (loop :while (has-next-p #:|generator!120|)
            :do (let ((nil (next #:|generator!120|))))))
  (stop #:|generator!120|))
Create a Common Lisp macro for the following transformation. Before code:
(actypecase 0 (string it))

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

Macro definition:
(defmacro actypecase (keyform &body cases)
  "Like CTYPECASE, except binds the result of the keyform to IT (via LET) for
the scope of the cases. Unlike CTYPECASE, new values possible stored by the
STORE-VALUE restart are not received by the keyform/place, but by IT."
  `(anaphoric ctypecase ,keyform ,@cases))

Macroexpansion:
(anaphoric ctypecase 0 (string it))
You are a Common Lisp macro expert. Given this code pattern:
(gathering nil
  :key
  nil)

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

Macro definition:
(defmacro GATHERING ...)

Macroexpansion:
(common-lisp:let ()
  :key
  nil
  (values))
Generate a defmacro form that transforms code like this:
(action (:before node-let) #'add-local-funs)

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

Macro definition:
(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))))

Macroexpansion:
(make-action (quote :before) (quote node-let) (function add-local-funs))
You are a Common Lisp macro expert. Given this code pattern:
(pop-preprocessor-directive-token tmp-token-list directive-symbol)

Write a macro that addresses: Macro call that should be transformed by pop-preprocessor-directive-token

Macro definition:
(defmacro pop-preprocessor-directive-token (token-list directive-name &key (errorp t))
  "Pops the next token in TOKEN-LIST ignoring `+whitespace-marker+'"
  (with-gensyms (head_)
    `(let ((,head_
             (check-and-pop-pp-directive-token-1 ,token-list ,directive-name ,errorp)))
       (if (eq +whitespace-marker+ ,head_)
           (check-and-pop-pp-directive-token-1 ,token-list ,directive-name ,errorp)
           ,head_))))

Macroexpansion:
(let ((#:head_266 (check-and-pop-pp-directive-token-1 tmp-token-list directive-symbol t))) (if (eq +whitespace-marker+ #:head_266) (check-and-pop-pp-directive-token-1 tmp-token-list directive-symbol t) #:head_266))
Define a macro that eliminates this repetitive pattern:
(defclause-driver (for var in-file filename &optional using (reader '#'read)) "Forms in a file" (top-level-check) (return-stream-driver-code var filename reader :file generate))

Issue: Macro call that should be transformed by defclause

Macro definition:
(defmacro defclause (clause-template &body body)
  (define-clause 'defun clause-template body nil))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (defun clause-for-in-file-6 (&key ((:for var)) ((:in-file filename)) ((:using reader) (quote (function read))) generate) "Forms in a file" (top-level-check) (return-stream-driver-code var filename reader :file generate)) (install-clause-info (quote (for :in-file)) (quote (for :in-file &optional :using)) (quote clause-for-in-file-6) "Forms in a file" t) (quote (for var in-file filename &optional using (reader (quote (function read))))))
Write a Common Lisp macro to handle this code pattern:
(ematch0 slots ((list) nil) ((list* (list name pattern) rest) (list* (list name pattern) (parse-slots rest))) ((list something) (etypecase something (keyword (error "the last slot is a keyword!")) (symbol (list (list something something))))) ((list something next) (etypecase something (keyword (list (list something next))) (symbol (list* (list something something) (parse-slots (list next)))))) ((list* something next rest) (etypecase something (keyword (list* (list something next) (parse-slots rest))) (symbol (list* (list something something) (parse-slots (list* next rest)))))))

Problem: Macro call that should be transformed by ematch0

Macro definition:
(defmacro ematch0 (what &body clauses)
  `(match0 ,what
     ,@clauses
     (_ (error "level0 match error!"))))

Macroexpansion:
(match0 slots ((list) nil) ((list* (list name pattern) rest) (list* (list name pattern) (parse-slots rest))) ((list something) (etypecase something (keyword (error "the last slot is a keyword!")) (symbol (list (list something something))))) ((list something next) (etypecase something (keyword (list (list something next))) (symbol (list* (list something something) (parse-slots (list next)))))) ((list* something next rest) (etypecase something (keyword (list* (list something next) (parse-slots rest))) (symbol (list* (list something something) (parse-slots (list* next rest)))))) (_ (error "level0 match error!")))
You are a Common Lisp macro expert. Given this code pattern:
(defstore example (a &rest args))

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

Macro definition:
(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)))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (ensure-store (quote example) (quote (a &rest args)))))
Write a Common Lisp macro to handle this code pattern:
(defjsmacro nil nil)

Problem: Macro call that should be transformed by DEFJSMACRO

Macro definition:
(defmacro DEFJSMACRO ...)

Macroexpansion:
(defpsmacro nil
    nil)
Create a Common Lisp macro for the following transformation. Before code:
(with-yield
  nil
  (progn))

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

Macro definition:
(defmacro WITH-YIELD ...)

Macroexpansion:
(isolate-cont
  (enable-yield
    nil
    nil
    (progn)))
Write a Common Lisp macro to handle this code pattern:
(define-alias-binding nconc nconcing)

Problem: Macro call that should be transformed by define-alias-binding

Macro definition:
(defmacro define-alias-binding (name referenced-binding-name)
  `(progn (setf (binding ',name) ',referenced-binding-name)
          ',name))

Macroexpansion:
(progn (setf (binding (quote nconc)) (quote nconcing)) (quote nconc))
You are a Common Lisp macro expert. Given this code pattern:
(match* (s1 s2) (((list* (list 'eql o1) s1) (list* (list 'eql o2) s2)) (if (eql o1 o2) (specializer< s1 s2) :equal)) (((list* (list 'eql _) _) _) :less) ((_ (list* (list 'eql _) _)) :greater) (((list* type1 s1) (list* type2 s2)) (let ((class1 (find-class type1)) (class2 (find-class type2))) (ensure-finalized class1) (ensure-finalized class2) (let ((prec1 (rest (class-precedence-list class1))) (prec2 (rest (class-precedence-list class2)))) (cond ((member class2 prec1) :less) ((member class1 prec2) :greater) ((eq class1 class2) (specializer< s1 s2)) (t (or (when (and s1 s2) (let ((order (specializer< s1 s2))) (unless (eq order :equal) order))) (if (string< (class-name class1) (class-name class2)) :less :greater))))))))

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

Macro definition:
(defmacro match* ((&rest things) &body clauses)
  `(multiple-value-match (values ,@things)
     ,@clauses))

Macroexpansion:
(multiple-value-match (values s1 s2) (((list* (list (quote eql) o1) s1) (list* (list (quote eql) o2) s2)) (if (eql o1 o2) (specializer< s1 s2) :equal)) (((list* (list (quote eql) _) _) _) :less) ((_ (list* (list (quote eql) _) _)) :greater) (((list* type1 s1) (list* type2 s2)) (let ((class1 (find-class type1)) (class2 (find-class type2))) (ensure-finalized class1) (ensure-finalized class2) (let ((prec1 (rest (class-precedence-list class1))) (prec2 (rest (class-precedence-list class2)))) (cond ((member class2 prec1) :less) ((member class1 prec2) :greater) ((eq class1 class2) (specializer< s1 s2)) (t (or (when (and s1 s2) (let ((order (specializer< s1 s2))) (unless (eq order :equal) order))) (if (string< (class-name class1) (class-name class2)) :less :greater))))))))
Write a Common Lisp macro to handle this code pattern:
(defun-compile-time form-callees (form environment) (walk #'(lambda (form form-type) (case form-type ((function-symbol function-setf) (list (second form))) ((symbol-call setf-call) (list (first form))) (otherwise '()))) #'(lambda (&optional (x nil x?) y) (if x? (union x y :test #'equal) '())) t nil t form environment))

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

Macro definition:
(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))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (common-lisp:defun form-callees (form environment) (walk (function (lambda (form form-type) (case form-type ((function-symbol function-setf) (list (second form))) ((symbol-call setf-call) (list (first form))) (otherwise (quote nil))))) (function (lambda (&optional (x nil x?) y) (if x? (union x y :test (function equal)) (quote nil)))) t nil t form environment)) (eval-when (:compile-toplevel) (compile (quote form-callees))))
Generate a defmacro form that transforms code like this:
(define-op (:union-all conjunctive-op))

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

Macro definition:
(defmacro define-op ((op-name struct-type &key sql-op-name include-slots (package (find-package '#:sxql/operator))) &body body)
  (check-type op-name symbol)
  (let ((struct-name (intern (concatenate 'string (symbol-name op-name) #.(string :-op)) package)))
    `(defstruct (,struct-name (:include ,struct-type
                               (name ,(or sql-op-name
                                          (with-output-to-string (s)
                                            (loop for c across (symbol-name op-name)
                                                  if (char= c #\-)
                                                    do (write-char #\Space s)
                                                  else
                                                    do (write-char c s)))))
                               ,@include-slots)
                              (:constructor ,(intern (concatenate 'string
                                                                  #.(string :make-)
                                                                  (symbol-name op-name)
                                                                  #.(string :-op))
                                                     package)
                                  ,(ecase struct-type
                                     ((unary-op
                                       unary-splicing-op
                                       unary-postfix-op) '(var))
                                     ((infix-op
                                       infix-splicing-op
                                       infix-list-op) '(left right))
                                     (conjunctive-op '(&rest expressions)))))
       ,@body)))

Macroexpansion:
(defstruct (union-all-op (:include conjunctive-op (name "UNION ALL")) (:constructor make-union-all-op (&rest expressions))))
Create a Common Lisp macro for the following transformation. Before code:
(->> 'some-name)

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

Macro definition:
(defmacro ->> ...)

Macroexpansion:
'some-name
Define a macro that eliminates this repetitive pattern:
(defstore example (&rest args))

Issue: Macro call that should be transformed by defstore

Macro definition:
(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)))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (ensure-store (quote example) (quote (&rest args)))))
Define a macro that eliminates this repetitive pattern:
(mvlet* nil
  nil)

Issue: Macro call that should be transformed by MVLET*

Macro definition:
(defmacro MVLET* ...)

Macroexpansion:
(progn nil)
You are a Common Lisp macro expert. Given this code pattern:
(do-notation bind-either ((sum (inc-either 1)) (str (either->string sum))) str)

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

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

Macroexpansion:
(progn (bind-either (lambda (sum) (bind-either (lambda (str) str) (either->string sum))) (inc-either 1)))
You are a Common Lisp macro expert. Given this code pattern:
(define-option-expander documentation (package documentation) (setf (documentation package T) documentation))

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

Macro definition:
(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))))

Macroexpansion:
(defmethod expand-option ((#:type124 (eql :documentation)) package #:args123) (destructuring-bind (documentation) #:args123 (setf (documentation package t) documentation)))
Write a Common Lisp macro to handle this code pattern:
(static-dispatch-test-hook)

Problem: Macro call that should be transformed by static-dispatch-test-hook

Macro definition:
(defmacro static-dispatch-test-hook ()
  "A form of this macro is inserted in the output of the
   STATIC-DISPATCH compiler macro, in order to allow certain test code
   to be inserted, by shadowing this macro using MACROLET. The
   global expands to NIL."

  nil)

Macroexpansion:
nil
You are a Common Lisp macro expert. Given this code pattern:
(with-effective-qualifier generic-function qualifier `(progn (%load-specializers-to-table ,generic-function ,type-list ,qualifier) ,(remove :unqualified `(defmethod ,generic-function ,qualifier ,descriptive-lambda-list ,@body) :end (if (eql :unqualified qualifier) 3 0))))

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

Macro definition:
(defmacro with-effective-qualifier (gf-name qualifier &body body)
  "take generic function and a symbol bound to a qualifier and mask that symbol with the effective qualifier.

The effective qualifier is the default qualifier for the given generic function should there be one defined by
a define-hook-generic form."
  `(let ((,qualifier
          (effective-qualifier ,gf-name ,qualifier)))
     ,@body))

Macroexpansion:
(let ((qualifier (effective-qualifier generic-function qualifier))) (sb-int:quasiquote (progn (%load-specializers-to-table #S(sb-impl::comma :expr generic-function :kind 0) #S(sb-impl::comma :expr type-list :kind 0) #S(sb-impl::comma :expr qualifier :kind 0)) #S(sb-impl::comma :expr (remove :unqualified (sb-int:quasiquote (defmethod #S(sb-impl::comma :expr generic-function :kind 0) #S(sb-impl::comma :expr qualifier :kind 0) #S(sb-impl::comma :expr descriptive-lambda-list :kind 0) #S(sb-impl::comma :expr body :kind 2))) :end (if (eql :unqualified qualifier) 3 0)) :kind 0))))
You are a Common Lisp macro expert. Given this code pattern:
(define-option-expander local-nicknames (package &rest nicknames) (loop for (nickname name) in nicknames do (trivial-package-local-nicknames:add-package-local-nickname nickname name package)))

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

Macro definition:
(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))))

Macroexpansion:
(defmethod expand-option ((#:type140 (eql :local-nicknames)) package #:args139) (destructuring-bind (&rest nicknames) #:args139 (loop for (nickname name) in nicknames do (sb-ext:add-package-local-nickname nickname name package))))
You are a Common Lisp macro expert. Given this code pattern:
(switch (13 :test =) (12 :oops) (13.0 :yay))

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

Macro definition:
(defmacro switch (&whole whole (object &key (test 'eql) (key 'identity))
                         &body clauses)
  "Evaluates first matching clause, returning its values, or evaluates and
returns the values of T or OTHERWISE if no keys match."
  (generate-switch-body whole object clauses test key))

Macroexpansion:
(let ((#:value129 (identity 13))) (cond ((= #:value129 12) :oops) ((= #:value129 13.0) :yay) (t nil)))
Create a Common Lisp macro for the following transformation. Before code:
(defsynonym :search :find)

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

Macro definition:
(defmacro defsynonym (symbol synonym)
  "Set SYNONYM for a SYMBOL. "
  `(eval-always
     (setf (get ',symbol 'synonym) ',synonym)))

Macroexpansion:
(eval-always (setf (get (quote :search) (quote synonym)) (quote :find)))
You are a Common Lisp macro expert. Given this code pattern:
(with nil
  :key
  nil)

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

Macro definition:
(defmacro WITH ...)

Macroexpansion:
(progn :key nil)
Create a Common Lisp macro for the following transformation. Before code:
(check-declaration-env nil)

What needs to change: Macro call that should be transformed by CHECK-DECLARATION-ENV

Macro definition:
(defmacro CHECK-DECLARATION-ENV ...)

Macroexpansion:
(let ()
  (let ((#:new120 (%check-declaration-env nil nil nil)))
    (setq nil #:new120)))
Write a Common Lisp macro to handle this code pattern:
(alet (1+ 1) (1+ it))

Problem: Macro call that should be transformed by alet

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

Macroexpansion:
(anaphoric ignore-first (1+ 1) (progn (1+ it)))
Define a macro that eliminates this repetitive pattern:
(augment free-vars (free-vars (second binding) bound-vars))

Issue: Macro call that should be transformed by augment

Macro definition:
(defmacro augment (var stuff)
  `(setf ,var (nconc ,var ,stuff)))

Macroexpansion:
(setf free-vars (nconc free-vars (free-vars (second binding) bound-vars)))
You are a Common Lisp macro expert. Given this code pattern:
(with-dynenv nil
  nil)

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

Macro definition:
(defmacro WITH-DYNENV ...)

Macroexpansion:
(multiple-value-bind (#:var-expansion126 #:var-expanded-p127)
    (macroexpand-1 'var-space nil)
  (multiple-value-bind (#:fun-expansion128 #:fun-expanded-p129)
      (macroexpand-1 'fun-space nil)
    (let ((*var-space* (when #:var-expanded-p127 #:var-expansion126))
          (*fun-space* (when #:fun-expanded-p129 #:fun-expansion128))
          (*within-captured-dynenv* t))
      nil)))