j14i/cl-macros huggingface dataset:
Create a Common Lisp macro for the following transformation. Before code:
(destructure-specialized-lambda-list descriptive-lambda-list vanilla-lambda-list type-list specialized-lambda-list (with-effective-qualifier generic-function qualifier (intern-hook generic-function hook-name type-list qualifier) `(progn (%defhook-fun ,hook-name ,vanilla-lambda-list ,@body) (%define-method-dispatch ,generic-function ,qualifier ,specialized-lambda-list))))

What needs to change: Macro call that should be transformed by destructure-specialized-lambda-list

Macro definition:
(defmacro destructure-specialized-lambda-list (descriptive-lambda-list-sym vanilla-lambda-list-sym type-list-sym specialized-lambda-list &body body)
  "if specialized-lambda-list is ((a integer) b):
descriptive-lambda-list will be ((x integer) (x t))
type-list will be (integer t) and vanilla-lambda-list is (a b)"
  (let ((item (gensym)))
    `(let* ((,descriptive-lambda-list-sym
             (loop :for ,item :in ,specialized-lambda-list
                :if (listp ,item)
                :collect ,item
                :else :collect (list ,item t)))
            (,vanilla-lambda-list-sym (mapcar #'first ,descriptive-lambda-list-sym))
            (,type-list-sym (mapcar #'second ,descriptive-lambda-list-sym)))
       (declare (ignorable ,descriptive-lambda-list-sym ,vanilla-lambda-list-sym ,type-list-sym))
       ,@body)))

Macroexpansion:
(let* ((descriptive-lambda-list (loop :for #:g126 :in specialized-lambda-list :if (listp #:g126) :collect #:g126 :else :collect (list #:g126 t))) (vanilla-lambda-list (mapcar (function first) descriptive-lambda-list)) (type-list (mapcar (function second) descriptive-lambda-list))) (declare (ignorable descriptive-lambda-list vanilla-lambda-list type-list)) (with-effective-qualifier generic-function qualifier (intern-hook generic-function hook-name type-list qualifier) (sb-int:quasiquote (progn (%defhook-fun #S(sb-impl::comma :expr hook-name :kind 0) #S(sb-impl::comma :expr vanilla-lambda-list :kind 0) #S(sb-impl::comma :expr body :kind 2)) (%define-method-dispatch #S(sb-impl::comma :expr generic-function :kind 0) #S(sb-impl::comma :expr qualifier :kind 0) #S(sb-impl::comma :expr specialized-lambda-list :kind 0))))))
Define a macro that eliminates this repetitive pattern:
(some-<>> nil :key nil)

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

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

Macroexpansion:
(let* ((#:g133 nil)
       (#:g133
        (if (null #:g133)
            nil
            (:key #:g133))))
  (if (null #:g133)
      nil
      (->> #:g133 nil)))
You are a Common Lisp macro expert. Given this code pattern:
(insert-char-class-tester (char-class (schar *string* start-pos)) (lambda (start-pos) (declare (fixnum start-pos)) (and (< start-pos *end-pos*) (char-class-test) (funcall next-fn (1+ start-pos)))))

Write a macro that addresses: Macro call that should be transformed by insert-char-class-tester

Macro definition:
(defmacro insert-char-class-tester ((char-class chr-expr) &body body)
  "Utility macro to replace each occurence of '\(CHAR-CLASS-TEST)
within BODY with the correct test (corresponding to CHAR-CLASS)
against CHR-EXPR."
  (with-rebinding (char-class)
    (with-unique-names (test-function)
      (flet ((substitute-char-class-tester (new)
               (subst new '(char-class-test) body
                      :test #'equalp)))
        `(let ((,test-function (test-function ,char-class)))
           ,@(substitute-char-class-tester
              `(funcall ,test-function ,chr-expr)))))))

Macroexpansion:
(let ((#:char-class155 char-class)) (let ((#:test-function156 (test-function #:char-class155))) (lambda (start-pos) (declare (fixnum start-pos)) (and (< start-pos *end-pos*) (funcall #:test-function156 (schar *string* start-pos)) (funcall next-fn (1+ start-pos))))))
Define a macro that eliminates this repetitive pattern:
(gatherer 'some-name)

Issue: Macro call that should be transformed by GATHERER

Macro definition:
(defmacro GATHERER ...)

Macroexpansion:
(common-lisp:let ((#:lastcons-452 (list nil)) #:lst-453)
  (declare (type cons #:lastcons-452)
           (type list #:lst-453))
  (setq #:lst-453 #:lastcons-452)
  (common-lisp:let (#:out-455)
    #'(lambda (#:items-451 result-p)
        (cond
         ((null result-p)
          (tagbody
            (setq #:lastcons-452
                    (setf (cdr #:lastcons-452) (cons #:items-451 nil)))))
         (t
          (progn
           (setq #:lst-453 (cdr #:lst-453))
           (setq #:out-455
                   (common-lisp:funcall 'some-name
                                        (common-lisp:funcall #'scan
                                                             #:lst-453))))
          #:out-455)))))
Create a Common Lisp macro for the following transformation. Before code:
(*let nil
  :key
  nil)

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

Macro definition:
(defmacro *LET ...)

Macroexpansion:
(let* ()
  :key
  nil)
Create a Common Lisp macro for the following transformation. Before code:
(with-store-entry (key store :quiet quiet) (when (item key store) (trc "overwriting item" key (item key store))) (setf (item key store) object))

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

Macro definition:
(defmacro with-store-entry ((key store &key quiet) &body body)
  `(prog1
       (progn
	 ,@body)
     (unless ,quiet
       (kick-c-link ,key ,store))))

Macroexpansion:
(prog1 (progn (when (item key store) (trc "overwriting item" key (item key store))) (setf (item key store) object)) (unless quiet (kick-c-link key store)))
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

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

Macroexpansion:
(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)))
Define a macro that eliminates this repetitive pattern:
(class/std example slot1 slot2 slot3)

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

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

Macroexpansion:
(defclass/std example nil ((slot1 slot2 slot3)))
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

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

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

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

Macroexpansion:
(macrolet nil)
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

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-application) (function rewrite-direct-application))
Define a macro that eliminates this repetitive pattern:
(defun-advisable nil
    nil)

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

Macro definition:
(defmacro DEFUN-ADVISABLE ...)

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

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

Macroexpansion:
(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!")))
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

Macro definition:
(defmacro MAKE-$INSTANCE ...)

Macroexpansion:
(let ((class (symbol-value nil)))
  (funcall (mcs-slot-value class (index-of-basicnew-fn)) class))
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

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

Macroexpansion:
(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)))))
Write a Common Lisp macro to handle this code pattern:
(drelet* nil
  (progn))

Problem: Macro call that should be transformed by DRELET*

Macro definition:
(defmacro DRELET* ...)

Macroexpansion:
(dynamic-relet* nil
  (progn))
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

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 duplicate-object (syntax-error-or-access-violation) nil) (setf (gethash "42710" *error-table*) (quote duplicate-object)))
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

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

Macroexpansion:
(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)))))
Write a Common Lisp macro to handle this code pattern:
(-> :one :ignore-invariant t () (increment))

Problem: Macro call that should be transformed by ->

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

Macroexpansion:
(atomically :one :ignore-invariant t nil (increment))
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 *>

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 (#:*>-offset233) (multiple-value-bind (#:*>-res234 #:*>-next235) (funcall +comma+ #:*>-offset233) (if (ok? #:*>-res234) (funcall +skip-space+ #:*>-next235) (fail #:*>-next235))))
Define a macro that eliminates this repetitive pattern:
(-> :g (a) (+ a 4))

Issue: Macro call that should be transformed by ->

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

Macroexpansion:
(atomically :g (a) (+ a 4))
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

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 #: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))))))
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

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 ((#:type142 (eql :packages)) module #:args141) (destructuring-bind (&rest names) #:args141 (setf (module-packages module) names)))
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

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

Macro definition:
(defmacro DEF-LAUNCHED-ITER ...)

Macroexpansion:
(defun nil :key
  (let ((it
         (make-instance 'iterator :coro
                        (lambda-coro
                          nil))))
    (inext-or-error it)
    it))
Write a Common Lisp macro to handle this code pattern:
(with* 'some-name)

Problem: Macro call that should be transformed by WITH*

Macro definition:
(defmacro WITH* ...)

Macroexpansion:
(multiple-value-bind (quote) nil (multiple-value-bind (some-name) nil))
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

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

Macroexpansion:
(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)
Create a Common Lisp macro for the following transformation. Before code:
(loop)

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

Macro definition:
(defmacro LOOP ...)

Macroexpansion:
(block nil (tagbody #:g190 (progn) (go #:g190)))
Write a Common Lisp macro to handle this code pattern:
(defmethod nil
  nil)

Problem: Macro call that should be transformed by DEFMETHOD

Macro definition:
(defmacro DEFMETHOD ...)

Macroexpansion:
(common-lisp:defmethod nil nil)
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

Macro definition:
(defmacro AND ...)

Macroexpansion:
t
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

Macro definition:
(defmacro DEFSYNONYM ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (setf (get 'nil 'iterate::synonym) 'nil))
Define a macro that eliminates this repetitive pattern:
(-> 'some-name)

Issue: Macro call that should be transformed by ->

Macro definition:
(defmacro -> ...)

Macroexpansion:
'some-name
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

Macro definition:
(defmacro IN-COMPILE-TIME ...)

Macroexpansion:
(macrolet ((#:macro142 (&environment ())
             nil))
  (#:macro142))
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

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

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