j14i/cl-macros huggingface dataset:
Create a Common Lisp macro for the following transformation. Before code:
(receive () (values) nil)

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

Macro definition:
(defmacro receive (formals expr &body body)
  "Stricter version of `multiple-value-bind'.

Use `receive' when you want to enforce that EXPR should return a
certain number of values, or a minimum number of values.

If FORMALS is a proper list, then EXPR must return exactly as many
values -- no more and no less -- as there are variables in FORMALS.

If FORMALS is an improper list (VARS . REST), then EXPR must return at
least as many values as there are VARS, and any further values are
bound, as a list, to REST.

Lastly, if FORMALS is a symbol, bind that symbol to all the values
returned by EXPR, as if by `multiple-value-list'.

From Scheme (SRFI-8)."
  ;; It's probably not worth stack-allocating the thunk.
  (cond ((null formals)
         `(multiple-value-call
              (lambda ()
                ,@body)
            ,expr))
        ((atom formals)
         ;; This could also be written:
         #+(or) `(let ((,formals (multiple-value-list ,expr)))
                   ,@body)
         ;; But I want it to be possible to declare FORMALS to have
         ;; dynamic extent, and most Lisps support that for &rest
         ;; lists.
         `(multiple-value-call
              (lambda (&rest ,formals)
                ,@body)
            ,expr))
        ((proper-list-p formals)
         (when (intersection formals lambda-list-keywords)
           (error "Lambda list keywords in formals: ~a" formals))
         `(multiple-value-call
              (lambda ,formals
                ,@body)
            ,expr))
        (t (let* ((last (last formals))
                  (vars (append (butlast formals)
                                (list (car last))))
                  (rest (cdr last)))
             (when (intersection (cons rest vars) lambda-list-keywords)
               (error "Lambda list keywords in formals: ~a" formals))
             `(multiple-value-call
                  (lambda (,@vars &rest ,rest)
                    ,@body)
                ,expr)))))

Macroexpansion:
(multiple-value-call (lambda nil nil) (values))
Generate a defmacro form that transforms code like this:
(defmethod* nil
    :key
  nil)

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

Macro definition:
(defmacro DEFMETHOD* ...)

Macroexpansion:
(defmethod :key nil (the t ()))
Define a macro that eliminates this repetitive pattern:
(send nil (progn))

Issue: Macro call that should be transformed by SEND

Macro definition:
(defmacro SEND ...)

Macroexpansion:
(send (funcall (slot-value nil 'progn)))
Generate a defmacro form that transforms code like this:
(with-assert-observers ("deleting foo" foo foo+1) (store-remove :foo store))

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

Macro definition:
(defmacro with-assert-observers ((desc &rest asserted-observers) &body body)  
  `(let ((*observers* nil))
     (trc ,desc " -- checking observers")
     ,@body
     (let ((superfluous-observers (loop for run in *observers* if (not (member run (list ,@asserted-observers))) collect run))
	   (failed-observers (loop for asserted in (list ,@asserted-observers) if (not (member asserted *observers*)) collect asserted)))
       (trc "called observers on" *observers* :superflous superfluous-observers :failed failed-observers)
       (assert (not superfluous-observers))
       (assert (not failed-observers)))))

Macroexpansion:
(let ((*observers* nil)) (trc "deleting foo" " -- checking observers") (store-remove :foo store) (let ((superfluous-observers (loop for run in *observers* if (not (member run (list foo foo+1))) collect run)) (failed-observers (loop for asserted in (list foo foo+1) if (not (member asserted *observers*)) collect asserted))) (trc "called observers on" *observers* :superflous superfluous-observers :failed failed-observers) (assert (not superfluous-observers)) (assert (not failed-observers))))
Write a Common Lisp macro to handle this code pattern:
(return 'some-name)

Problem: Macro call that should be transformed by RETURN

Macro definition:
(defmacro RETURN ...)

Macroexpansion:
(return-from nil 'some-name)
Generate a defmacro form that transforms code like this:
(reduced-typecase nil (progn))

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

Macro definition:
(defmacro REDUCED-TYPECASE ...)

Macroexpansion:
(typecase nil (progn))
Create a Common Lisp macro for the following transformation. Before code:
(enable-fn-syntax)

What needs to change: Macro call that should be transformed by ENABLE-FN-SYNTAX

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

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (%enable-fn-syntax))
Write a Common Lisp macro to handle this code pattern:
(when (eql (top-sign) 'skip-first-template) (pop-sign))

Problem: 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 (eql (top-sign) (quote skip-first-template)) (pop-sign))
Define a macro that eliminates this repetitive pattern:
(gen-lambda () (if (> i (1- seqlen)) 'generator-stop (prog1 (elt seq i) (incf i))))

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

Macro definition:
(defmacro gen-lambda (params &body rest)
  "Version of lambda that wraps the anonymous function in an instance of the basic-generator class. This allows the lambda to be identified as a generator by its type. Basic-generator objects are derived from funcallable-standard-class, therefore they can be called as functions."
  `(let ((values-handler (create-values-handler)))
     (declare (ignorable values-handler))
     (make-instance 
      'basic-generator 
      :function (lambda ,params ,@rest))))

Macroexpansion:
(let ((values-handler (create-values-handler))) (declare (ignorable values-handler)) (make-instance (quote basic-generator) :function (lambda nil (if (> i (1- seqlen)) (quote generator-stop) (prog1 (elt seq i) (incf i))))))
Define a macro that eliminates this repetitive pattern:
(define-language-macro 'some-name)

Issue: Macro call that should be transformed by DEFINE-LANGUAGE-MACRO

Macro definition:
(defmacro DEFINE-LANGUAGE-MACRO ...)

Macroexpansion:
(defmacro 'some-name (&whole whole &body body)
  (declare (ignore body))
  `(macrolet ((,(car whole) (&body body)
                (let* ((lang (make-instance ',(car whole)))
                       (env (top-level-environment lang)))
                  (codegen-text (sexp->ops lang body env) ,*pretty*))))
     ,@(if *pretty*
           `((let ((*text-pretty-printer* (get-pretty-printer)))
               ,whole))
           `(,whole))))
Write a Common Lisp macro to handle this code pattern:
(do+ (options :name inner-loop) (do+ (terminate outer-loop 3)))

Problem: Macro call that should be transformed by do+

Macro definition:
(defmacro do+ (&body body)
  "High-level, extensible iteration construct. Refer to the manual for syntax and semantics."
  `(do+/internal nil ,@body))

Macroexpansion:
(do+/internal nil (options :name inner-loop) (do+ (terminate outer-loop 3)))
Define a macro that eliminates this repetitive pattern:
(dynamic-relet* 'some-name)

Issue: Macro call that should be transformed by DYNAMIC-RELET*

Macro definition:
(defmacro DYNAMIC-RELET* ...)

Macroexpansion:
(dynamic-relet (quote)
  (dynamic-relet* (some-name)))
You are a Common Lisp macro expert. Given this code pattern:
(define-component coffee :input-type "coffee" :output-type "js" :compile-function (lambda (input-pathname output-pathname) (declare (ignore output-pathname)) (inferior-shell:run `("coffee" "-c" ,input-pathname) :show t)))

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

Macro definition:
(defmacro define-component (name &key input-type output-type compile-function)
  "Define an ASDF component."
  `(progn
     (defclass ,name (source-file)
       ((type :initform ,input-type)
        (output :reader output :initarg :output)))

     (defmethod perform ((o load-op) (component ,name)) t)

     (defmethod output-files ((operation compile-op) (component ,name))
       (list
        (output-pathname component ,output-type)))

     (defmethod perform ((o compile-op) (component ,name))
       (funcall ,compile-function
                (component-pathname component)
                (output-pathname component ,output-type)))

     (import ',name :asdf)))

Macroexpansion:
(progn (defclass coffee (source-file) ((type :initform "coffee") (output :reader output :initarg :output))) (defmethod perform ((o load-op) (component coffee)) t) (defmethod output-files ((operation compile-op) (component coffee)) (list (output-pathname component "js"))) (defmethod perform ((o compile-op) (component coffee)) (funcall (lambda (input-pathname output-pathname) (declare (ignore output-pathname)) (inferior-shell:run (sb-int:quasiquote ("coffee" "-c" #S(sb-impl::comma :expr input-pathname :kind 0))) :show t)) (component-pathname component) (output-pathname component "js"))) (import (quote coffee) :asdf))
Write a Common Lisp macro to handle this code pattern:
(do-generator (d s (izip data selectors)) (when s (yield d)))

Problem: 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 ((#:g159 (izip data selectors))) (loop do (if-generator ((d s) #:g159) (progn (when s (yield d))) (return))))
Create a Common Lisp macro for the following transformation. Before code:
(with-html-string (:div (:div)))

What needs to change: 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 (:div (:div))))
Write a Common Lisp macro to handle this code pattern:
(*> #'comment +skip-junk+)

Problem: 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 (#:*>-offset221) (multiple-value-bind (#:*>-res222 #:*>-next223) (funcall (function comment) #:*>-offset221) (if (ok? #:*>-res222) (funcall +skip-junk+ #:*>-next223) (fail #:*>-next223))))
Create a Common Lisp macro for the following transformation. Before code:
(assoc-cdr :jwks--uri disc)

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

Macro definition:
(defmacro assoc-cdr (key alist &optional (test '#'eql))
  `(cdr (assoc ,key ,alist :test ,test)))

Macroexpansion:
(cdr (assoc :jwks--uri disc :test (function eql)))
Write a Common Lisp macro to handle this code pattern:
(%escape-string-form (format nil "~A" form))

Problem: Macro call that should be transformed by %escape-string-form

Macro definition:
(defmacro %escape-string-form (val)
  (let ((val2 (gensym)))
    `(let ((,val2 ,val))
       (if (should-escape-p ,val2)
           `(escape-string ,,val2)
           ,val2))))

Macroexpansion:
(let ((#:g123 (format nil "~A" form))) (if (should-escape-p #:g123) (sb-int:quasiquote (escape-string #S(sb-impl::comma :expr #:g123 :kind 0))) #:g123))
Create a Common Lisp macro for the following transformation. Before code:
(dflet ((foo/lock () 13) (list () 42)) (is (eql 42 (list))) (is (eql 13 (foo/lock))))

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

Macro definition:
(defmacro dflet ((&rest definitions) &body body)
  "Like FLET, but dynamically sets the FDEFINITIONS during the duration of
the BODY."
  `(progf
       ',(mapcar #'car definitions)
       (list
        ,.(mapcar (lambda (definition)
                    `(lambda ,(cadr definition)
                       ,@(cddr definition)))
                  definitions))
     ,@body))

Macroexpansion:
(progf (quote (foo/lock list)) (list (lambda nil 13) (lambda nil 42)) (is (eql 42 (list))) (is (eql 13 (foo/lock))))
Create a Common Lisp macro for the following transformation. Before code:
(while nil
  :key
  nil)

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

Macro definition:
(defmacro WHILE ...)

Macroexpansion:
(loop while nil
      do (progn :key nil))
You are a Common Lisp macro expert. Given this code pattern:
(-> :p () (mt:open-latch latch))

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

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

Macroexpansion:
(atomically :p nil (cl-muth:open-latch latch))
Define a macro that eliminates this repetitive pattern:
(is = 0.0f0 (read-from-string "0.0"))

Issue: Macro call that should be transformed by is

Macro definition:
(defmacro is (comp expected form &optional description &rest format-args)
  `(eval-in-context
    *context*
    (make-instance 'comparison-result
                   :expression '(is ,comp ,expected ,form)
                   :value-form ',form
                   :body (lambda () ,form)
                   :expected ,expected
                   :comparison ,(maybe-quote comp)
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))

Macroexpansion:
(eval-in-context *context* (make-instance (quote comparison-result) :expression (quote (is = 0.0 (read-from-string "0.0"))) :value-form (quote (read-from-string "0.0")) :body (lambda nil (read-from-string "0.0")) :expected 0.0 :comparison (quote =)))
Generate a defmacro form that transforms code like this:
(defclause (appending expr &optional into var at (place 'end)) "Append into a list" (return-collection-code :variable var :expression expr :start-operation 'append :end-operation '(subst (var expr) (copy-list expr)) :place place :one-element nil))

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

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

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (defun clause-appending-20 (&key ((:appending expr)) ((:into var)) ((:at place) (quote end))) "Append into a list" (return-collection-code :variable var :expression expr :start-operation (quote append) :end-operation (quote (subst (var expr) (copy-list expr))) :place place :one-element nil)) (install-clause-info (quote (appending)) (quote (appending &optional :into :at)) (quote clause-appending-20) "Append into a list" nil) (quote (appending expr &optional into var at (place (quote end)))))
Create a Common Lisp macro for the following transformation. Before code:
(dynamic-relet nil
  (progn))

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

Macro definition:
(defmacro DYNAMIC-RELET ...)

Macroexpansion:
(dynamic-wind
  :proceed
  #:proceed190
  (let ()
    (declare (special))
    (#:proceed190 (progn))))
You are a Common Lisp macro expert. Given this code pattern:
(~> (loop for i from 0 below 3 collecting (let ((i i)) (-> :p (a) (declare (type fixnum a)) (the fixnum (+ a i))))))

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

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

Macroexpansion:
(concurrently (loop for i from 0 below 3 collecting (let ((i i)) (-> :p (a) (declare (type fixnum a)) (the fixnum (+ a i))))))
Create a Common Lisp macro for the following transformation. Before code:
(as->* nil)

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

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

Macroexpansion:
nil
Generate a defmacro form that transforms code like this:
(defsynonym maximizing :max)

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 maximizing) (quote synonym)) (quote :max)))
Write a Common Lisp macro to handle this code pattern:
(advisable-lambda nil
  (progn))

Problem: Macro call that should be transformed by ADVISABLE-LAMBDA

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

Macroexpansion:
(make-instance 'advisable-function :main #'(lambda () (progn)) :arguments 'nil
               :dispatcher-generator
               #'(lambda (#:fobj126)
                   #'(lambda ()
                       #A((29) base-char . "Advisable function dispatcher")
                       (let ((#:fixed127 (append)))
                         (apply-before #:fobj126 #:fixed127)
                         (multiple-value-prog1
                             (apply-around #:fobj126 #:fixed127)
                           (apply-after #:fobj126 #:fixed127))))))
Create a Common Lisp macro for the following transformation. Before code:
(let+ nil
  (progn))

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

Macro definition:
(defmacro LET+ ...)

Macroexpansion:
(locally (progn))
Define a macro that eliminates this repetitive pattern:
(let+ nil
  nil)

Issue: Macro call that should be transformed by LET+

Macro definition:
(defmacro LET+ ...)

Macroexpansion:
(locally nil)
Write a Common Lisp macro to handle this code pattern:
(f_)

Problem: Macro call that should be transformed by F_

Macro definition:
(defmacro F_ ...)

Macroexpansion:
(lambda (_))
Define a macro that eliminates this repetitive pattern:
(with-space (if safe? (write-string string *html*) (escape-to-stream string #'escape-string-char *html*)))

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

Macro definition:
(defmacro with-space (&body body)
  (with-thunk (body)
    `(call-with-space ,body)))

Macroexpansion:
(flet ((#:stack-fn-body1 nil (if safe? (write-string string *html*) (escape-to-stream string (function escape-string-char) *html*)))) (declare (dynamic-extent (function #:stack-fn-body1))) (symbol-macrolet ((#:stack-fn-body1 (function #:stack-fn-body1))) (call-with-space #:stack-fn-body1)))
Generate a defmacro form that transforms code like this:
(defsynonym thereis :there-is)

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 thereis) (quote synonym)) (quote :there-is)))
Write a Common Lisp macro to handle this code pattern:
(define-error assignment-type-match (:error-type varjo-critical-error) (code-obj-a code-obj-b form) "Currently varjo cannot handle changing the type through an assignment due to the static nature of glsl. place: ~a value: ~a Problematic form: ~s" (type->type-spec (primary-type code-obj-a)) (type->type-spec (primary-type code-obj-b)) form)

Problem: Macro call that should be transformed by define-error

Macro definition:
(defmacro define-error (name (&key (error-type 'varjo-error) (prefix "Varjo"))
                            (&rest args) error-string &body body)
  `(defcondition ,name (:error-type ,error-type :prefix ,prefix) ,args
       ,error-string ,@body))

Macroexpansion:
(defcondition assignment-type-match (:error-type varjo-critical-error :prefix "Varjo") (code-obj-a code-obj-b form) "Currently varjo cannot handle changing the type through an assignment due to the static nature of glsl. place: ~a value: ~a Problematic form: ~s" (type->type-spec (primary-type code-obj-a)) (type->type-spec (primary-type code-obj-b)) form)
Define a macro that eliminates this repetitive pattern:
(and nil nil)

Issue: Macro call that should be transformed by AND

Macro definition:
(defmacro AND ...)

Macroexpansion:
(if nil
    nil)
You are a Common Lisp macro expert. Given this code pattern:
(with-temp (input-file :tmpdir d :template "XXXXXX.prolog" :debug (<= 1 *debug-prolog*)) (with-open-file (s input-file :direction :output :if-does-not-exist :error) (dolist (r rules) (print-rule s r))) (let* ((executable (namestring (make-pathname :type "out" :defaults input-file)))) (run-command-with-debug-print `("gplc" ,input-file "-o" ,executable) :input input :output output :error error) (run-command-with-debug-print `(,executable) :input input :output output :error error)))

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

Macro definition:
(defmacro with-temp ((var &key directory template (tmpdir "/tmp/") debug) &body body)
  "Create a temporary file, then remove the file by unwind-protect.
Most arguments are analogous to mktemp.
When DIRECTORY is non-nil, creates a directory instead.
DEBUG is a form.
When evaluated to non-nil, it does not remove the directory so that you can investigate what happened inside the directory.
It may be evaluated multiple times."
  (with-gensyms (command)
    `(let ((,var (uiop:run-program
                  (let ((,command (format nil "mktemp --tmpdir='~a' ~@[-d~*~] ~@[~a~]"
                                          ,tmpdir ,directory ,template)))
                    (when ,debug
                      (format *error-output* "~&; ~a~%" ,command))
                    ,command)
                  :output '(:string :stripped t))))
       (unwind-protect
            (progn ,@body)
         (if ,debug
             (format *error-output* "~&; not removing ~a for debugging~%" ,var)
             (uiop:run-program (format nil "rm -rf ~a" (namestring ,var)) :ignore-error-status t))))))

Macroexpansion:
(let ((input-file (uiop/run-program:run-program (let ((#:command174 (format nil "mktemp --tmpdir='~a' ~@[-d~*~] ~@[~a~]" d nil "XXXXXX.prolog"))) (when (<= 1 *debug-prolog*) (format *error-output* "~&; ~a~%" #:command174)) #:command174) :output (quote (:string :stripped t))))) (unwind-protect (progn (with-open-file (s input-file :direction :output :if-does-not-exist :error) (dolist (r rules) (print-rule s r))) (let* ((executable (namestring (make-pathname :type "out" :defaults input-file)))) (run-command-with-debug-print (sb-int:quasiquote ("gplc" #S(sb-impl::comma :expr input-file :kind 0) "-o" #S(sb-impl::comma :expr executable :kind 0))) :input input :output output :error error) (run-command-with-debug-print (sb-int:quasiquote (#S(sb-impl::comma :expr executable :kind 0))) :input input :output output :error error))) (if (<= 1 *debug-prolog*) (format *error-output* "~&; not removing ~a for debugging~%" input-file) (uiop/run-program:run-program (format nil "rm -rf ~a" (namestring input-file)) :ignore-error-status t))))
You are a Common Lisp macro expert. Given this code pattern:
(draw-relative (intern (concatenate 'string (string name) "-R")))

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

Macro definition:
(defmacro draw (scene (shape &rest params) &rest opts)
  (let ((element (gensym)))
    `(let ((,element (funcall #'make-svg-element ,shape (append (list ,@params) (list ,@opts)))))
       (add-element ,scene ,element)
       ,element)))

Macroexpansion:
(draw-relative (intern (concatenate (quote string) (string name) "-R")))