j14i/cl-macros huggingface dataset:
Write a Common Lisp macro to handle this code pattern:
(with-form-field-values (name) form (print name))

Problem: Macro call that should be transformed by with-form

Macro definition:
(defmacro with-form (form &body body)
  "Bind *FORM* to FORM and evaluate BODY in that context."
  `(call-with-form ,form (lambda () ,@body)))

Macroexpansion:
(let ((name (field-value (get-field form (quote name))))) (print name))
Generate a defmacro form that transforms code like this:
(lambda-coro
  nil
  (progn))

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

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

Macroexpansion:
(progn
 (defcoroutine #:name129
     (#:arg130)
   (macrolet ((yield (form)
                (let ((g!-it (gensym "IT")))
                  `(progn
                    (let ((,g!-it ,form))
                      (cl-coroutine:yield ,g!-it))
                    ,'#:arg130)))
              (last-yield-value ()
                '#:arg130))
     nil
     (progn)
     (coexit!)))
 (make-coroutine '#:name129))
Create a Common Lisp macro for the following transformation. Before code:
(defun-speedy %ascii-string-to-octets (string) (let ((result (make-array (length string) :element-type '(unsigned-byte 8)))) (declare (type octets result)) (dotimes (i (length string) result) (declare (type fixnum i)) (setf (aref result i) (char-code (aref string i))))))

What needs to change: Macro call that should be transformed by defun-speedy

Macro definition:
(defmacro defun-speedy (name lambda-list &body body)
  `(progn
     (declaim (notinline ,name))
     (defun ,name ,lambda-list
       ,*speedy-declaration*
       ,@body)))

Macroexpansion:
(progn (declaim (notinline %ascii-string-to-octets)) (defun %ascii-string-to-octets (string) (declare (optimize (speed 3) (safety 0) (space 0) (compilation-speed 0))) (let ((result (make-array (length string) :element-type (quote (unsigned-byte 8))))) (declare (type octets result)) (dotimes (i (length string) result) (declare (type fixnum i)) (setf (aref result i) (char-code (aref string i)))))))
You are a Common Lisp macro expert. Given this code pattern:
(match0 (coerce (subseq name (- l 2) l) 'list) ((list #\- #\P) (when-let ((typesym (find-symbol (subseq name 0 (- l 2)) (symbol-package fn-sym)))) (if (subtypep typesym t) typesym t))) ((list _ #\P) (when-let ((typesym (find-symbol (subseq name 0 (- l 1)) (symbol-package fn-sym)))) (if (subtypep typesym t) typesym t))))

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

Macro definition:
(defmacro match0 (*what* &body clauses &environment *env*)
  (once-only (*what*)
    (parse-patterns clauses)))

Macroexpansion:
(let ((#:*what*149 (coerce (subseq name (- l 2) l) (quote list)))) (declare (ignorable #:*what*149)) (if (and (consp #:*what*149) (let ((#:*what*150 (car #:*what*149))) (declare (ignorable #:*what*150)) (equal #:*what*150 #\HYPHEN-MINUS)) (let ((#:*what*151 (cdr #:*what*149))) (declare (ignorable #:*what*151)) (and (consp #:*what*151) (let ((#:*what*152 (car #:*what*151))) (declare (ignorable #:*what*152)) (equal #:*what*152 #\LATIN_CAPITAL_LETTER_P)) (let ((#:*what*153 (cdr #:*what*151))) (declare (ignorable #:*what*153)) (equal #:*what*153 nil))))) (let* ((#:*what*150 (car #:*what*149)) (#:*what*151 (cdr #:*what*149)) (#:*what*152 (car #:*what*151)) (#:*what*153 (cdr #:*what*151))) (declare (ignorable #:*what*153 #:*what*152 #:*what*151 #:*what*150)) (when-let ((typesym (find-symbol (subseq name 0 (- l 2)) (symbol-package fn-sym)))) (if (subtypep typesym t) typesym t))) (if (and (consp #:*what*149) (let ((#:*what*154 (car #:*what*149))) (declare (ignorable #:*what*154)) t) (let ((#:*what*155 (cdr #:*what*149))) (declare (ignorable #:*what*155)) (and (consp #:*what*155) (let ((#:*what*156 (car #:*what*155))) (declare (ignorable #:*what*156)) (equal #:*what*156 #\LATIN_CAPITAL_LETTER_P)) (let ((#:*what*157 (cdr #:*what*155))) (declare (ignorable #:*what*157)) (equal #:*what*157 nil))))) (let* ((#:*what*154 (car #:*what*149)) (#:*what*155 (cdr #:*what*149)) (#:*what*156 (car #:*what*155)) (#:*what*157 (cdr #:*what*155))) (declare (ignorable #:*what*157 #:*what*156 #:*what*155 #:*what*154)) (when-let ((typesym (find-symbol (subseq name 0 (- l 1)) (symbol-package fn-sym)))) (if (subtypep typesym t) typesym t))) nil)))
You are a Common Lisp macro expert. Given this code pattern:
(do-generator (item generator) (unless (funcall predicate item) (return)) (yield item))

Write a macro that addresses: 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 ((#:g161 generator)) (loop do (if-generator ((item) #:g161) (progn (unless (funcall predicate item) (return)) (yield item)) (return))))
Define a macro that eliminates this repetitive pattern:
(defstruct-compile-time (nondeterministic-function (:print-function print-nondeterministic-function) (:predicate nondeterministic-function?-internal)) function)

Issue: Macro call that should be transformed by defstruct-compile-time

Macro definition:
(defmacro defstruct-compile-time (options &body items)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (defstruct ,options ,@items)))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (defstruct (nondeterministic-function (:print-function print-nondeterministic-function) (:predicate nondeterministic-function?-internal)) function))
Write a Common Lisp macro to handle this code pattern:
(define-option-expander use (package &rest packages) (use-package packages package))

Problem: Macro call that should be transformed by define-option-expander

Macro definition:
(defmacro define-option-expander (name (package &rest arguments) &body body)
  (let ((args (gensym "ARGS")))
    `(defmethod expand-option ((,(gensym "TYPE") (eql ,(intern (string name) "KEYWORD"))) ,package ,args)
       (destructuring-bind ,arguments ,args
         ,@body))))

Macroexpansion:
(defmethod expand-option ((#:type126 (eql :use)) package #:args125) (destructuring-bind (&rest packages) #:args125 (use-package packages package)))
Define a macro that eliminates this repetitive pattern:
(-<> nil (progn))

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

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

Macroexpansion:
(progn nil)
Generate a defmacro form that transforms code like this:
(with-table node hash depth (bitmap array bits index hit) (if (not hit) node (let ((new-node (%hamt-remove (aref array index) key hash (1+ depth) test))) (cond (new-node (make-instance (type-of node) :bitmap bitmap :table (vec-update array index new-node))) ((= bitmap 1) nil) (t (make-instance (type-of node) :bitmap (logxor bitmap (ash 1 bits)) :table (vec-remove array index)))))))

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

Macro definition:
(defmacro with-table (node hash depth
                      (bitmap array bits index hit)
                      &body body)
  "Bitshifting in HAMT tables"
  `(let* ((,bitmap (table-bitmap ,node))
          (,array (table-array ,node))
          (,bits (get-bits ,hash ,depth))
          (,index (get-index ,bits ,bitmap))
          (,hit (logbitp ,bits ,bitmap)))
     ,@body))

Macroexpansion:
(let* ((bitmap (table-bitmap node)) (array (table-array node)) (bits (get-bits hash depth)) (index (get-index bits bitmap)) (hit (logbitp bits bitmap))) (if (not hit) node (let ((new-node (%hamt-remove (aref array index) key hash (1+ depth) test))) (cond (new-node (make-instance (type-of node) :bitmap bitmap :table (vec-update array index new-node))) ((= bitmap 1) nil) (t (make-instance (type-of node) :bitmap (logxor bitmap (ash 1 bits)) :table (vec-remove array index)))))))
Generate a defmacro form that transforms code like this:
(with-package (package (or identifier *package*)) (cond ((not package) (error 'module-not-found :requested identifier)) (T (or (resolve-module package) (error 'not-a-module :requested package)))))

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

Macro definition:
(defmacro with-package ((var &optional (package var)) &body body)
  `(let ((,var (ensure-package ,package)))
     ,@body))

Macroexpansion:
(let ((package (ensure-package (or identifier *package*)))) (cond ((not package) (error (quote module-not-found) :requested identifier)) (t (or (resolve-module package) (error (quote not-a-module) :requested package)))))
Create a Common Lisp macro for the following transformation. Before code:
(%proper-list-p var 'cons)

What needs to change: Macro call that should be transformed by %proper-list-p

Macro definition:
(defmacro %proper-list-p (var &optional (element-type '*))
  `(loop
     (typecase ,var
       (null (return t))
       (cons (if (or ,(eq element-type '*)
                     (typep (car ,var) ,element-type))
                 (setq ,var (cdr ,var))
                 (return)))
       (t    (return)))))

Macroexpansion:
(loop (typecase var (null (return t)) (cons (if (or nil (typep (car var) (quote cons))) (setq var (cdr var)) (return))) (t (return))))
Write a Common Lisp macro to handle this code pattern:
(defaction nil
    (progn))

Problem: Macro call that should be transformed by DEFACTION

Macro definition:
(defmacro DEFACTION ...)

Macroexpansion:
(setf (gethash #A((3) base-char . "NIL") cl-rules.core::*actions*)
        (lambda (progn)))
You are a Common Lisp macro expert. Given this code pattern:
(deferror "23" integrity-violation)

Write a macro that addresses: 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 integrity-violation (database-error) nil) (setf (gethash "23" *error-table*) (quote integrity-violation)))
Write a Common Lisp macro to handle this code pattern:
(ct-let nil
  nil)

Problem: Macro call that should be transformed by CT-LET

Macro definition:
(defmacro CT-LET ...)

Macroexpansion:
(cond
 (*within-captured-dynenv*
  (let ()
    (let ((#:new-var-space151
           (reduce
            (lambda (#:accum152 #:item153)
              (destructuring-bind
                  (#:name154 . #:value155)
                  #:item153
                (update-alist #:name154 #:value155 #:accum152)))
            (list) :initial-value *var-space*)))
      `(symbol-macrolet ((var-space ,#:new-var-space151))
         ,(let ((*var-space* #:new-var-space151))
            nil)))))
 (t
  (error
   "No macrodynamic environment has been captured to establish CT-LET bindings.")))
Create a Common Lisp macro for the following transformation. Before code:
(f_
  'some-name)

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

Macro definition:
(defmacro F_ ...)

Macroexpansion:
(lambda (_) 'some-name)
Define a macro that eliminates this repetitive pattern:
(some-> nil)

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

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

Macroexpansion:
(let* ((#:|some125| nil))
  #:|some125|)
Write a Common Lisp macro to handle this code pattern:
(alist-bind (name inline parameters return-type variadic) form (unless inline (let ((sym (foreign-type-symbol name :cfun *package*))) (let ((cfun-fields (parse-fields parameters :cparam))) (push sym *foreign-function-list*) `(define-foreign-function '(,sym ,name ,@(when variadic '(:variadic-p t))) ',@(parse-type return-type (aval :tag return-type)) ',cfun-fields)))))

Problem: 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 ((#:alist244 form)) (let ((name (aval :name #:alist244)) (inline (aval :inline #:alist244)) (parameters (aval :parameters #:alist244)) (return-type (aval :return-type #:alist244)) (variadic (aval :variadic #:alist244))) (unless inline (let ((sym (foreign-type-symbol name :cfun *package*))) (let ((cfun-fields (parse-fields parameters :cparam))) (push sym *foreign-function-list*) (sb-int:quasiquote (define-foreign-function (quote (#S(sb-impl::comma :expr sym :kind 0) #S(sb-impl::comma :expr name :kind 0) #S(sb-impl::comma :expr (when variadic (quote (:variadic-p t))) :kind 2))) (quote #S(sb-impl::comma :expr (parse-type return-type (aval :tag return-type)) :kind 2)) (quote #S(sb-impl::comma :expr cfun-fields :kind 0)))))))))
Create a Common Lisp macro for the following transformation. Before code:
(define-modf-rewrite cadr (expr) `(car (cdr ,(second expr))))

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

Macro definition:
(defmacro define-modf-rewrite (name (expr) &body body)
  "Define a new rewrite rule.  If a form starting with NAME is encountered, call
the defined function to return a form that we can deal with (i.e. one defined
via DEFINE-MODF-EXPANDER, DEFINE-MODF-FUNCTION, and DEFINE-MODF-METHOD)."
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf (gethash ',name *modf-rewrites*)
           (lambda (,expr)
             ,@body))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (setf (gethash (quote cadr) *modf-rewrites*) (lambda (expr) (sb-int:quasiquote (car (cdr #S(sb-impl::comma :expr (second expr) :kind 0)))))))
Define a macro that eliminates this repetitive pattern:
(sor (elt-like 0 cell) (setf it 1))

Issue: Macro call that should be transformed by sor

Macro definition:
(defmacro sor (first &rest rest)
  "Like OR, except binds the first argument to IT (via SYMBOL-MACROLET) for
the scope of the rest of the arguments. IT can be set with SETF."
  `(symbolic or ,first ,@rest))

Macroexpansion:
(symbolic or (elt-like 0 cell) (setf it 1))
Define a macro that eliminates this repetitive pattern:
(augment *special-clause-alist* (list (cons symbol doc-string)))

Issue: Macro call that should be transformed by augment

Macro definition:
(defmacro augment (var stuff)
  `(setf ,var (nconc ,var ,stuff)))

Macroexpansion:
(setf *special-clause-alist* (nconc *special-clause-alist* (list (cons symbol doc-string))))
Define a macro that eliminates this repetitive pattern:
(js-inline nil nil)

Issue: Macro call that should be transformed by JS-INLINE

Macro definition:
(defmacro JS-INLINE ...)

Macroexpansion:
(js-inline* '(progn nil nil))
Write a Common Lisp macro to handle this code pattern:
($unset "k" "l")

Problem: Macro call that should be transformed by $

Macro definition:
(defmacro $ (&rest args)
  `(kv ,@args))

Macroexpansion:
(kv "$unset" (construct-container* 1 (unwrap ($exp+ "k" "l"))))
Write a Common Lisp macro to handle this code pattern:
(while nil)

Problem: Macro call that should be transformed by WHILE

Macro definition:
(defmacro WHILE ...)

Macroexpansion:
(loop while nil
      do (progn))
You are a Common Lisp macro expert. Given this code pattern:
(signal-reader-error "Expected } after hex code")

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

Macro definition:
(defmacro signal-reader-error (format-control &rest format-arguments)
  "Like ERROR but signals a SIMPLE-READER-ERROR for the stream
*STREAM*."
  `(error 'simple-reader-error
          :stream *stream*
          :format-control ,format-control
          :format-arguments (list ,@format-arguments)))

Macroexpansion:
(error (quote simple-reader-error) :stream *stream* :format-control "Expected } after hex code" :format-arguments (list))
Define a macro that eliminates this repetitive pattern:
(lambda+ nil
  nil)

Issue: Macro call that should be transformed by LAMBDA+

Macro definition:
(defmacro LAMBDA+ ...)

Macroexpansion:
(lambda ()
  (let+ nil
    nil))
Define a macro that eliminates this repetitive pattern:
(augment *finalp* finalp)

Issue: Macro call that should be transformed by augment

Macro definition:
(defmacro augment (var stuff)
  `(setf ,var (nconc ,var ,stuff)))

Macroexpansion:
(setf *finalp* (nconc *finalp* finalp))
Generate a defmacro form that transforms code like this:
(signal-syntax-error* (lexer-pos lexer) "Expected end of string.")

Pattern to recognize: Macro call that should be transformed by signal-syntax-error*

Macro definition:
(defmacro signal-syntax-error* (pos format-control &rest format-arguments)
  `(error 'ppcre-syntax-error
          :pos ,pos
          :format-control ,format-control
          :format-arguments (list ,@format-arguments)))

Macroexpansion:
(error (quote ppcre-syntax-error) :pos (lexer-pos lexer) :format-control "Expected end of string." :format-arguments (list))
Generate a defmacro form that transforms code like this:
(define-custom-var (:string-char *string-char-handler*))

Pattern to recognize: Macro call that should be transformed by define-custom-var

Macro definition:
(defmacro define-custom-var ((key name) &rest other-args)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (progn (pushnew '(,name . ,key) *custom-vars* :test #'equal)
            (defvar ,name ,@other-args))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (pushnew (quote (*string-char-handler* . :string-char)) *custom-vars* :test (function equal)) (defvar *string-char-handler*)))
Create a Common Lisp macro for the following transformation. Before code:
(doseq (elem sequence :from-end from-end :start start :end end) (when (funcall test (funcall key elem)) (return (compute-pos pos))) (incf pos))

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

Macro definition:
(defmacro doseq (name/seq &body body)
  "Iterate over the elements of a single sequence SEQUENCE.

   Same as DO-SEQUENCES but for the special case of iterating over a
   single sequence.

   The macro arguments can be in one of the following two forms:

    1. (NAME (ELEMENT SEQUENCE &REST ARGS) &BODY BODY)

    2. ((ELEMENT SEQUENCE &REST ARGS) &BODY BODY)

   NAME is the block name, NIL if not given.

   ELEMENT is the variable to which each element of the sequence is
   bound.

   SEQUENCE is the sequence, with ARGS being the remaining arguments
   passed to the ITERATOR function.

   BODY is the list of forms evaluated on each iteration."

  (let-if ((name name/seq)
           (seq (first body) name/seq)
           (body (rest body) body))
      (symbolp name/seq)

    (destructuring-bind (element sequence &rest args) seq
      `(do-sequences ,name
         ((,element ,sequence ,@args))
         ,@body))))

Macroexpansion:
(do-sequences nil ((elem sequence :from-end from-end :start start :end end)) (when (funcall test (funcall key elem)) (return (compute-pos pos))) (incf pos))
Generate a defmacro form that transforms code like this:
(define-custom-var (:array-member *array-member-handler*) (constantly t) "Designator for a function of 1 arbitrary argument (decoded member of Array).")

Pattern to recognize: Macro call that should be transformed by define-custom-var

Macro definition:
(defmacro define-custom-var ((key name) &rest other-args)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (progn (pushnew '(,name . ,key) *custom-vars* :test #'equal)
            (defvar ,name ,@other-args))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (progn (pushnew (quote (*array-member-handler* . :array-member)) *custom-vars* :test (function equal)) (defvar *array-member-handler* (constantly t) "Designator for a function of 1 arbitrary argument (decoded member of Array).")))
Generate a defmacro form that transforms code like this:
(define-cruft %find-readtable (name) "Return the readtable named NAME." #+ :allegro (excl:named-readtable (readtable-name-for-allegro name) nil) #+ :common-lisp (values (gethash name *named-readtables* nil)))

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

Macro definition:
(defmacro define-cruft (name lambda-list &body (docstring . alternatives))
  (assert (typep docstring 'string) (docstring) "Docstring missing!")
  (assert (not (null alternatives)))
  `(progn
     (declaim (inline ,name))
     (defun ,name ,lambda-list ,docstring ,(first alternatives))))

Macroexpansion:
(progn (declaim (inline %find-readtable)) (defun %find-readtable (name) "Return the readtable named NAME." (values (gethash name *named-readtables* nil))))
Generate a defmacro form that transforms code like this:
(mapcar 'binding-to-symbol bindings)

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

Macro definition:
(defmacro m (form &environment *env*)
  (e form))

Macroexpansion:
(mapcar (quote binding-to-symbol) bindings)
You are a Common Lisp macro expert. Given this code pattern:
(doseq 'some-name)

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

Macro definition:
(defmacro doseq ((var seq-form &optional result-form) &body body)
  "doseq iterates over the elements of an sequence and binds value-var to successive values
and then evaluates body as a tagbody that can include declarations. Finally the result-form
is returned after the iteration completes."
  #+clisp
    `(ext:doseq (,var ,seq-form ,result-form)
       ,@body)
  #+sbcl
    `(sb-sequence:dosequence (,var ,seq-form ,result-form)
       ,@body)
  #-(or clisp sbcl)
    `(doseq* (,(gensym) ,var ,seq-form ,result-form)
       ,@body))

Macroexpansion:
(sb-sequence:dosequence (quote some-name nil))