j14i/cl-macros huggingface dataset:
You are a Common Lisp macro expert. Given this code pattern:
(alist-bind (name id fields) form (let ((sym (foreign-type-symbol name :cenum *package*))) (when (symbol-package sym) (pushnew sym *foreign-other-exports-list*)) `(progn ,@(parse-enum-to-const fields) (define-foreign-enum ',sym ,id ',(parse-enum-fields fields)))))

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

Macro definition:
(defmacro alist-bind ((&rest vars) alist &body body)
  "Inefficient but doesn't really matter here"
  (once-only (alist)
    `(let (,@(mapcar (lambda (x)
                       (if (consp x)
                           `(,(car x) (aval ,(cadr x) ,alist))
                           `(,x (aval ,(make-keyword x) ,alist))))
                     vars))
       ,@body)))

Macroexpansion:
(let ((#:alist243 form)) (let ((name (aval :name #:alist243)) (id (aval :id #:alist243)) (fields (aval :fields #:alist243))) (let ((sym (foreign-type-symbol name :cenum *package*))) (when (symbol-package sym) (pushnew sym *foreign-other-exports-list*)) (sb-int:quasiquote (progn #S(sb-impl::comma :expr (parse-enum-to-const fields) :kind 2) (define-foreign-enum (quote #S(sb-impl::comma :expr sym :kind 0)) #S(sb-impl::comma :expr id :kind 0) (quote #S(sb-impl::comma :expr (parse-enum-fields fields) :kind 0))))))))
Define a macro that eliminates this repetitive pattern:
(ltbdd-with-new-hash nil
  nil)

Issue: Macro call that should be transformed by LTBDD-WITH-NEW-HASH

Macro definition:
(defmacro LTBDD-WITH-NEW-HASH ...)

Macroexpansion:
(bdd-call-with-new-hash (lambda () nil) :bdd-node-type
                        '(or lisp-type-bdd-node bdd-leaf))
Write a Common Lisp macro to handle this code pattern:
(atomically nil () (decf counter))

Problem: Macro call that should be transformed by atomically

Macro definition:
(defmacro atomically (invariant &body args)
  "Encloses atomic flow block of code that can be dispatched
concurrently. Non-consing."
  (destructuring-bind (opts lambda-list body) (parse-atomic-block-args args)
    (flow-lambda-macro (flow-context)
      (with-flow-function-macro (body-fu lambda-list body)
        `(dispatch-atomically ,flow-context #',body-fu ,invariant ,@opts)))))

Macroexpansion:
(%flow-lambda (#:flow-context153) (%with-flow-function (#:body-fu154 nil (decf counter)) (dispatch-atomically #:flow-context153 (function #:body-fu154) nil)))
Define a macro that eliminates this repetitive pattern:
(defstore example (&key (a (init-a)) (b a)))

Issue: 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?156) (declare (ignorable a #:a?156)) a) (ensure-store (quote example) (quote (&key (a (the t (a-init-function152)) #:a?156) (b (the t (b-init-function154 a #:a?156)) #:b?157))))))
Write a Common Lisp macro to handle this code pattern:
(define-screamer-package :screamer-user)

Problem: Macro call that should be transformed by define-screamer-package

Macro definition:
(defmacro define-screamer-package (defined-package-name &body options)
  "Convenience wrapper around DEFPACKAGE. Passes its argument directly
to DEFPACKAGE, and automatically injects two additional options:

    \(:shadowing-import-from :screamer :defun :multiple-value-bind :y-or-n-p)
    \(:use :cl :screamer)"
  `(defpackage ,defined-package-name
     ,@options
     (:shadowing-import-from :screamer :defun :multiple-value-bind :y-or-n-p)
     (:use :cl :screamer)))

Macroexpansion:
(defpackage :screamer-user (:shadowing-import-from :screamer :defun :multiple-value-bind :y-or-n-p) (:use :cl :screamer))
Define a macro that eliminates this repetitive pattern:
(with-decoder-simple-clos-semantics (is (equal-objects-p (json:make-object '((hello . "hej") (hi . "tjena")) nil) (decode-json-from-string input))) (is-false (#-cmu identity #+cmu symbol-package (class-name (class-of (decode-json-from-string input))))) (is (equal-objects-p (decode-json-from-string "{ }") (json:make-object nil nil))))

Issue: Macro call that should be transformed by with-decoder-simple-clos-semantics

Macro definition:
(defmacro with-decoder-simple-clos-semantics (&body body)
  "Execute BODY in a dynamic environement where the decoder semantics
is such as set by SET-DECODER-SIMPLE-CLOS-SEMANTICS."
  `(with-shadowed-custom-vars
     (set-decoder-simple-clos-semantics)
     ,@body))

Macroexpansion:
(with-shadowed-custom-vars (set-decoder-simple-clos-semantics) (is (equal-objects-p (make-object (quote ((hello . "hej") (hi . "tjena"))) nil) (decode-json-from-string input))) (is-false (identity (class-name (class-of (decode-json-from-string input))))) (is (equal-objects-p (decode-json-from-string "{ }") (make-object nil nil))))
You are a Common Lisp macro expert. Given this code pattern:
(define-op (:a< infix-op :sql-op-name "@<"))

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

Macro definition:
(defmacro define-op ((op-name struct-type &key sql-op-name include-slots (package (find-package '#:sxql/operator))) &body body)
  (check-type op-name symbol)
  (let ((struct-name (intern (concatenate 'string (symbol-name op-name) #.(string :-op)) package)))
    `(defstruct (,struct-name (:include ,struct-type
                               (name ,(or sql-op-name
                                          (with-output-to-string (s)
                                            (loop for c across (symbol-name op-name)
                                                  if (char= c #\-)
                                                    do (write-char #\Space s)
                                                  else
                                                    do (write-char c s)))))
                               ,@include-slots)
                              (:constructor ,(intern (concatenate 'string
                                                                  #.(string :make-)
                                                                  (symbol-name op-name)
                                                                  #.(string :-op))
                                                     package)
                                  ,(ecase struct-type
                                     ((unary-op
                                       unary-splicing-op
                                       unary-postfix-op) '(var))
                                     ((infix-op
                                       infix-splicing-op
                                       infix-list-op) '(left right))
                                     (conjunctive-op '(&rest expressions)))))
       ,@body)))

Macroexpansion:
(defstruct (a<-op (:include infix-op (name "@<")) (:constructor make-a<-op (left right))))
Define a macro that eliminates this repetitive pattern:
(defclause-driver (for var next next) "General driver; VAR is set to value of NEXT" (return-driver-code :variable var :next (list (do-dsetq var (walk-expr next)))))

Issue: 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-for-next-8 (&key ((:for var)) ((:next next)) generate) "General driver; VAR is set to value of NEXT" (return-driver-code :variable var :next (list (do-dsetq var (walk-expr next))))) (install-clause-info (quote (for :next)) (quote (for :next)) (quote clause-for-next-8) "General driver; VAR is set to value of NEXT" t) (quote (for var next next)))
Define a macro that eliminates this repetitive pattern:
(define-error invalid-v-defun-template () (func-name template) "Template passed to v-def-glsl-template-fun must be a format string: ~a~%~a~%" func-name template)

Issue: 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 invalid-v-defun-template (:error-type varjo-error :prefix "Varjo") (func-name template) "Template passed to v-def-glsl-template-fun must be a format string: ~a~%~a~%" func-name template)
You are a Common Lisp macro expert. Given this code pattern:
(-> :g (a) (put a))

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 :g (a) (put a))
Create a Common Lisp macro for the following transformation. Before code:
(with-destructured-lambda-form nil
    nil)

What needs to change: Macro call that should be transformed by WITH-DESTRUCTURED-LAMBDA-FORM

Macro definition:
(defmacro WITH-DESTRUCTURED-LAMBDA-FORM ...)

Macroexpansion:
(destructuring-bind
    (#:function121 #:name122 #:qualifiers123 #:lambda-list124 #:docstring125
     #:declarations126 #:forms127)
    (split-lambda-form nil)
  (declare
   (ignore #:function121 #:name122 #:qualifiers123 #:lambda-list124
    #:docstring125 #:declarations126 #:forms127)))
Create a Common Lisp macro for the following transformation. Before code:
(static-method-function-test-hook)

What needs to change: Macro call that should be transformed by static-method-function-test-hook

Macro definition:
(defmacro static-method-function-test-hook ()
  "A form of this macro is inserted in method functions, in order to
   allow test code to be inserted."

  nil)

Macroexpansion:
nil
Generate a defmacro form that transforms code like this:
(define-error none-type-in-out-vars () (glsl-name) "One of the values being returned from the shader (~s) is of type :none." glsl-name)

Pattern to recognize: 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 none-type-in-out-vars (:error-type varjo-error :prefix "Varjo") (glsl-name) "One of the values being returned from the shader (~s) is of type :none." glsl-name)
Define a macro that eliminates this repetitive pattern:
(defclause minimizing (form &key (test ''<) saving in) "Same as optimizing but with < as the default test." `(optimizing ,form :test ,test :saving ,saving :in ,in))

Issue: 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 minimizing (form &key (test (quote (quote <))) saving in) "Same as optimizing but with < as the default test." (sb-int:quasiquote (optimizing #S(sb-impl::comma :expr form :kind 0) :test #S(sb-impl::comma :expr test :kind 0) :saving #S(sb-impl::comma :expr saving :kind 0) :in #S(sb-impl::comma :expr in :kind 0)))) (pushnew (quote minimizing) *clauses*))
Create a Common Lisp macro for the following transformation. Before code:
(define-modf-method pathname-name 1 (new-val path) (make-pathname :name new-val :defaults path))

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

Macro definition:
(defmacro define-modf-method (name nth-arg (new-val &rest args) &body body)
  "Define a new modf method.  It inverts NAME forms by modifying the NTH-ARG
term of the arguments of the place form in the MODF macro.  This method can
specialize on any of ARGS."
  ;; Side effect in a macro, I know.  How can you do this via EVAL-WHEN if I
  ;; want it to run even if not a toplevel macro?
  (setf (gethash name *modf-nth-arg*)
        nth-arg)
  `(progn
     (eval-when (:compile-toplevel :load-toplevel :execute)
       (setf (gethash ',name *modf-nth-arg*)
             ,nth-arg))
     (defmethod ,(intern (modf-name name) :modf) (,new-val ,@args)
       ,@body)))

Macroexpansion:
(progn (eval-when (:compile-toplevel :load-toplevel :execute) (setf (gethash (quote pathname-name) *modf-nth-arg*) 1)) (defmethod |BUILDER:COMMON-LISP:PATHNAME-NAME| (new-val path) (make-pathname :name new-val :defaults path)))
Generate a defmacro form that transforms code like this:
(-> nil (value) (setf result value) (mt:open-latch latch))

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

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

Macroexpansion:
(atomically nil (value) (setf result value) (cl-muth:open-latch latch))
Create a Common Lisp macro for the following transformation. Before code:
(with-rules nil)

What needs to change: Macro call that should be transformed by WITH-RULES

Macro definition:
(defmacro WITH-RULES ...)

Macroexpansion:
(dolist (nil (alexandria:hash-table-keys cl-rules.core::*rules*)))
Generate a defmacro form that transforms code like this:
(with-unique-names (this-s) (let ((current-s (get s-indicator current-s-indicator))) (setf (get s-indicator current-s-indicator) this-s) `(symbol-macrolet ((,this-s (internal-symbol-macrolet ((it ,current-s)) ,test)) (it ,this-s)) (,operation it ,@other-args))))

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

Macro definition:
(defmacro with-unique-names ((&rest bindings) &body body)
  `(let ,(mapcar #'(lambda (binding)
		     (destructuring-bind (var prefix)
			 (if (consp binding) binding (list binding binding))
		       `(,var (gensym ,(string prefix)))))
		 bindings)
     ,@body))

Macroexpansion:
(let ((this-s (gensym #A((7) base-char . "THIS-S-")))) (let ((current-s (get s-indicator current-s-indicator))) (setf (get s-indicator current-s-indicator) this-s) (quasiquote (symbol-macrolet ((#S(sb-impl::comma :expr this-s :kind 0) (internal-symbol-macrolet ((it #S(sb-impl::comma :expr current-s :kind 0))) #S(sb-impl::comma :expr test :kind 0))) (it #S(sb-impl::comma :expr this-s :kind 0))) (#S(sb-impl::comma :expr operation :kind 0) it #S(sb-impl::comma :expr other-args :kind 2))))))
Create a Common Lisp macro for the following transformation. Before code:
(bind ((obj (make-instance 'metabang-bind-class-2 :a 1 :b 2 :c 3 :d 4 :e 5)) ((:accessors a c e) obj)) (setf a :a c :c) (list (e obj) (c obj) (a obj)))

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

Macro definition:
(defmacro bind ((&rest bindings) &body body)
  "Bind is a replacement for let*, destructuring-bind, multiple-value-bind and more. 

An example is probably the best way to describe its syntax:

    \(bind \(\(a 2\)
           \(\(b &rest args &key \(c 2\) &allow-other-keys\) '\(:a :c 5 :d 10 :e 54\)\)
           \(\(:values d e\) \(truncate 4.5\)\)
           \(\(:structure xxx- slot1 slot2\) \(make-xxx\)\)
           \(\(:flet name \(arg1 arg2\)\) \(+ arg1 arg2\)\)\)
         \(list a b c d e args\)\)

Simple bindings are as in let*. Destructuring is done if the first item
in a binding is a list. Multiple value binding is done if the first item
in a binding is a list and the first item in the list is ':values'. Other
forms have their own syntax. For example, :structure first has the conc
name and then slot names whereas :flet has the function name and a list
of arguments and then the function body (in an implicit progn)."
  (let (declarations)
    (loop while (and (consp (car body)) (eq (caar body) 'declare)) do
          (push (first body) declarations)
          (setf body (rest body)))
    (if bindings
	(let ((*all-declarations* (bind-expand-declarations (nreverse declarations))))
	  (prog1
	      (bind-macro-helper bindings body)
	    (check-for-unused-variable-declarations *all-declarations*)))
        `(locally
             ,@declarations
           ,@body))))

Macroexpansion:
(let* ((obj (make-instance (quote metabang-bind-class-2) :a 1 :b 2 :c 3 :d 4 :e 5)) (#:|values-176| obj)) (declare (ignorable #:|values-176|)) (with-accessors ((a a) (c c) (e e)) #:|values-176| (progn (setf a :a c :c) (list (e obj) (c obj) (a obj)))))
Generate a defmacro form that transforms code like this:
(define-simple-definition-resolver structure designator-structure-p)

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 structure (structure #:package139) (when (ignore-errors (designator-structure-p structure)) (list (make-instance (quote structure) :designator structure :package #:package139))))
You are a Common Lisp macro expert. Given this code pattern:
(->* nil (progn))

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

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

Macroexpansion:
(-> (progn) nil)
Create a Common Lisp macro for the following transformation. Before code:
(define-condition/a dbi-operational-error (dbi-database-error) () (:documentation "Exception for errors related to the database's operation which are not necessarily under the control of the programmer. This includes such things as unexpected disconnect, datasource name not found, transaction could not be processed, a memory allocation error occured during processing, etc."))

What needs to change: Macro call that should be transformed by define-condition/a

Macro definition:
(defmacro define-condition/a (name parent-types slots &body options)
  `(progn
     (define-condition ,name ,parent-types ,slots ,@options)
     (deftype ,(intern (format nil "<~A>" (symbol-name name))) () ',name)
     (setf (find-class ',(intern (format nil "<~A>" (symbol-name name))))
           (find-class ',name))))

Macroexpansion:
(progn (define-condition dbi-operational-error (dbi-database-error) nil (:documentation "Exception for errors related to the database's operation which are not necessarily under the control of the programmer. This includes such things as unexpected disconnect, datasource name not found, transaction could not be processed, a memory allocation error occured during processing, etc.")) (deftype <dbi-operational-error> nil (quote dbi-operational-error)) (setf (find-class (quote <dbi-operational-error>)) (find-class (quote dbi-operational-error))))
Write a Common Lisp macro to handle this code pattern:
(answer foo 1 2 3)

Problem: Macro call that should be transformed by answer

Macro definition:
(defmacro answer (call &body forms)
  (let ((name (if (listp call) (car call) call))
        (sym (gensym)))
    `(if-called
      ',name
      (let ((,sym (fdefinition ',name)))
        (declare (ignorable ,sym))
        (let ((times 0))
          (lambda (&rest args)
            (declare (ignorable args))
            ,(let ((cases
                     `(case (prog1 times (incf times))
                        ,.(loop
                            for i from 0
                            for (form . rest) on forms
                            collect `(,(if rest i T) ,form)))))
               (if (listp call)
                   `(trivia:match args
                     ((list . ,(cdr call)) ,cases)
                     (_ (unhandled)))
                   cases))))))))

Macroexpansion:
(if-called (quote foo) (let ((#:g163 (fdefinition (quote foo)))) (declare (ignorable #:g163)) (let ((times 0)) (lambda (&rest args) (declare (ignorable args)) (case (prog1 times (incf times)) (0 1) (1 2) (t 3))))))
Generate a defmacro form that transforms code like this:
(defjs reduce5(k vals) (let ((sum 0)) (dolist (c vals) (incf sum c)) (return sum)))

Pattern to recognize: 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) (let ((sum 0)) (dolist (c vals) (incf sum c)) (return sum)))))) (setf (gethash (quote reduce5) *js-definitions*) js-body) (defun reduce5 (k vals) (get-element "retval" (car (docs (db.eval js-body k vals))))))
You are a Common Lisp macro expert. Given this code pattern:
(define-column-type serial () :integer)

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

Macro definition:
(defmacro define-column-type (type-symbol lambda-list &body body)
  (let ((type (gensym "TYPE"))
        (args (gensym "ARGS")))
    `(defmethod cltype-to-dbtype ((,type (eql ',type-symbol)) &rest ,args)
       (declare (ignore ,type))
       (destructuring-bind ,lambda-list ,args
         ,@body))))

Macroexpansion:
(defmethod cltype-to-dbtype ((#:type224 (eql (quote serial))) &rest #:args225) (declare (ignore #:type224)) (destructuring-bind nil #:args225 :integer))
You are a Common Lisp macro expert. Given this code pattern:
(with* nil)

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

Macro definition:
(defmacro WITH* ...)

Macroexpansion:
nil
Create a Common Lisp macro for the following transformation. Before code:
(signal-syntax-error "Empty character class.")

What needs to change: 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 "Empty character class.")
Write a Common Lisp macro to handle this code pattern:
(enable-readtime-wrapper-syntax nil nil)

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

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

Macroexpansion:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-readtime-wrapper-syntax-in-readtable nil nil)
  (values))