j14i/cl-macros huggingface dataset:
Write a Common Lisp macro to handle this code pattern:
(signal-syntax-error "Illegal back-reference: ~S." parse-tree)

Problem: Macro call that should be transformed by signal-syntax-error

Macro definition:
(defmacro signal-syntax-error (format-control &rest format-arguments)
  `(signal-syntax-error* nil ,format-control ,@format-arguments))

Macroexpansion:
(signal-syntax-error* nil "Illegal back-reference: ~S." parse-tree)
Create a Common Lisp macro for the following transformation. Before code:
(mvlet* ((left-cases right-cases (halves cases)) (split (caar right-cases))) `(if (< ,keyform ,split) ,(rec keyform left-cases) ,(rec keyform right-cases)))

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

Macro definition:
(defmacro mvlet* ((&rest bindings) &body body &environment env)
  "Expand a series of nested `multiple-value-bind' forms.

`mvlet*' is similar in intent to Scheme’s `let-values', but with a
different and less parenthesis-intensive syntax. Each binding is a
list of

    (var var*... expr)

A simple example should suffice to show both the implementation and
the motivation:

    (defun uptime (seconds)
      (mvlet* ((minutes seconds (truncate seconds 60))
               (hours minutes (truncate minutes 60))
               (days hours (truncate hours 24)))
        (declare ((integer 0 *) days hours minutes seconds))
        (fmt \"~d day~:p, ~d hour~:p, ~d minute~:p, ~d second~:p\"
             days hours minutes seconds)))

Note that declarations work just like `let*'."
  (cond ((null bindings)
         `(locally ,@body))
        ((every #'simple-binding-p bindings)
         `(let* ,bindings ,@body))
        (t (multiple-value-bind (body decls)
               (parse-body body)
             (let* ((bindings (canonicalize-bindings bindings))
                    (mvbinds (member-if-not #'simple-binding-p bindings))
                    (simple-binds (ldiff bindings mvbinds)))
               (if simple-binds
                   (multiple-value-bind (local other)
                       (partition-declarations (mapcar #'car simple-binds) decls env)
                     `(let* ,simple-binds
                        ,@local
                        (mvlet* ,mvbinds
                          ,@other
                          ,@body)))
                   (let* ((vars (butlast (car bindings)))
                          (expr (lastcar (car bindings))))
                     (multiple-value-bind (local other)
                         (partition-declarations vars decls env)
                       `(multiple-value-bind ,vars
                            ,expr
                          ,@local
                          (mvlet* ,(cdr bindings)
                            ,@other
                            ,@body))))))))))

Macroexpansion:
(multiple-value-bind (left-cases right-cases) (halves cases) (mvlet* ((split (caar right-cases))) (sb-int:quasiquote (if (< #S(sb-impl::comma :expr keyform :kind 0) #S(sb-impl::comma :expr split :kind 0)) #S(sb-impl::comma :expr (rec keyform left-cases) :kind 0) #S(sb-impl::comma :expr (rec keyform right-cases) :kind 0)))))
Write a Common Lisp macro to handle this code pattern:
(-<> nil)

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

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

Macroexpansion:
nil
Define a macro that eliminates this repetitive pattern:
(flow-lambda-macro (flow-context) (let ((fu-body `((flet ((continue-flow (&optional ,continue-arg) (capture-flow-value ,flow-context ,continue-arg) (dispatch-rest ,flow-context)) (interrupt-flow (&optional ,condi) (error ,condi))) (declare (ignorable (function continue-flow) (function interrupt-flow))) ,@body)))) (with-flow-function-macro (body-fu lambda-list fu-body) `(dispatch-asynchronously ,flow-context #',body-fu))))

Issue: Macro call that should be transformed by flow-lambda-macro

Macro definition:
(defmacro flow-lambda-macro ((flow-context) &body body)
  `(with-gensyms (,flow-context)
     `(%flow-lambda (,,flow-context)
        ,,@body)))

Macroexpansion:
(with-gensyms (flow-context) (sb-int:quasiquote (%flow-lambda (#S(sb-impl::comma :expr flow-context :kind 0)) #S(sb-impl::comma :expr (let ((fu-body (sb-int:quasiquote ((flet ((continue-flow (&optional #S(sb-impl::comma :expr continue-arg :kind 0)) (capture-flow-value #S(sb-impl::comma :expr flow-context :kind 0) #S(sb-impl::comma :expr continue-arg :kind 0)) (dispatch-rest #S(sb-impl::comma :expr flow-context :kind 0))) (interrupt-flow (&optional #S(sb-impl::comma :expr condi :kind 0)) (error #S(sb-impl::comma :expr condi :kind 0)))) (declare (ignorable (function continue-flow) (function interrupt-flow))) #S(sb-impl::comma :expr body :kind 2)))))) (with-flow-function-macro (body-fu lambda-list fu-body) (sb-int:quasiquote (dispatch-asynchronously #S(sb-impl::comma :expr flow-context :kind 0) (function #S(sb-impl::comma :expr body-fu :kind 0)))))) :kind 0))))
Create a Common Lisp macro for the following transformation. Before code:
(define-dispatch dispatch-for-+ (args specific-hooks) (reduce #'+ (mapcar (lambda (f) (apply f args)) specific-hooks)))

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

Macro definition:
(defmacro define-dispatch (name lambda-list &body body)
  "the lambda list should accept two arguments:
the list of arguments given by the current method call.
the specific hooks (as named or unamed functions) for the qualified method (that we will be dispatching from).

you should then use the arguments to dispatch the specific hooks as you wish in the body.
if the body returns a result, by default the method will also return that result, this can be overriden with finalize-dispatch-method.

See finalize-dispatch-method
See dispatch"
  `(let ((new-dispatch (make-dispatcher (lambda ,lambda-list ,@body))))
     (setf (gethash ',name *dispatch-table*)
           new-dispatch)))

Macroexpansion:
(let ((new-dispatch (make-dispatcher (lambda (args specific-hooks) (reduce (function +) (mapcar (lambda (f) (apply f args)) specific-hooks)))))) (setf (gethash (quote dispatch-for-+) *dispatch-table*) new-dispatch))
Write a Common Lisp macro to handle this code pattern:
(with-reader-case nil
  :key
  nil)

Problem: Macro call that should be transformed by WITH-READER-CASE

Macro definition:
(defmacro WITH-READER-CASE ...)

Macroexpansion:
(let ()
  (let ((#:previous-case181 (readtable-case *readtable*)))
    (setf (readtable-case *readtable*) nil)
    (unwind-protect (progn :key nil)
      (setf (readtable-case *readtable*) #:previous-case181))))
Define a macro that eliminates this repetitive pattern:
(some-<>
  nil
  (progn))

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

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

Macroexpansion:
(let* ((#:var178 nil)
       (#:var179
        (if #:var178
            (progn #:var178)
            nil)))
  #:var179)
Create a Common Lisp macro for the following transformation. Before code:
(draw scene (:use :xlink-href (xlink-href columns)) :x (- (random 750) 25) :y (- (random 700) 25) :height size :width size :stroke "rgb(232, 229, 148)" :stroke-width 0.3 :fill (one-of *sandy-test-colors*))

What needs to change: 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 ((#:g148 (funcall (function make-svg-element) :use (append (list :xlink-href (xlink-href columns)) (list :x (- (random 750) 25) :y (- (random 700) 25) :height size :width size :stroke "rgb(232, 229, 148)" :stroke-width 0.3 :fill (one-of *sandy-test-colors*)))))) (add-element scene #:g148) #:g148)
Create a Common Lisp macro for the following transformation. Before code:
(quasiquote-expand-1 'list (append (butlast x) (mapcar 'kwote (and last (single-arg (car last))))))

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) (append (butlast x) (mapcar (quote kwote) (and last (single-arg (car last))))))
Define a macro that eliminates this repetitive pattern:
(some->> 'some-name)

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

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

Macroexpansion:
(let* ((#:|some124| 'some-name))
  #:|some124|)
Generate a defmacro form that transforms code like this:
(define-value-binding repeating ((var 0) limit) (declare (type (integer 0) var limit)) `(when (< ,limit (incf ,var)) (end-for)))

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

Macro definition:
(defmacro define-value-binding (name (var &rest args) &body body)
  (let ((vars (lambda-fiddle:extract-lambda-vars (lambda-fiddle:remove-aux-part args))))
    (emit-binding-definition name var args body :extra-vars vars)))

Macroexpansion:
(define-direct-binding repeating (var limit) (let ((#:limit178 (gensym #A((5) base-char . "LIMIT")))) (values* (sb-int:quasiquote (with-interleaving (let* #S(sb-impl::comma :expr (list* (list #:limit178 limit) (loop for #:var177 in (lambda-fiddle:extract-lambda-vars (enlist var)) collect (list #:var177 0))) :kind 0) (declare (ignorable #S(sb-impl::comma :expr #:limit178 :kind 0))) #S(sb-impl::comma :expr (sb-int:quasiquote (declare (type #S(sb-impl::comma :expr (quote (integer 0)) :kind 0) #S(sb-impl::comma :expr var :kind 0)))) :kind 0) #S(sb-impl::comma :expr (sb-int:quasiquote (declare (type #S(sb-impl::comma :expr (quote (integer 0)) :kind 0) #S(sb-impl::comma :expr #:limit178 :kind 0)))) :kind 0)) #S(sb-impl::comma :expr nil :kind 0))) (let ((limit #:limit178)) (declare (ignorable limit)) (sb-int:quasiquote (when (< #S(sb-impl::comma :expr limit :kind 0) (incf #S(sb-impl::comma :expr var :kind 0))) (end-for)))))))
Write a Common Lisp macro to handle this code pattern:
(define-simple-documentation-lookup compiler-macro cl:compiler-macro)

Problem: Macro call that should be transformed by define-simple-documentation-lookup

Macro definition:
(defmacro define-simple-documentation-lookup (class documentation-type)
  `(defmethod documentation ((,class ,class))
     ,(if (eql documentation-type T)
          `(cl:documentation (object ,class) 'T)
          `(cl:documentation (designator ,class) ',documentation-type))))

Macroexpansion:
(defmethod documentation ((compiler-macro compiler-macro)) (common-lisp:documentation (designator compiler-macro) (quote common-lisp:compiler-macro)))
Create a Common Lisp macro for the following transformation. Before code:
(inext nil)

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

Macro definition:
(defmacro INEXT ...)

Macroexpansion:
(let ((vals (multiple-value-list (funcall (i-coro nil) nil))))
  (if (not vals)
      (coexit!)
      (car vals)))
Define a macro that eliminates this repetitive pattern:
(ps-package-prefix 'some-name)

Issue: Macro call that should be transformed by PS-PACKAGE-PREFIX

Macro definition:
(defmacro PS-PACKAGE-PREFIX ...)

Macroexpansion:
(gethash (find-package 'some-name) *package-prefix-table*)
You are a Common Lisp macro expert. Given this code pattern:
(builder (:session :store (make-redis-store :namespace *namespace* :connection *connection*)) (lambda (env) (unless (gethash :counter (getf env :lack.session)) (setf (gethash :counter (getf env :lack.session)) 0)) `(200 (:content-type "text/plain") (,(format nil "Hello, you've been here for ~Ath times!" (incf (gethash :counter (getf env :lack.session))))))))

Write a macro that addresses: 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 (#:app238) (funcall (find-middleware :session) #:app238 :store (make-redis-store :namespace *namespace* :connection *connection*))))) :initial-value (to-app (lambda (env) (unless (gethash :counter (getf env :lack.session)) (setf (gethash :counter (getf env :lack.session)) 0)) (sb-int:quasiquote (200 (:content-type "text/plain") (#S(sb-impl::comma :expr (format nil "Hello, you've been here for ~Ath times!" (incf (gethash :counter (getf env :lack.session)))) :kind 0)))))) :from-end t)
You are a Common Lisp macro expert. Given this code pattern:
(signal-syntax-error "No choices in branch: ~S." parse-tree)

Write a macro that addresses: Macro call that should be transformed by signal-syntax-error

Macro definition:
(defmacro signal-syntax-error (format-control &rest format-arguments)
  `(signal-syntax-error* nil ,format-control ,@format-arguments))

Macroexpansion:
(signal-syntax-error* nil "No choices in branch: ~S." parse-tree)
Write a Common Lisp macro to handle this code pattern:
(-> :g (value) (put value) (error 'skipping-condition))

Problem: Macro call that should be transformed by ->

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

Macroexpansion:
(atomically :g (value) (put value) (error (quote skipping-condition)))
Write a Common Lisp macro to handle this code pattern:
(as-> nil :key nil)

Problem: Macro call that should be transformed by AS->

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

Macroexpansion:
(let* ((:key nil))
  nil)
You are a Common Lisp macro expert. Given this code pattern:
(iterate
  nil
  :key
  nil)

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

Macro definition:
(defmacro ITERATE ...)

Macroexpansion:
(iter
  nil
  :key
  nil)
Create a Common Lisp macro for the following transformation. Before code:
(do-notation bind-maybe ((sum (inc-maybe 1)) (str (maybe->string sum))) str)

What needs to change: 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) str) (maybe->string sum))) (inc-maybe 1)))
Define a macro that eliminates this repetitive pattern:
(c-assert (listp (kid-values self)))

Issue: Macro call that should be transformed by c-assert

Macro definition:
(defmacro c-assert (assertion &optional places fmt$ &rest fmt-args)
  (declare (ignorable assertion places fmt$ fmt-args))
   #+(or)`(progn) 
  `(unless *stop*
     (unless ,assertion
       ,(if fmt$
            `(c-break ,fmt$ ,@fmt-args)
          `(c-break "failed assertion: ~a" ',assertion)))))

Macroexpansion:
(unless *stop* (unless (listp (kid-values self)) (c-break "failed assertion: ~a" (quote (listp (kid-values self))))))
You are a Common Lisp macro expert. Given this code pattern:
(define-condition deprecation-warning (style-warning) ((name :initarg :name :reader deprecated-name) (replacements :initarg :replacement :reader deprecated-name-replacement) (since :initarg :since :reader deprecated-since)) (:report (lambda (condition stream) (format stream "~S is deprecated since CL-MUSTACHE version ~A. ~ Use ~S instead." (deprecated-name condition) (deprecated-since condition) (deprecated-name-replacement condition)))))

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

Macro definition:
(defmacro define (name template)
  "Define a named renderer of string TEMPLATE."
  `(setf (symbol-function ',name)
         (compile-template ,template)))

Macroexpansion:
(progn (sb-kernel::%define-condition (quote deprecation-warning) (quote (style-warning)) (sb-kernel::find-condition-layout (quote deprecation-warning) (quote (style-warning))) (list (sb-kernel::make-condition-slot :name (quote name) :initargs (quote (:name)) :readers (quote (deprecated-name)) :writers (quote nil) :initform-p (quote nil) :documentation (quote nil) :initform nil :initfunction nil :allocation (quote :instance)) (sb-kernel::make-condition-slot :name (quote replacements) :initargs (quote (:replacement)) :readers (quote (deprecated-name-replacement)) :writers (quote nil) :initform-p (quote nil) :documentation (quote nil) :initform nil :initfunction nil :allocation (quote :instance)) (sb-kernel::make-condition-slot :name (quote since) :initargs (quote (:since)) :readers (quote (deprecated-since)) :writers (quote nil) :initform-p (quote nil) :documentation (quote nil) :initform nil :initfunction nil :allocation (quote :instance))) (list) (quote (deprecated-since deprecated-name-replacement deprecated-name)) (quote nil) (sb-c:source-location)) (sb-kernel::%set-condition-report (quote deprecation-warning) (function (sb-int:named-lambda (sb-kernel::condition-report deprecation-warning) (condition stream) (declare (type condition condition) (type stream stream)) (funcall (function (lambda (condition stream) (format stream "~S is deprecated since CL-MUSTACHE version ~A. ~ Use ~S instead." (deprecated-name condition) (deprecated-since condition) (deprecated-name-replacement condition)))) condition stream)))) (quote deprecation-warning))
You are a Common Lisp macro expert. Given this code pattern:
(*let nil)

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

Macro definition:
(defmacro *LET ...)

Macroexpansion:
(let* ())
Define a macro that eliminates this repetitive pattern:
(lret* ((type `(integer ,start (,end))) (len (- end start)) (vector (make-array len :element-type type))) (nlet lp ((i 0) (n start)) (declare (type array-index i n)) (if (= i len) vector (progn (setf (aref vector i) n) (lp (1+ i) (1+ n))))))

Issue: Macro call that should be transformed by lret

Macro definition:
(defmacro lret ((&rest bindings) &body body)
  "Return the initial value of the last binding in BINDINGS. The idea
is to create something, initialize it, and then return it.

    (lret ((x 1)
           (y (make-array 1)))
      (setf (aref y 0) x))
    => #(1)

Note that the value returned is the value initially bound. Subsequent
assignments are ignored.

    (lret ((x 1))
      (setf x 2))
    => 1

Furthermore, on Lisps that support it, the variable may be made
read-only, making assignment a compiler-time error.

`lret' may seem trivial, but it fufills the highest purpose a macro
can: it eliminates a whole class of bugs (initializing an object, but
forgetting to return it).

Cf. `aprog1' in Anaphora."
  `(lret-aux let ,bindings
     ,@body))

Macroexpansion:
(lret-aux let* ((type (sb-int:quasiquote (integer #S(sb-impl::comma :expr start :kind 0) (#S(sb-impl::comma :expr end :kind 0))))) (len (- end start)) (vector (make-array len :element-type type))) (nlet lp ((i 0) (n start)) (declare (type array-index i n)) (if (= i len) vector (progn (setf (aref vector i) n) (lp (1+ i) (1+ n))))))
Define a macro that eliminates this repetitive pattern:
(deferror "57P01" admin-shutdown server-shutdown)

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 admin-shutdown (server-shutdown) nil) (setf (gethash "57P01" *error-table*) (quote admin-shutdown)))
Create a Common Lisp macro for the following transformation. Before code:
(do-subclasses (ctype content) (publish ctype))

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

Macro definition:
(defmacro do-subclasses ((var class) &body body)
  "Iterate over the subclasses of CLASS performing BODY with VAR
lexically bound to the current subclass."
  (alexandria:with-gensyms (klasses)
    `(let ((,klasses (all-subclasses (find-class ',class))))
       (loop for ,var in ,klasses do ,@body))))

Macroexpansion:
(let ((#:klasses285 (all-subclasses (find-class (quote content))))) (loop for ctype in #:klasses285 do (publish ctype)))
Generate a defmacro form that transforms code like this:
(do-generator (g list-or-gen) (yield g) (push g accum))

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

Macro definition:
(defmacro do-generator ((var &rest vars-and-generator) &body body)
  "Steps through the specified generator, binding the value it returns to var, then executing the body for each step. If multiple variables are specified and the generator returns multiple values, the extra values will be bound to the extra variables."
  (let ((g (gensym)))
    `(let ((,g ,(car (last vars-and-generator))))
       (loop 
	  do (if-generator ((,var ,@(butlast vars-and-generator)) ,g)
			   (progn
			     ,@body)
			   (return))))))

Macroexpansion:
(let ((#:g156 list-or-gen)) (loop do (if-generator ((g) #:g156) (progn (yield g) (push g accum)) (return))))
You are a Common Lisp macro expert. Given this code pattern:
(enable-reader-syntax)

Write a macro that addresses: Macro call that should be transformed by ENABLE-READER-SYNTAX

Macro definition:
(defmacro ENABLE-READER-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute)
  (push *readtable* *previous-readtables*)
  (setq *readtable* (copy-readtable))
  (%enable-reader-syntax *readtable*))
You are a Common Lisp macro expert. Given this code pattern:
(*> +period+ +digit-chunks+)

Write a macro that addresses: 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 (#:*>-offset245) (multiple-value-bind (#:*>-res246 #:*>-next247) (funcall +period+ #:*>-offset245) (if (ok? #:*>-res246) (funcall +digit-chunks+ #:*>-next247) (fail #:*>-next247))))
Generate a defmacro form that transforms code like this:
(with-cache ("none" :store storage) (error "SHOULD BE ERROR"))

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

Macro definition:
(defmacro with-cache ((key &key store expire) &body body)
  "If a cache indicated by KEY exists, this just returns the cache
value without evaluating BODY. Otherwise, this evaluates BODY and
stores the evaluated value into STORE with KEY and EXPIRE. KEY is a
form that an evaluated value indicates the cache key.

Example:

    (defun f (x)
      (with-cache (x *store*)
        (very-complex-computation x)))"
  (once-only (key store expire)
    (with-gensyms (value exists-p)
      `(multiple-value-bind (,value ,exists-p)
           (getcache ,key ,store)
         (if ,exists-p
             ,value
             (let ((,value (progn ,@body)))
               (setcache ,key ,value ,store :expire ,expire)
               ,value))))))

Macroexpansion:
(let ((#:key242 "none") (#:store243 storage) (#:expire244 nil)) (multiple-value-bind (#:value245 #:exists-p246) (getcache #:key242 #:store243) (if #:exists-p246 #:value245 (let ((#:value245 (progn (error "SHOULD BE ERROR")))) (setcache #:key242 #:value245 #:store243 :expire #:expire244) #:value245))))
Generate a defmacro form that transforms code like this:
(incf nil nil)

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

Macro definition:
(defmacro INCF ...)

Macroexpansion:
(setq nil (+ nil nil))