j14i/cl-macros huggingface dataset:
You are a Common Lisp macro expert. Given this code pattern:
(with-capped-stack () (etypecase destination ((eql T) (present thing *standard-output*)) ((eql NIL) (with-output-to-string (stream) (present thing stream))) (stream (present-object thing destination))))

Write a macro that addresses: Macro call that should be transformed by with-capped-stack

Macro definition:
(defmacro with-capped-stack (() &body body)
  `(stack-capper (lambda () ,@body)))

Macroexpansion:
(stack-capper (lambda nil (etypecase destination ((eql t) (present thing *standard-output*)) ((eql nil) (with-output-to-string (stream) (present thing stream))) (stream (present-object thing destination)))))
Create a Common Lisp macro for the following transformation. Before code:
(define-layered-class nil
  (progn))

What needs to change: Macro call that should be transformed by DEFINE-LAYERED-CLASS

Macro definition:
(defmacro DEFINE-LAYERED-CLASS ...)

Macroexpansion:
(defclass nil (progn) nil (:metaclass layered-class) (:in-layer . t))
Define a macro that eliminates this repetitive pattern:
(gen-lambda-with-sticky-stop () (multiple-value-bind (res signal) (funcall source) (if signal res (sticky-stop))))

Issue: Macro call that should be transformed by gen-lambda-with-sticky-stop

Macro definition:
(defmacro gen-lambda-with-sticky-stop (&rest rest)
  `(make-instance 
    'basic-generator 
    :function (sticky-stop-lambda ,@rest)))

Macroexpansion:
(make-instance (quote basic-generator) :function (sticky-stop-lambda nil (multiple-value-bind (res signal) (funcall source) (if signal res (sticky-stop)))))
Create a Common Lisp macro for the following transformation. Before code:
(defjs reduce1(k vals) (return (aref vals 0)))

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

Macro definition:
(defmacro defjs (name args &body body)
  "Define client side javascript. Works like defun; body is in lisp, with parenscript
   additions, like return. So (defjs hello (x y) (return (+ x y))) defines an adder. 
   macro creates a lisp function which sends the javascript function over to the mongo 
   server to be evaluated. Result is processed and returned to the reader. 
   This will execute 10 times on the server :
   (mapcar (lambda (x) (hello 10 x)) (list 1 2 3 4 5 6 7 8 9 10))"
  `(let* ((js-body (parenscript:ps (lambda ,args ,@body))))
     (setf (gethash ',name *js-definitions*) js-body)
     (defun ,name ,args
       (get-element "retval" (car (docs (db.eval js-body ,@args)))))))

Macroexpansion:
(let* ((js-body (parenscript:ps (lambda (k vals) (return (aref vals 0)))))) (setf (gethash (quote reduce1) *js-definitions*) js-body) (defun reduce1 (k vals) (get-element "retval" (car (docs (db.eval js-body k vals))))))
Define a macro that eliminates this repetitive pattern:
(f0
  'some-name)

Issue: Macro call that should be transformed by F0

Macro definition:
(defmacro F0 ...)

Macroexpansion:
(lambda () 'some-name)
Write a Common Lisp macro to handle this code pattern:
(c? )

Problem: 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 nil) :value-state :unevaluated :rule (c-lambda))
Generate a defmacro form that transforms code like this:
(with-table-name nil (yield (as-op-right op)))

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

Macro definition:
(defmacro with-table-name (table-name &body body)
  `(let ((*table-name-scope* ,table-name))
     ,@body))

Macroexpansion:
(let ((*table-name-scope* nil)) (yield (as-op-right op)))
Generate a defmacro form that transforms code like this:
(ψ nil)

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

Macro definition:
(defmacro Ψ ...)

Macroexpansion:
(mapcar (λ) nil)
Define a macro that eliminates this repetitive pattern:
(with-html-string (:p :attrs attrs "bar"))

Issue: Macro call that should be transformed by with-html

Macro definition:
(defmacro with-html (&body body &environment env)
  "Interpret BODY as HTML. Consult README.txt for the syntax."
  `(let ((*html* (ensure-html-stream *html*)))
     ,(if (and (null (cdr body)) (atom (car body)))
          (car body)
          `(progn ,@(parse-html body env)))))

Macroexpansion:
(with-output-to-string (*html*) (with-html (:p :attrs attrs "bar")))
Create a Common Lisp macro for the following transformation. Before code:
(~> (flow:atomically :tag-0 () "Hello") (-> :tag-1 () ", concurrent"))

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

Macro definition:
(defmacro ~> (&rest body)
  "See flow:concurrently"
  `(concurrently ,@body))

Macroexpansion:
(concurrently (atomically :tag-0 nil "Hello") (-> :tag-1 nil ", concurrent"))
Write a Common Lisp macro to handle this code pattern:
(collect-stream nil (progn))

Problem: Macro call that should be transformed by COLLECT-STREAM

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

Macroexpansion:
(common-lisp:let* ((#:generator-482 (generator (progn))) #:items-477)
  (declare (type generator #:generator-482))
  (tagbody
   #:ll-483
    (setq #:items-477 (next-in #:generator-482 (go end)))
    (common-lisp:funcall #'print #:items-477 nil)
    (go #:ll-483)
   end)
  nil)
Generate a defmacro form that transforms code like this:
(define nil
  nil)

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

Macro definition:
(defmacro DEFINE ...)

Macroexpansion:
(eval-when (:load-toplevel :execute)
  (check-if-bound 'nil)
  (setf (get 'nil 'read-macro)
          (lambda (#:stream146)
            (let ((*standard-input* #:stream146))
              nil)))
  'nil)
Create a Common Lisp macro for the following transformation. Before code:
(action (:after node-application) #'lift-static-dict)

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 lift-static-dict))
Define a macro that eliminates this repetitive pattern:
(scond ((car x) (setf it :nono)) ((car y) (setf it :yes)))

Issue: Macro call that should be transformed by scond

Macro definition:
(defmacro scond (&body clauses)
  "Like COND, except each test-form is bound to IT (via SYMBOL-MACROLET) for the
scope of the corresponsing clause. IT can be set with SETF."
  (labels ((rec (clauses)
	     (if clauses
		 (destructuring-bind ((test &body body) . rest) clauses
		   (if body
		       `(symbolic if ,test (progn ,@body) ,(rec rest))
		       `(symbolic if ,test it ,(rec rest))))
		 nil)))
    (rec clauses)))

Macroexpansion:
(symbolic if (car x) (progn (setf it :nono)) (symbolic if (car y) (progn (setf it :yes)) nil))
Create a Common Lisp macro for the following transformation. Before code:
(dreletf* 'some-name)

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

Macro definition:
(defmacro DRELETF* ...)

Macroexpansion:
(dreletf ('nil)
  (dreletf ((some-name nil))
    (progn)))
Create a Common Lisp macro for the following transformation. Before code:
(*> (char #\H) (char #\e))

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 (#:*>-offset206) (multiple-value-bind (#:*>-res207 #:*>-next208) (funcall (char #\LATIN_CAPITAL_LETTER_H) #:*>-offset206) (if (ok? #:*>-res207) (funcall (char #\LATIN_SMALL_LETTER_E) #:*>-next208) (fail #:*>-next208))))
Create a Common Lisp macro for the following transformation. Before code:
(with-took-usec took-usec (fetch-using-connection conn query))

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

Macro definition:
(defmacro with-took-usec (var &body body)
  (let ((before (gensym "BEFORE")))
    `(let ((,before (get-internal-real-time)))
       (multiple-value-prog1 (progn ,@body)
         (setf ,var (ceiling
                      (* (- (get-internal-real-time) ,before)
                         #.(/ 1000000 internal-time-units-per-second))))))))

Macroexpansion:
(multiple-value-bind (#:before-unixtime171 #:before-usec172) (sb-ext:get-time-of-day) (multiple-value-prog1 (progn (fetch-using-connection conn query)) (multiple-value-bind (#:after-unixtime173 #:after-usec174) (sb-ext:get-time-of-day) (setf took-usec (+ (* (- #:after-unixtime173 #:before-unixtime171) 1000000) (- #:after-usec174 #:before-usec172))))))
Generate a defmacro form that transforms code like this:
(signals (error "The form ~S is expected to signal an ~S" '(error "an error") 'error) (error "an error"))

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

Macro definition:
(defmacro signals (condition-spec
                   &body body)
  "Generates a pass if BODY signals a condition of type
CONDITION. BODY is evaluated in a block named NIL, CONDITION is
not evaluated."
  (let ((block-name (gensym)))
    (destructuring-bind (condition &optional reason-control &rest reason-args)
        (ensure-list condition-spec)
      `(block ,block-name
         (handler-bind ((,condition (lambda (c)
                                      (declare (ignore c))
                                      ;; ok, body threw condition
                                      (add-result 'test-passed
                                                  :test-expr ',condition)
                                      (return-from ,block-name t))))
           (block nil
             ,@body))
         (process-failure
           ',condition
           ,@(if reason-control
                 `(,reason-control ,@reason-args)
                 `("Failed to signal a ~S" ',condition)))
         (return-from ,block-name nil)))))

Macroexpansion:
(block #:g286 (handler-bind ((error (lambda (c) (declare (ignore c)) (add-result (quote test-passed) :test-expr (quote error)) (return-from #:g286 t)))) (block nil (error "an error"))) (process-failure (quote error) "The form ~S is expected to signal an ~S" (quote (error "an error")) (quote error)) (return-from #:g286 nil))
Define a macro that eliminates this repetitive pattern:
(letrec-syntax common-lisp:nil)

Issue: Macro call that should be transformed by LETREC-SYNTAX

Macro definition:
(defmacro LETREC-SYNTAX ...)

Macroexpansion:
(common-lisp:macrolet common-lisp:nil)
Create a Common Lisp macro for the following transformation. Before code:
(collect-first 'some-name)

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

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

Macroexpansion:
(common-lisp:let* ((#:generator-640 (generator 'some-name))
                   #:items-634
                   (#:item-636 nil))
  (declare (type generator #:generator-640)
           (type (null-or t) #:item-636))
  (tagbody
   #:ll-641
    (setq #:items-634 (next-in #:generator-640 (go end)))
    (setq #:item-636 #:items-634)
   end)
  #:item-636)
You are a Common Lisp macro expert. Given this code pattern:
(c-assert (not (member nil old-kids)))

Write a macro that addresses: 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 (not (member nil old-kids)) (c-break "failed assertion: ~a" (quote (not (member nil old-kids))))))
You are a Common Lisp macro expert. Given this code pattern:
(defclause to (final-value &key (from 0) by while using) "Variation over from." `(from ,from :to ,final-value :by ,by ,@(when while `(:while ,while)) ,@(when using `(:using ,using))))

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

Macro definition:
(defmacro defclause (name arglist &body body)
  "Same as cl:defmacro, but additionally records <name> in *clauses* as a known clause macro."
  `(progn
     (defmacro ,name ,arglist ,@body)
     (pushnew ',name *clauses*)))

Macroexpansion:
(progn (defmacro to (final-value &key (from 0) by while using) "Variation over from." (sb-int:quasiquote (from #S(sb-impl::comma :expr from :kind 0) :to #S(sb-impl::comma :expr final-value :kind 0) :by #S(sb-impl::comma :expr by :kind 0) #S(sb-impl::comma :expr (when while (sb-int:quasiquote (:while #S(sb-impl::comma :expr while :kind 0)))) :kind 2) #S(sb-impl::comma :expr (when using (sb-int:quasiquote (:using #S(sb-impl::comma :expr using :kind 0)))) :kind 2)))) (pushnew (quote to) *clauses*))
Create a Common Lisp macro for the following transformation. Before code:
(defparam nil (progn))

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

Macro definition:
(defmacro DEFPARAM ...)

Macroexpansion:
(setf (gethash #A((3) base-char . "NIL") cl-rules.core::*parameters*) (progn))
Generate a defmacro form that transforms code like this:
(defcell b 1)

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

Macro definition:
(defmacro defcell (name value-form &environment env)
  "Define a global cell identified by NAME.

This macro defines a cell identified by NAME with its value computed
by VALUE-FORM. The value of the cell can be referenced by the symbol
NAME following the DEFCELL form.

If VALUE-FORM is a constant, by CONSTANTP, a mutable cell is defined
which can have its value set directly using SETF or SETQ on the symbol
NAME.

If VALUE-FORM is not a constant a computed cell is created. A computed
cell may reference one or more argument cells in VALUE-FORM or a
function called during the evaluation of VALUE-FORM.  When the values
of any of the argument cells change, the value of the computed cell is
recomputed by evaluating VALUE-FORM again. The referenced argument
cells are determined automatically when the VALUE-FORM is evaluated.

This macro creates a cell definition that is visible globally to all
forms unless it is lexically shadowed by a definition with the same
NAME using CELL-LET. Note that despite being visible globally, the
cell definition is still lexically scoped and not dynamically scoped
like global variables defined with DEFVAR or DEFPARAMETER."

  (if (constantp value-form env)
      `(define-mutable-cell% ,name ,value-form)
      `(define-computed-cell% ,name ,value-form)))

Macroexpansion:
(define-mutable-cell% b 1)
Generate a defmacro form that transforms code like this:
(define-alias-binding maximize maximizing)

Pattern to recognize: 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 maximize)) (quote maximizing)) (quote maximize))
Create a Common Lisp macro for the following transformation. Before code:
(defclause collecting-into-and-returning (vars &rest args &key initially by finally) "Same as collecting-into, but also returns the value of each <vars> at the end of the loop." (declare (ignore initially by finally)) `((collecting-into ,vars ,@args) ,@(mapcar (lambda (var) `(returning ,var)) (ensure-list vars))))

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

Macro definition:
(defmacro defclause (name arglist &body body)
  "Same as cl:defmacro, but additionally records <name> in *clauses* as a known clause macro."
  `(progn
     (defmacro ,name ,arglist ,@body)
     (pushnew ',name *clauses*)))

Macroexpansion:
(progn (defmacro collecting-into-and-returning (vars &rest args &key initially by finally) "Same as collecting-into, but also returns the value of each <vars> at the end of the loop." (declare (ignore initially by finally)) (sb-int:quasiquote ((collecting-into #S(sb-impl::comma :expr vars :kind 0) #S(sb-impl::comma :expr args :kind 2)) #S(sb-impl::comma :expr (mapcar (lambda (var) (sb-int:quasiquote (returning #S(sb-impl::comma :expr var :kind 0)))) (ensure-list vars)) :kind 2)))) (pushnew (quote collecting-into-and-returning) *clauses*))
You are a Common Lisp macro expert. Given this code pattern:
(c-assert (not (find c *call-stack*)))

Write a macro that addresses: 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 (not (find c *call-stack*)) (c-break "failed assertion: ~a" (quote (not (find c *call-stack*))))))
Create a Common Lisp macro for the following transformation. Before code:
(with-mocks () (register-mock 'foo) (register-mock 'bar) (bt:make-thread (lambda () (foo) (bar))) (is (assert-cond (lambda () (and (equal '((foo)) (invocations 'foo)) (equal '((bar)) (invocations 'bar)))) .5)))

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

Macro definition:
(defmacro with-mocks ((&key (recordp T)) &body body)
  "Execute BODY in a new mocking context.  Invocations will be recorded
if RECORDP is set (default true)."
  `(call-with-mocks
    (lambda () ,@body)
    :recordp ,recordp))

Macroexpansion:
(call-with-mocks (lambda nil (register-mock (quote foo)) (register-mock (quote bar)) (bordeaux-threads:make-thread (lambda nil (foo) (bar))) (is (assert-cond (lambda nil (and (equal (quote ((foo))) (invocations (quote foo))) (equal (quote ((bar))) (invocations (quote bar))))) 0.5))) :recordp t)
Generate a defmacro form that transforms code like this:
(define-mustache-character #\= (let ((arg-text (string-trim '(#\Space #\Tab #\=) arg-text))) (prog1 (make-instance 'delimiter-tag :text arg-text) (change-delimiter arg-text))))

Pattern to recognize: 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:
(set-mustache-character #\EQUALS_SIGN (lambda (raw-text arg-text escapep start end) (declare (ignorable raw-text arg-text escapep start end) (type simple-string raw-text arg-text) (boolean escapep) (offset start end)) (let ((arg-text (string-trim (quote (#\Space #\Tab #\EQUALS_SIGN)) arg-text))) (prog1 (make-instance (quote delimiter-tag) :text arg-text) (change-delimiter arg-text)))))
Write a Common Lisp macro to handle this code pattern:
(signal-syntax-error "Register 0 doesn't exist: ~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 "Register 0 doesn't exist: ~S." parse-tree)
Generate a defmacro form that transforms code like this:
(define-simple-definition-resolver package find-package)

Pattern to recognize: Macro call that should be transformed by define-simple-definition-resolver

Macro definition:
(defmacro define-simple-definition-resolver (class lookup-function &body body)
  (let ((package (gensym "PACKAGE")))
    `(define-definition-resolver ,class (,class ,package)
       (when (ignore-errors ,(if body
                                 `(let ((,(first lookup-function) ,class))
                                    ,@body)
                                 `(,lookup-function ,class)))
         (list (make-instance ',class :designator ,class :package ,package))))))

Macroexpansion:
(define-definition-resolver package (package #:package132) (when (ignore-errors (find-package package)) (list (make-instance (quote package) :designator package :package #:package132))))
Define a macro that eliminates this repetitive pattern:
(define-global-parameter* nil (progn))

Issue: Macro call that should be transformed by DEFINE-GLOBAL-PARAMETER*

Macro definition:
(defmacro DEFINE-GLOBAL-PARAMETER* ...)

Macroexpansion:
(progn
 (setf (get 'nil +value-key+) (progn))
 (sb-ext:define-load-time-global nil (get 'nil +value-key+))
 (setf nil (get 'nil +value-key+))
 (remprop 'nil +value-key+)
 'nil)
Create a Common Lisp macro for the following transformation. Before code:
(lambda-match
  nil)

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

Macro definition:
(defmacro LAMBDA-MATCH ...)

Macroexpansion:
(lambda (#:arg146)
  (match #:arg146
    nil))
Generate a defmacro form that transforms code like this:
(compiler-macro-lambda (a) `(1+ ,a))

Pattern to recognize: Macro call that should be transformed by compiler-macro-lambda

Macro definition:
(defmacro compiler-macro-lambda (lambda-list &body body)
  (introspect-environment:parse-compiler-macro (gensym "COMPILER-MACRO-LAMBDA")
                                               lambda-list
                                               body))

Macroexpansion:
(sb-int:named-lambda (compiler-macro #:compiler-macro-lambda148) (#:expr #:env) (declare (sb-c::lambda-list (a))) (declare (ignore #:env)) (sb-int:named-ds-bind (:macro #:compiler-macro-lambda148 . define-compiler-macro) (a) (sb-c::compiler-macro-args #:expr) (declare (sb-c::constant-value a) (sb-c::no-compiler-macro #:compiler-macro-lambda148)) (block #:compiler-macro-lambda148 (sb-int:quasiquote (1+ #S(sb-impl::comma :expr a :kind 0))))))
Define a macro that eliminates this repetitive pattern:
(defjsmacro)

Issue: Macro call that should be transformed by DEFJSMACRO

Macro definition:
(defmacro DEFJSMACRO ...)

Macroexpansion:
(defpsmacro)
Write a Common Lisp macro to handle this code pattern:
(with-sql-logging (mapc #'execute-sql (migration-expressions class)))

Problem: Macro call that should be transformed by with-sql-logging

Macro definition:
(defmacro with-sql-logging (&body body)
  `(let ((*mito-logger-stream* *mito-migration-logger-stream*))
     (with-trace-sql ,@body)))

Macroexpansion:
(let ((*mito-logger-stream* *mito-migration-logger-stream*)) (with-trace-sql (mapc (function execute-sql) (migration-expressions class))))