j14i/cl-macros huggingface dataset:
Write a Common Lisp macro to handle this code pattern:
(defsynonym :reducing :reduce)

Problem: 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 :reducing) (quote synonym)) (quote :reduce)))
Create a Common Lisp macro for the following transformation. Before code:
(with-interleaving `(with-interleaving ,@(loop for part in (rest form) collect (remove-bindings bindings part))))

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

Macro definition:
(defmacro with-interleaving (&body body)
  (let* ((root (copy-list (pop body)))
         (current root))
    (dolist (form body root)
      (let ((form (copy-list form)))
        (when form
          (setf (cdr (last current)) (cons form NIL))
          (setf current form))))))

Macroexpansion:
(sb-int:quasiquote (with-interleaving #S(sb-impl::comma :expr (loop for part in (rest form) collect (remove-bindings bindings part)) :kind 2)))
Define a macro that eliminates this repetitive pattern:
(f nil
  (progn))

Issue: Macro call that should be transformed by F

Macro definition:
(defmacro F ...)

Macroexpansion:
(lambda () (progn))
Define a macro that eliminates this repetitive pattern:
(enable-readtime-wrapper-syntax nil (progn))

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

Macro definition:
(defmacro ENABLE-READTIME-WRAPPER-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-readtime-wrapper-syntax-in-readtable nil (progn))
  (values))
Create a Common Lisp macro for the following transformation. Before code:
(quasiquote-expand-1 'list (butlast x))

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

Macro definition:
(defmacro quasiquote (x) (quasiquote-expand x))

Macroexpansion:
(quasiquote-expand-1 (quote list) (butlast x))
Write a Common Lisp macro to handle this code pattern:
(defsynonym :with with)

Problem: 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 :with) (quote synonym)) (quote with)))
You are a Common Lisp macro expert. Given this code pattern:
(defstore example (a &optional (b (the real (compute-default a))) (c (the real (1+ b)))))

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

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 (defun a-init-function152 (a) (declare (ignorable a)) (the real (compute-default a))) (defun b-init-function154 (a b #:b?160) (declare (ignorable a b #:b?160)) (the real (1+ b))) (ensure-store (quote example) (quote (a &optional (b (the real (a-init-function152 a)) #:b?160) (c (the real (b-init-function154 a b #:b?160)) #:c?161))))))
Create a Common Lisp macro for the following transformation. Before code:
(action (:traverse node-application node bound-variables) (unless (tracked-variable-p (node-application-rator node) bound-variables) (funcall *traverse* (node-application-rator node) bound-variables)) (loop :for rand :in (node-application-rands node) :do (funcall *traverse* rand bound-variables)) (traverse-keyword-rands (node-application-keyword-rands node) bound-variables) node)

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

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 :traverse) (quote node-application) (lambda (node bound-variables) (declare (type node-application node)) (unless (tracked-variable-p (node-application-rator node) bound-variables) (funcall *traverse* (node-application-rator node) bound-variables)) (loop :for rand :in (node-application-rands node) :do (funcall *traverse* rand bound-variables)) (traverse-keyword-rands (node-application-keyword-rands node) bound-variables) node))
Create a Common Lisp macro for the following transformation. Before code:
(ps-doc
  'some-name)

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

Macro definition:
(defmacro PS-DOC ...)

Macroexpansion:
"'someName';"
Create a Common Lisp macro for the following transformation. Before code:
(ƒ→ nil nil)

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

Macro definition:
(defmacro Ƒ→ ...)

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

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

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

Macroexpansion:
(progn (declaim (inline %unassociate-name-from-readtable)) (defun %unassociate-name-from-readtable (name readtable) "Remove the association between NAME and READTABLE" (progn (assert (eq readtable (gethash name *named-readtables*))) (remhash name *named-readtables*))))
Generate a defmacro form that transforms code like this:
(-> :tag-2 ((a b)) (concatenate 'string a b " World!"))

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

Macro definition:
(defmacro -> (invariant &body args)
  "See flow:atomically"
  `(atomically ,invariant ,@args))

Macroexpansion:
(atomically :tag-2 ((a b)) (concatenate (quote string) a b " World!"))
Generate a defmacro form that transforms code like this:
(without-package-lock (:common-lisp #+lispworks :implementation) (defmethod documentation ((name symbol) (doc-type (eql 'readtable))) (let ((readtable (find-readtable name))) (and readtable (gethash readtable *readtable-to-docstring*)))) (defmethod documentation ((readtable readtable) (doc-type (eql 'readtable))) (gethash readtable *readtable-to-docstring*)) (defmethod (setf documentation) (docstring (name symbol) (doc-type (eql 'readtable))) (let ((readtable (find-readtable name))) (unless readtable (error 'readtable-does-not-exist :readtable-name name)) (setf (gethash readtable *readtable-to-docstring*) docstring))) (defmethod (setf documentation) (docstring (readtable readtable) (doc-type (eql 'readtable))) (setf (gethash readtable *readtable-to-docstring*) docstring)))

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

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

Macroexpansion:
(progn (defmethod documentation ((name symbol) (doc-type (eql (quote readtable)))) (let ((readtable (find-readtable name))) (and readtable (gethash readtable *readtable-to-docstring*)))) (defmethod documentation ((readtable readtable) (doc-type (eql (quote readtable)))) (gethash readtable *readtable-to-docstring*)) (defmethod (setf documentation) (docstring (name symbol) (doc-type (eql (quote readtable)))) (let ((readtable (find-readtable name))) (unless readtable (error (quote readtable-does-not-exist) :readtable-name name)) (setf (gethash readtable *readtable-to-docstring*) docstring))) (defmethod (setf documentation) (docstring (readtable readtable) (doc-type (eql (quote readtable)))) (setf (gethash readtable *readtable-to-docstring*) docstring)))
Generate a defmacro form that transforms code like this:
(with-component-testers (a b #'pathname-type) (components-are-member '(nil :wild :unspecific)) (components-are-string=))

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

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

Macroexpansion:
(let* ((#:g147 (function pathname-type)) (a (funcall #:g147 a)) (b (funcall #:g147 b))) (labels ((components-are (test) (and (funcall test a) (funcall test b))) (components-are-member (values) (and (member a values :test (function eql)) (member b values :test (function eql)) (eql a b))) (components-are-string= nil (and (stringp a) (stringp b) (string= a b))) (components-are-every (test) (and (consp a) (consp b) (every test a b)))) (declare (ignorable (function components-are) (function components-are-member) (function components-are-string=) (function components-are-every))) (if (or (components-are-member (quote (nil :wild :unspecific))) (components-are-string=)) (values t a b) nil)))
Generate a defmacro form that transforms code like this:
(c? (when (kv-collector self) (funcall (kv-collector self) (^value))))

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

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

Macroexpansion:
(make-c-dependent :code (quote ((when (kv-collector self) (funcall (kv-collector self) (^value))))) :value-state :unevaluated :rule (c-lambda (when (kv-collector self) (funcall (kv-collector self) (^value)))))
Define a macro that eliminates this repetitive pattern:
(deferror "23001" restrict-violation integrity-violation)

Issue: Macro call that should be transformed by deferror

Macro definition:
(defmacro deferror (code typename &optional (superclass 'database-error))
  `(progn (define-condition ,typename (,superclass) ())
          (setf (gethash ,code *error-table*) ',typename)))

Macroexpansion:
(progn (define-condition restrict-violation (integrity-violation) nil) (setf (gethash "23001" *error-table*) (quote restrict-violation)))
Write a Common Lisp macro to handle this code pattern:
(undefreply nil)

Problem: Macro call that should be transformed by UNDEFREPLY

Macro definition:
(defmacro UNDEFREPLY ...)

Macroexpansion:
(undefine-reply 'nil :qualifiers 'nil :participants `nil)
Generate a defmacro form that transforms code like this:
(when (node-slot shared) (make-proxy shared comma))

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

Macro definition:
(defmacro when (test &body forms)
  `(if ,test
	   ,(cl:if (cadr forms)
			   `(progn ,@forms)
			   (car forms))))

Macroexpansion:
(if (node-slot shared) (make-proxy shared comma))
Write a Common Lisp macro to handle this code pattern:
(keep-bops nil)

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

Macro definition:
(defmacro KEEP-BOPS ...)

Macroexpansion:
(eval-when (:load-toplevel :compile-toplevel :execute)
  (progn
   (init-binfix)
   (unless nil
     (setq *binfix*
             (delete nil
                     (mapcar
                      (lambda (bs)
                        (setq bs
                                (delete-if
                                 (lambda (b)
                                   (unless (member (car b) '(nil))
                                     (remprop (car b) 'properties)
                                     t))
                                 bs)))
                      *binfix*)))
     (assign-properties))))
Write a Common Lisp macro to handle this code pattern:
(match0 (remove nil (list (hyphened) (concname) (nameonly))) ((list sym) sym) ((list) nil) (readers (ambiguous-slot-error "Multiple candidates of the accessor function: ~{~a~^, ~}" readers)))

Problem: Macro call that should be transformed by match0

Macro definition:
(defmacro match0 (*what* &body clauses &environment *env*)
  (once-only (*what*)
    (parse-patterns clauses)))

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

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

Macro definition:
(defmacro *LET ...)

Macroexpansion:
(let* ()
  nil)
Define a macro that eliminates this repetitive pattern:
(define-custom-var (:object-value *object-value-handler*))

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

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

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (pushnew (quote (*object-value-handler* . :object-value)) *custom-vars* :test (function equal)) (defvar *object-value-handler*)))
You are a Common Lisp macro expert. Given this code pattern:
(assert-values ("deleted foo") (foo 'nothing) (foo+1 'nothing) (bar 2) (bar-1 1))

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

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

Macroexpansion:
(progn (trc "deleted foo") (assert (eql (value foo) (quote nothing))) (assert (eql (value foo+1) (quote nothing))) (assert (eql (value bar) 2)) (assert (eql (value bar-1) 1)))
Define a macro that eliminates this repetitive pattern:
(λλ)

Issue: Macro call that should be transformed by ΛΛ

Macro definition:
(defmacro ΛΛ ...)

Macroexpansion:
(lambda (&optional α) (cond))
Create a Common Lisp macro for the following transformation. Before code:
(collect-product 'some-name)

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

Macro definition:
(defmacro COLLECT-PRODUCT ...)

Macroexpansion:
(common-lisp:let* ((#:generator-131 (generator 'some-name))
                   #:numbers-127
                   (#:mul-128 1))
  (declare (type generator #:generator-131)
           (type number #:mul-128))
  (tagbody
   #:ll-132
    (setq #:numbers-127 (next-in #:generator-131 (go end)))
    (setq #:mul-128 (* #:mul-128 #:numbers-127))
    (go #:ll-132)
   end)
  #:mul-128)
Write a Common Lisp macro to handle this code pattern:
(do-notation bind-maybe ((sum nothing) (str (maybe->string sum))) (print str))

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

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-maybe (lambda (sum) (bind-maybe (lambda (str) (print str)) (maybe->string sum))) nothing))
Define a macro that eliminates this repetitive pattern:
(action (:after node-variable node bound-variables) (when (and (eq name (node-variable-value node)) (not (member name bound-variables :test #'eq))) (copy-node value (node-type node))))

Issue: Macro call that should be transformed by action

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 :after) (quote node-variable) (lambda (node bound-variables) (declare (type node-variable node)) (when (and (eq name (node-variable-value node)) (not (member name bound-variables :test (function eq)))) (copy-node value (node-type node)))))
Generate a defmacro form that transforms code like this:
(defsynonym next :next)

Pattern to recognize: 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 next) (quote synonym)) (quote :next)))
Write a Common Lisp macro to handle this code pattern:
(count-of nil
  (progn))

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

Macro definition:
(defmacro COUNT-OF ...)

Macroexpansion:
(lc (nil (progn)) count)
Create a Common Lisp macro for the following transformation. Before code:
(with-cached-reader-conditionals)

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

Macro definition:
(defmacro WITH-CACHED-READER-CONDITIONALS ...)

Macroexpansion:
(call-with-cached-reader-conditionals (lambda ()))
Create a Common Lisp macro for the following transformation. Before code:
(*> (char #\\) (alt (<$ #\newline (char #\n)) (<$ #\tab (char #\t)) (<$ #\return (char #\r)) (<$ #\backspace (char #\b)) (<$ #\page (char #\f))))

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

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

Macroexpansion:
(lambda (#:*>-offset197) (multiple-value-bind (#:*>-res198 #:*>-next199) (funcall (char #\REVERSE_SOLIDUS) #:*>-offset197) (if (ok? #:*>-res198) (funcall (alt (<$ #\Newline (char #\LATIN_SMALL_LETTER_N)) (<$ #\Tab (char #\LATIN_SMALL_LETTER_T)) (<$ #\Return (char #\LATIN_SMALL_LETTER_R)) (<$ #\Backspace (char #\LATIN_SMALL_LETTER_B)) (<$ #\Page (char #\LATIN_SMALL_LETTER_F))) #:*>-next199) (fail #:*>-next199))))
Write a Common Lisp macro to handle this code pattern:
(some-<>>)

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

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

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

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

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

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