j14i/cl-macros huggingface dataset:
Write a Common Lisp macro to handle this code pattern:
(with-decoder-simple-list-semantics (let ((*json-symbols-package* (find-package :json-test)) result) (setf result (json-rpc:invoke-rpc "{\"method\":\"secretmethod\",\"params\":[1,2],\"id\":\"my id\"}")) (json-bind (result error id) result (is-false result) (is-true error) (is (string= id "my id")))))

Problem: Macro call that should be transformed by with-decoder-simple-list-semantics

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

Macroexpansion:
(with-shadowed-custom-vars (set-decoder-simple-list-semantics) (let ((*json-symbols-package* (find-package :json-test)) result) (setf result (json-rpc:invoke-rpc "{\"method\":\"secretmethod\",\"params\":[1,2],\"id\":\"my id\"}")) (json-bind (result error id) result (is-false result) (is-true error) (is (string= id "my id")))))
Define a macro that eliminates this repetitive pattern:
(matrix-ecase 'some-name)

Issue: Macro call that should be transformed by MATRIX-ECASE

Macro definition:
(defmacro MATRIX-ECASE ...)

Macroexpansion:
(let ((#:g244 quote))
  (ecase #:g244))
You are a Common Lisp macro expert. Given this code pattern:
(-<> nil)

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

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

Macroexpansion:
nil
Create a Common Lisp macro for the following transformation. Before code:
(modf place new-value)

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

Macro definition:
(defmacro modf (place value &rest more &environment env)
  "Make a new object \(which may use some of the old object) such that PLACE
evaluates to VALUE.

MORE should have the form...

MORE : NIL
     | (TEMPORARY-BINDING ANOTHER-MODF-PLACE ANOTHER-VALUE . MORE)

Use it to specify a temporary binding for the new object created which will be
used in the subsequence MODF-PLACE NEW-VALUE pairs until the end of the MODF
form."
  (if more
      (destructuring-bind (next-symbol next-place next-value &rest next-more) more
        `(let ((,next-symbol ,(modf-expand value place nil env)))
           (modf ,next-place ,next-value ,@next-more)))
      (modf-expand value place nil env)))

Macroexpansion:
(let ((nil place)) new-value)
Generate a defmacro form that transforms code like this:
(fgather-result nil)

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

Macro definition:
(defmacro FGATHER-RESULT ...)

Macroexpansion:
(nil nil t)
Write a Common Lisp macro to handle this code pattern:
(defmacro+ps nil
    nil)

Problem: Macro call that should be transformed by DEFMACRO+PS

Macro definition:
(defmacro DEFMACRO+PS ...)

Macroexpansion:
(progn
 (defmacro nil ())
 (defpsmacro nil
     nil))
Generate a defmacro form that transforms code like this:
(awhen (not (incf x)) t)

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

Macro definition:
(defmacro awhen (test &body body)
  "Like WHEN, except binds the result of the test to IT (via LET) for the scope
of the body."
  `(anaphoric when ,test ,@body))

Macroexpansion:
(let ((it (not (incf x)))) (when it t))
You are a Common Lisp macro expert. Given this code pattern:
(collect-ignore nil)

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

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

Macroexpansion:
(common-lisp:let* ((#:generator-169 (generator nil)))
  (declare (type generator #:generator-169))
  (tagbody #:ll-170 (next-in #:generator-169 (go end)) (go #:ll-170) end)
  nil)
Write a Common Lisp macro to handle this code pattern:
(-<>> nil)

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

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

Macroexpansion:
nil
Create a Common Lisp macro for the following transformation. Before code:
(gen-lambda () (if (not data) 'generator-stop (prog1 data (setf data (cdr data)))))

What needs to change: 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 (not data) (quote generator-stop) (prog1 data (setf data (cdr data)))))))
Define a macro that eliminates this repetitive pattern:
(defun/1 pow (x y) (expt x y))

Issue: Macro call that should be transformed by defun/1

Macro definition:
(defmacro defun/1 (name arglist &body body)
  "Lisp-1 defun; makes function pointers work."
  `(progn
     (defun ,name ,arglist
       (declare (optimize (speed 0) (debug 3)
                          ;; FIXME: Why do minor warnings result in load errors?
                          #+sbcl (sb-ext:inhibit-warnings 3)))
        
       ,@body)
     (defparameter ,name (vacietis.c:mkptr& (symbol-function ',name)))))

Macroexpansion:
(progn (defun pow (x y) (declare (optimize (speed 0) (debug 3) (sb-ext:inhibit-warnings 3))) (expt x y)) (defparameter pow (vacietis.c:mkptr& (symbol-function (quote pow)))))
You are a Common Lisp macro expert. Given this code pattern:
(define-mustache-character #\= (let ((arg-text (string-trim '(#\Space #\Tab #\=) arg-text))) (prog1 (make-instance 'delimiter-tag :text arg-text) (change-delimiter arg-text))))

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

Macro definition:
(defmacro define-mustache-character (char &body body)
  `(set-mustache-character
    ,char (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))
            ,@body)))

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)))))
Generate a defmacro form that transforms code like this:
(check-cursor-attached cluffer:end-of-buffer-p (cursor))

Pattern to recognize: Macro call that should be transformed by check-cursor-attached

Macro definition:
(defmacro check-cursor-attached (name arguments)
  (let ((args (substitute '(cursor cluffer:cursor) 'cursor arguments)))
    `(defmethod ,name :before ,args
       (declare (ignore ,@(set-difference (remove 'cursor arguments)
                                          lambda-list-keywords)))
       (unless (cluffer:cursor-attached-p cursor)
         (error 'cluffer:cursor-detached)))))

Macroexpansion:
(defmethod cluffer:end-of-buffer-p :before ((cursor cluffer:cursor)) (declare (ignore)) (unless (cluffer:cursor-attached-p cursor) (error (quote cluffer:cursor-detached))))
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-read-only a c e) obj)) (setf a :a c :c) (ensure-same (list a c e) '(:a :c 5) :test 'equal) (ensure-same (list (e obj) (c obj) (a obj)) '(5 3 1) :test 'equal))

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-174| obj) (a (a #:|values-174|)) (c (c #:|values-174|)) (e (e #:|values-174|))) (declare (ignorable #:|values-174|)) (progn (setf a :a c :c) (ensure-same (list a c e) (quote (:a :c 5)) :test (quote equal)) (ensure-same (list (e obj) (c obj) (a obj)) (quote (5 3 1)) :test (quote equal))))
Create a Common Lisp macro for the following transformation. Before code:
(signal-reader-error "Expected } after Unicode character name")

What needs to change: 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 Unicode character name" :format-arguments (list))
You are a Common Lisp macro expert. Given this code pattern:
(fail (warn "An expected warning.") warning)

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

Macro definition:
(defmacro fail (form &optional (type 'error) description &rest format-args)
  `(eval-in-context
    *context*
    (make-instance 'comparison-result
                   :expression '(fail ,form ,type)
                   :value-form '(capture-error ,form)
                   :body (lambda () (capture-error ,form ,(maybe-unquote type)))
                   :expected ',(maybe-unquote type)
                   :comparison 'typep
                   ,@(when description
                       `(:description (format NIL ,description ,@format-args))))))

Macroexpansion:
(eval-in-context *context* (make-instance (quote comparison-result) :expression (quote (fail (warn "An expected warning.") warning)) :value-form (quote (capture-error (warn "An expected warning."))) :body (lambda nil (capture-error (warn "An expected warning.") warning)) :expected (quote warning) :comparison (quote typep)))
You are a Common Lisp macro expert. Given this code pattern:
(assert-values ("changed foo = 1") (foo 1) (foo+1 2) (bar 2) (bar-1 1))

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

Macro definition:
(defmacro assert-values ((desc) &body objects-and-values)
  `(progn
     (trc ,desc)
     ,@(loop for (obj val) in objects-and-values
	    collect `(assert (eql (value ,obj) ,val)))))

Macroexpansion:
(progn (trc "changed foo = 1") (assert (eql (value foo) 1)) (assert (eql (value foo+1) 2)) (assert (eql (value bar) 2)) (assert (eql (value bar-1) 1)))
Create a Common Lisp macro for the following transformation. Before code:
(when (or (typep (node-slot expression) 'function-call) (typep (node-slot expression) 'infix-expression) (typep (node-slot expression) 'prefix-expression) (typep (node-slot expression) 'postfix-expression) (typep (node-slot expression) 'empty) (node-slot force-semicolon)) (format stream ";"))

What needs to change: 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 (or (typep (node-slot expression) (quote function-call)) (typep (node-slot expression) (quote infix-expression)) (typep (node-slot expression) (quote prefix-expression)) (typep (node-slot expression) (quote postfix-expression)) (typep (node-slot expression) (quote empty)) (node-slot force-semicolon)) (format stream ";"))
Create a Common Lisp macro for the following transformation. Before code:
(continue-whopper nil :key nil)

What needs to change: Macro call that should be transformed by CONTINUE-WHOPPER

Macro definition:
(defmacro CONTINUE-WHOPPER ...)

Macroexpansion:
(call-next-method-fn self class-env inst-env mcs%caller mcs%next-methods
                     (list nil :key nil))
Generate a defmacro form that transforms code like this:
(draw scene (:rect :x 30 :y 30 :width 400 :height 150) :fill "rgb(230,230,230)" :stroke "black")

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

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

Macroexpansion:
(let ((#:g164 (funcall (function make-svg-element) :rect (append (list :x 30 :y 30 :width 400 :height 150) (list :fill "rgb(230,230,230)" :stroke "black"))))) (add-element scene #:g164) #:g164)
Write a Common Lisp macro to handle this code pattern:
(letrec* (x) x)

Problem: Macro call that should be transformed by letrec*

Macro definition:
(defmacro letrec* ((&rest bindings) &body body)
  "Like LETREC, but the bindings are evaluated in order.
See Waddell et al., *Fixing Letrec* for motivation.

Cf. `fbindrec*'."
  `(letrec-with setq ,bindings
     ,@body))

Macroexpansion:
(letrec-with setq (x) x)
Define a macro that eliminates this repetitive pattern:
(alist-bind (name type) form (let ((sym (foreign-type-symbol name :cextern *package*))) (push sym *foreign-extern-list*) `(define-foreign-extern ',sym ,name ',@(parse-type type (aval :tag type)))))

Issue: 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 ((#:alist246 form)) (let ((name (aval :name #:alist246)) (type (aval :type #:alist246))) (let ((sym (foreign-type-symbol name :cextern *package*))) (push sym *foreign-extern-list*) (sb-int:quasiquote (define-foreign-extern (quote #S(sb-impl::comma :expr sym :kind 0)) #S(sb-impl::comma :expr name :kind 0) (quote #S(sb-impl::comma :expr (parse-type type (aval :tag type)) :kind 2)))))))
Define a macro that eliminates this repetitive pattern:
(define-simple-type-map variable cl:variable)

Issue: Macro call that should be transformed by define-simple-type-map

Macro definition:
(defmacro define-simple-type-map (class type)
  `(defmethod type ((,class ,class))
     ',type))

Macroexpansion:
(defmethod type ((variable variable)) (quote common-lisp:variable))
Create a Common Lisp macro for the following transformation. Before code:
(undefmessage 'some-name)

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

Macro definition:
(defmacro UNDEFMESSAGE ...)

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

Issue: Macro call that should be transformed by ->

Macro definition:
(defmacro -> ...)

Macroexpansion:
'some-name
Write a Common Lisp macro to handle this code pattern:
(defsynonym multiplying :mult)

Problem: 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 multiplying) (quote synonym)) (quote :mult)))
You are a Common Lisp macro expert. Given this code pattern:
(next-in nil :key nil)

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

Macro definition:
(defmacro NEXT-IN ...)

Macroexpansion:
(do-next-in nil #'(lambda () :key nil))
You are a Common Lisp macro expert. Given this code pattern:
(with-table-name nil (yield obj))

Write a macro that addresses: 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 obj))
Define a macro that eliminates this repetitive pattern:
(decf nil nil)

Issue: Macro call that should be transformed by DECF

Macro definition:
(defmacro DECF ...)

Macroexpansion:
(setq nil (sb-impl::xsubtract nil nil))
Create a Common Lisp macro for the following transformation. Before code:
(read-char*)

What needs to change: Macro call that should be transformed by read-char*

Macro definition:
(defmacro read-char* ()
  "Convenience macro because we always read from the same string with
the same arguments."
  `(read-char *stream* t nil t))

Macroexpansion:
(read-char *stream* t nil t)
Create a Common Lisp macro for the following transformation. Before code:
(defclause (sum expr &optional into var result-type (type 'number)) "Sum into a variable" (return-reduction-code :identity 0 :operation '+ :expression expr :test nil :variable var :type type :accum-kind :increment))

What needs to change: 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-sum-10 (&key ((:sum expr)) ((:into var)) ((:result-type type) (quote number))) "Sum into a variable" (return-reduction-code :identity 0 :operation (quote +) :expression expr :test nil :variable var :type type :accum-kind :increment)) (install-clause-info (quote (sum)) (quote (sum &optional :into :result-type)) (quote clause-sum-10) "Sum into a variable" nil) (quote (sum expr &optional into var result-type (type (quote number)))))
Write a Common Lisp macro to handle this code pattern:
(defun-compile-time walk-multiple-value-call-nondeterministic (map-function reduce-function screamer? partial? nested? form environment) (unless (null (rest (last form))) (error "Improper MULTIPLE-VALUE-CALL-NONDETERMINISTIC: ~S" form)) (unless (>= (length form) 2) (error "MULTIPLE-VALUE-CALL-NONDETERMINISTIC must have at least one ~ argument, a FUNCTION: ~S" form)) (if reduce-function (funcall reduce-function (funcall map-function form 'multiple-value-call-nondeterministic) (reduce reduce-function (mapcar #'(lambda (subform) (walk map-function reduce-function screamer? partial? nested? subform environment)) (rest form)))) (funcall map-function form 'multiple-value-call-nondeterministic)))

Problem: Macro call that should be transformed by defun-compile-time

Macro definition:
(defmacro defun-compile-time (function-name lambda-list &body body)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (cl:defun ,function-name ,lambda-list ,@body)
     (eval-when (:compile-toplevel) (compile ',function-name))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (common-lisp:defun walk-multiple-value-call-nondeterministic (map-function reduce-function screamer? partial? nested? form environment) (unless (null (rest (last form))) (error "Improper MULTIPLE-VALUE-CALL-NONDETERMINISTIC: ~S" form)) (unless (>= (length form) 2) (error "MULTIPLE-VALUE-CALL-NONDETERMINISTIC must have at least one ~ argument, a FUNCTION: ~S" form)) (if reduce-function (funcall reduce-function (funcall map-function form (quote multiple-value-call-nondeterministic)) (reduce reduce-function (mapcar (function (lambda (subform) (walk map-function reduce-function screamer? partial? nested? subform environment))) (rest form)))) (funcall map-function form (quote multiple-value-call-nondeterministic)))) (eval-when (:compile-toplevel) (compile (quote walk-multiple-value-call-nondeterministic))))
Write a Common Lisp macro to handle this code pattern:
(with-table node hash depth (bitmap array bits index hit) (if hit (%hamt-lookup (aref array index) key hash (1+ depth) test) (values nil nil)))

Problem: 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 hit (%hamt-lookup (aref array index) key hash (1+ depth) test) (values nil nil)))
You are a Common Lisp macro expert. Given this code pattern:
(action (:after node-match node) (multiple-value-bind (new-node new-changed?) (maybe-simplify-match node) (when new-changed? (setf changed? t) new-node)))

Write a macro that addresses: 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-match) (lambda (node) (declare (type node-match node)) (multiple-value-bind (new-node new-changed?) (maybe-simplify-match node) (when new-changed? (setf changed? t) new-node))))
Generate a defmacro form that transforms code like this:
(do-for nil
  nil)

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

Macro definition:
(defmacro DO-FOR ...)

Macroexpansion:
(block nil (lc ((block nil (tagbody (return (progn nil))))) progn))
You are a Common Lisp macro expert. Given this code pattern:
(-> :three () (increment))

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 :three nil (increment))
Generate a defmacro form that transforms code like this:
(set-handler nil :key nil)

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

Macro definition:
(defmacro SET-HANDLER ...)

Macroexpansion:
(let ((key :key) (function nil))
  (let ((found (assoc key nil :test #'equal)))
    (if found
        (setf (cdr found) function)
        (prog1 function (push (cons key function) nil)))))