j14i/cl-macros huggingface dataset:
You are a Common Lisp macro expert. Given this code pattern:
(integer-writer 8)

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

Macro definition:
(defmacro integer-writer (bytes)
  "Create a function to write integers to a binary stream."
  (let ((bits (* 8 bytes)))
    `(progn
       (declaim (inline ,(integer-writer-name bytes t)
                        ,(integer-writer-name bytes nil)))
       (defun ,(integer-writer-name bytes nil) (socket value)
         (declare (type stream socket)
                  (type (unsigned-byte ,bits) value)
                  #.*optimize*)
         ,@(if (= bytes 1)
               `((write-byte value socket))
               (loop :for byte :from (1- bytes) :downto 0
                     :collect `(write-byte (ldb (byte 8 ,(* byte 8)) value)
                                           socket)))
         (values))
       (defun ,(integer-writer-name bytes t) (socket value)
         (declare (type stream socket)
                  (type (signed-byte ,bits) value)
                  #.*optimize*)
         ,@(if (= bytes 1)
               `((write-byte (ldb (byte 8 0) value) socket))
               (loop :for byte :from (1- bytes) :downto 0
                     :collect `(write-byte (ldb (byte 8 ,(* byte 8)) value)
                                           socket)))
         (values)))))

Macroexpansion:
(progn (declaim (inline write-int8 write-uint8)) (defun write-uint8 (socket value) (declare (type stream socket) (type (unsigned-byte 64) value) (optimize (speed 3) (safety 0) (space 1) (debug 1) (compilation-speed 0))) (write-byte (ldb (byte 8 56) value) socket) (write-byte (ldb (byte 8 48) value) socket) (write-byte (ldb (byte 8 40) value) socket) (write-byte (ldb (byte 8 32) value) socket) (write-byte (ldb (byte 8 24) value) socket) (write-byte (ldb (byte 8 16) value) socket) (write-byte (ldb (byte 8 8) value) socket) (write-byte (ldb (byte 8 0) value) socket) (values)) (defun write-int8 (socket value) (declare (type stream socket) (type (signed-byte 64) value) (optimize (speed 3) (safety 0) (space 1) (debug 1) (compilation-speed 0))) (write-byte (ldb (byte 8 56) value) socket) (write-byte (ldb (byte 8 48) value) socket) (write-byte (ldb (byte 8 40) value) socket) (write-byte (ldb (byte 8 32) value) socket) (write-byte (ldb (byte 8 24) value) socket) (write-byte (ldb (byte 8 16) value) socket) (write-byte (ldb (byte 8 8) value) socket) (write-byte (ldb (byte 8 0) value) socket) (values)))
Define a macro that eliminates this repetitive pattern:
(-> :g (b) (+ b 7))

Issue: Macro call that should be transformed by ->

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

Macroexpansion:
(atomically :g (b) (+ b 7))
Create a Common Lisp macro for the following transformation. Before code:
(draw canvas (:ellipse :cx x :cy y :rx rx :ry ry) :stroke-opacity (* 0.8 (/ n length)))

What needs to change: 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 ((#:g163 (funcall (function make-svg-element) :ellipse (append (list :cx x :cy y :rx rx :ry ry) (list :stroke-opacity (* 0.8 (/ n length))))))) (add-element canvas #:g163) #:g163)
Write a Common Lisp macro to handle this code pattern:
(loop-on-custom (key var value) customizations append (list var value))

Problem: Macro call that should be transformed by loop-on-custom

Macro definition:
(defmacro loop-on-custom ((key var &optional value) &rest clauses)
  (if value
      (destructuring-bind (key-args . clauses) clauses
        `(loop for (,key ,value) on ,key-args by #'cddr
            for ,var = (custom-key-to-variable ,key)
            if ,var ,@clauses))
      `(loop for (,var . ,key) in *custom-vars*
            ,@clauses)))

Macroexpansion:
(loop for (key value) on customizations by (function cddr) for var = (custom-key-to-variable key) if var append (list var value))
Generate a defmacro form that transforms code like this:
(enable-quasi-quoted-binary-to-binary-emitting-form-syntax 'some-name)

Pattern to recognize: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BINARY-TO-BINARY-EMITTING-FORM-SYNTAX

Macro definition:
(defmacro ENABLE-QUASI-QUOTED-BINARY-TO-BINARY-EMITTING-FORM-SYNTAX ...)

Macroexpansion:
(eval-when (:compile-toplevel :execute)
  (setf *readtable* (copy-readtable *readtable*))
  (set-quasi-quoted-binary-to-binary-emitting-form-syntax-in-readtable
   'some-name :with-inline-emitting nil :declarations 'nil :start-character nil
   :end-character nil :unquote-character #\COMMA :splice-character
   #\COMMERCIAL_AT :destructive-splice-character #\FULL_STOP
   :dispatched-quasi-quote-name "bin")
  (values))
Define a macro that eliminates this repetitive pattern:
(define-compile-struct sql-clause)

Issue: Macro call that should be transformed by define-compile-struct

Macro definition:
(defmacro define-compile-struct (structure-name &rest defstruct-options)
  (flet ((symbolcat (&rest symbols)
           (intern (format nil "~{~A~^-~}" symbols) #.*package*)))
    (let ((compiled-name (symbolcat structure-name :compiled)))
      `(progn
         (defstruct (,compiled-name (:include ,structure-name ,@defstruct-options))
           (sql nil :type string)
           (bind nil :type list))

         (defmethod find-compile-function ((object ,structure-name))
           (function ,(symbolcat :make compiled-name)))

         (defmethod print-object ((object ,compiled-name) stream)
           (format stream "#<SXQL-COMPILED: ~A [~{~A~^, ~}]>"
                   (,(symbolcat compiled-name :sql) object)
                   (,(symbolcat compiled-name :bind) object)))

         (defmethod yield ((object ,compiled-name))
           (values
            (,(symbolcat compiled-name :sql) object)
            (,(symbolcat compiled-name :bind) object)))))))

Macroexpansion:
(progn (defstruct (sql-clause-compiled (:include sql-clause)) (sql nil :type string) (bind nil :type list)) (defmethod find-compile-function ((object sql-clause)) (function make-sql-clause-compiled)) (defmethod print-object ((object sql-clause-compiled) stream) (format stream "#<SXQL-COMPILED: ~A [~{~A~^, ~}]>" (sql-clause-compiled-sql object) (sql-clause-compiled-bind object))) (defmethod yield ((object sql-clause-compiled)) (values (sql-clause-compiled-sql object) (sql-clause-compiled-bind object))))
Create a Common Lisp macro for the following transformation. Before code:
(augment *step* step)

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

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

Macroexpansion:
(setf *step* (nconc *step* step))
Create a Common Lisp macro for the following transformation. Before code:
(@ nil :key nil)

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

Macro definition:
(defmacro @ ...)

Macroexpansion:
(@ (message-oo.mangle::key nil) nil)
Create a Common Lisp macro for the following transformation. Before code:
(gatherlet nil
  nil)

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

Macro definition:
(defmacro GATHERLET ...)

Macroexpansion:
(common-lisp:let ()
  nil)
Create a Common Lisp macro for the following transformation. Before code:
(action (:after node-application node) (when (eq name (node-rator-name node)) (incf count)) (values))

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

Macro definition:
(defmacro action ((when type &rest args) &body body)
  "Construct an action block, turning `body` into a lambda function
accepting `args` if `args` are provided. If there are no `args`, then
`body` is assumed to be a function object and is used directly with
`when` and `type` to create an `action` instance. Otherwise, the first
argument in `args` is declared to be a node of type `type`, and the
`args` and `body` are used to generate a lambda function."
  (check-type when keyword)
  (check-type type symbol)
  (assert (subtypep type 'node))
  (assert (or (not (endp args)) (= 1 (length body))))
  (if (endp args)
      `(make-action ',when ',type ,@body)
      `(make-action ',when ',type
                    (lambda (,@args)
                      (declare (type ,type ,(first args)))
                      ,@body))))

Macroexpansion:
(make-action (quote :after) (quote node-application) (lambda (node) (declare (type node-application node)) (when (eq name (node-rator-name node)) (incf count)) (values)))
You are a Common Lisp macro expert. Given this code pattern:
(defguarantee make-instance ((class contracted-class) &key &allow-other-keys) (passes-invariants-p (results)))

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

Macro definition:
(defmacro defguarantee (name (&rest lambda-list) &body body)
  "Adds a postcondition to the NAMEd function. It can be either a generic or
   non-generic function. If it's the former, then use a specialized lambda list,
   otherwise use an ordinary lambda list. The docstring, if any, will be used in
   failure reports."
  #+qpq-postcondition-checks-disabled
  (declare (ignore name lambda-list body))
  #+qpq-postcondition-checks-disabled
  (values)
  #-qpq-postcondition-checks-disabled
  (multiple-value-bind (remaining-forms declarations doc-string)
      (parse-body body :documentation t)
    (declare (ignore declarations))
    (let* ((stripped-ll (strip-lambda-list lambda-list))
           (lambda-vars (remove-if (rcurry #'member
                                           '(&optional &rest
                                             &key &allow-other-keys &aux))
                                   stripped-ll))
           (method `(progn
                      (ensure-contracted-function ',name ',stripped-ll)
                      (defmethod ,name
                          :guarantee
                          ,(or doc-string
                            (format nil "~A"
                             (description<-remaining-forms
                              remaining-forms)))
                        ,lambda-list
                        (declare (ignorable ,@lambda-vars))
                        ,@body))))
      (if (every #'symbolp lambda-list)
          `(if (and (fboundp ',name)
                    (not (typep (fdefinition ',name) 'generic-function)))
               (defcontract ,name :guarantee ,lambda-list
                 (declare (ignorable ,@lambda-vars))
                 ,@body)
               ,method)
          method))))

Macroexpansion:
(progn (ensure-contracted-function (quote make-instance) (quote (class &key &allow-other-keys))) (defmethod make-instance :guarantee #A((31) base-char . "(PASSES-INVARIANTS-P (RESULTS))") ((class contracted-class) &key &allow-other-keys) (declare (ignorable class)) (passes-invariants-p (results))))
You are a Common Lisp macro expert. Given this code pattern:
(as->* nil
  :key
  nil)

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

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

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

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

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

Macroexpansion:
(progn
 (defmacro nil :key nil)
 (defpsmacro nil
     :key
   nil))
Generate a defmacro form that transforms code like this:
(undefreply 'some-name)

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

Macro definition:
(defmacro UNDEFREPLY ...)

Macroexpansion:
(undefine-reply ''some-name :qualifiers 'nil :participants `nil)
Define a macro that eliminates this repetitive pattern:
(c?-with-stored (v :foo store 'nothing) (bwhen (val (value v)) val))

Issue: Macro call that should be transformed by c?

Macro definition:
(defmacro c? (&body body)
  `(make-c-dependent
    :code ',body
    :value-state :unevaluated
    :rule (c-lambda ,@body)))

Macroexpansion:
(c? (bwhen-c-stored (v :foo store (quote nothing)) (bwhen (val (value v)) val)))
Generate a defmacro form that transforms code like this:
(with-destructured-lambda-form nil
    (progn))

Pattern to recognize: Macro call that should be transformed by WITH-DESTRUCTURED-LAMBDA-FORM

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

Macroexpansion:
(destructuring-bind
    (#:function128 #:name129 #:qualifiers130 #:lambda-list131 #:docstring132
     #:declarations133 #:forms134)
    (split-lambda-form (progn))
  (declare
   (ignore #:function128 #:name129 #:qualifiers130 #:lambda-list131
    #:docstring132 #:declarations133 #:forms134)))
Define a macro that eliminates this repetitive pattern:
(aif (+ 1 1) (+ 1 it) :never)

Issue: Macro call that should be transformed by aif

Macro definition:
(defmacro aif (test then &optional else)
  "Like IF, except binds the result of the test to IT (via LET) for
the scope of the then and else expressions."  
  `(anaphoric if ,test ,then ,else))

Macroexpansion:
(anaphoric if (+ 1 1) (+ 1 it) :never)
Create a Common Lisp macro for the following transformation. Before code:
(cond-<>
  'some-name)

What needs to change: Macro call that should be transformed by COND-<>

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

Macroexpansion:
'some-name
Define a macro that eliminates this repetitive pattern:
(setdocs (type restart "Class container for restart information. See NAME See REPORT See RESTART See OBJECT See INTERACTIVE See TEST See INVOKE") (function name "Returns the restart's symbol. Use this for INVOKE-RESTART. See RESTART") (function report "Returns the report string describing the restart's effects. See RESTART") (function restart "Returns a symbol to the restart-function or a direct function-object. See RESTART") (function object "Returns the platform-internal restart object. See RESTART") (function interactive "Returns the interactive restart function. See RESTART") (function test "Returns the restart test function. See RESTART") (function invoke "Invoke the restart that the restart object references. See RESTART"))

Issue: Macro call that should be transformed by setdocs

Macro definition:
(defmacro setdocs (&body pairs)
  `(progn
     ,@(loop for (type var doc) in pairs
             collect `(setf (documentation ',var ',type) ,doc))))

Macroexpansion:
(progn (setf (documentation (quote restart) (quote type)) "Class container for restart information. See NAME See REPORT See RESTART See OBJECT See INTERACTIVE See TEST See INVOKE") (setf (documentation (quote name) (quote function)) "Returns the restart's symbol. Use this for INVOKE-RESTART. See RESTART") (setf (documentation (quote report) (quote function)) "Returns the report string describing the restart's effects. See RESTART") (setf (documentation (quote restart) (quote function)) "Returns a symbol to the restart-function or a direct function-object. See RESTART") (setf (documentation (quote object) (quote function)) "Returns the platform-internal restart object. See RESTART") (setf (documentation (quote interactive) (quote function)) "Returns the interactive restart function. See RESTART") (setf (documentation (quote test) (quote function)) "Returns the restart test function. See RESTART") (setf (documentation (quote invoke) (quote function)) "Invoke the restart that the restart object references. See RESTART"))
You are a Common Lisp macro expert. Given this code pattern:
(ps-doc)

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

Macro definition:
(defmacro PS-DOC ...)

Macroexpansion:
""
You are a Common Lisp macro expert. Given this code pattern:
(*> +doctype+ +skip-space+)

Write a macro that addresses: 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 (#:*>-offset265) (multiple-value-bind (#:*>-res266 #:*>-next267) (funcall +doctype+ #:*>-offset265) (if (ok? #:*>-res266) (funcall +skip-space+ #:*>-next267) (fail #:*>-next267))))
Write a Common Lisp macro to handle this code pattern:
(define-error multi-func-stemcells () (func-name) "Multiple functions found named ~a that match arguments.~%However varjo cannot decide which function to use because n of the arguments passed in are of stemcell type" func-name)

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 multi-func-stemcells (:error-type varjo-error :prefix "Varjo") (func-name) "Multiple functions found named ~a that match arguments.~%However varjo cannot decide which function to use because n of the arguments passed in are of stemcell type" func-name)
Create a Common Lisp macro for the following transformation. Before code:
(ps)

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

Macro definition:
(defmacro PS ...)

Macroexpansion:
""
Define a macro that eliminates this repetitive pattern:
(define-modf-expander cdr 1 (expr val new-val) (declare (ignore expr)) `(cons (car ,val) ,new-val))

Issue: Macro call that should be transformed by define-modf-expander

Macro definition:
(defmacro define-modf-expander (name nth-arg
                                (expr val new-val)
                                &body body)
  "Define a new expander which inverts forms starting with NAME.  Your function
should return an expansion from EXPR to a form that will build a new object that
has NEW-VAL in the place specified by expr.  NTH-ARG marks which argument is
considered the actual data which will be inverted next."
  (setf
   (gethash name *modf-nth-arg*)
   nth-arg)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     (setf
      (gethash ',name *modf-nth-arg*)
      ,nth-arg
      (gethash ',name *modf-expansions*)
      (lambda (,expr ,val ,new-val)
        ,@body))))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (setf (gethash (quote cdr) *modf-nth-arg*) 1 (gethash (quote cdr) *modf-expansions*) (lambda (expr val new-val) (declare (ignore expr)) (sb-int:quasiquote (cons (car #S(sb-impl::comma :expr val :kind 0)) #S(sb-impl::comma :expr new-val :kind 0))))))
You are a Common Lisp macro expert. Given this code pattern:
(define-compile-struct sxql/composer:select-query-state)

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

Macro definition:
(defmacro define-compile-struct (structure-name &rest defstruct-options)
  (flet ((symbolcat (&rest symbols)
           (intern (format nil "~{~A~^-~}" symbols) #.*package*)))
    (let ((compiled-name (symbolcat structure-name :compiled)))
      `(progn
         (defstruct (,compiled-name (:include ,structure-name ,@defstruct-options))
           (sql nil :type string)
           (bind nil :type list))

         (defmethod find-compile-function ((object ,structure-name))
           (function ,(symbolcat :make compiled-name)))

         (defmethod print-object ((object ,compiled-name) stream)
           (format stream "#<SXQL-COMPILED: ~A [~{~A~^, ~}]>"
                   (,(symbolcat compiled-name :sql) object)
                   (,(symbolcat compiled-name :bind) object)))

         (defmethod yield ((object ,compiled-name))
           (values
            (,(symbolcat compiled-name :sql) object)
            (,(symbolcat compiled-name :bind) object)))))))

Macroexpansion:
(progn (defstruct (select-query-state-compiled (:include select-query-state)) (sql nil :type string) (bind nil :type list)) (defmethod find-compile-function ((object select-query-state)) (function make-select-query-state-compiled)) (defmethod print-object ((object select-query-state-compiled) stream) (format stream "#<SXQL-COMPILED: ~A [~{~A~^, ~}]>" (select-query-state-compiled-sql object) (select-query-state-compiled-bind object))) (defmethod yield ((object select-query-state-compiled)) (values (select-query-state-compiled-sql object) (select-query-state-compiled-bind object))))
Generate a defmacro form that transforms code like this:
(bind (((:accessors-read-only a c e) (make-instance 'metabang-bind-class-2 :a 1 :b 2 :c 3 :d 4 :e 5))) (list e c a))

Pattern to recognize: 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* ((#:|values-173| (make-instance (quote metabang-bind-class-2) :a 1 :b 2 :c 3 :d 4 :e 5)) (a (a #:|values-173|)) (c (c #:|values-173|)) (e (e #:|values-173|))) (declare (ignorable #:|values-173|)) (progn (list e c a)))
You are a Common Lisp macro expert. Given this code pattern:
(with-standard-definer-options nil
  :key
  nil)

Write a macro that addresses: Macro call that should be transformed by WITH-STANDARD-DEFINER-OPTIONS

Macro definition:
(defmacro WITH-STANDARD-DEFINER-OPTIONS ...)

Macroexpansion:
`(progn
  ,@(when (getf -options- :export)
      `((eval-when (:compile-toplevel :load-toplevel :execute)
          (export ',nil))))
  ,:key
  ,nil)
Define a macro that eliminates this repetitive pattern:
(in-readtable pax:macro)

Issue: Macro call that should be transformed by in-readtable

Macro definition:
(defmacro in-readtable (name)
  "Set *READTABLE* to the readtable referred to by the symbol NAME and
  return the readtable. This may signal READTABLE-DOES-NOT-EXIST.

  - Everything IN-READTABLE does is also performed at [compile time][
    pax:clhs] if the call appears as a [top level form][ pax:clhs].

  - The effects of IN-READTABLE are file-local since both COMPILE-FILE
    and LOAD rebind *READTABLE*."
  (check-type name symbol)
  `(eval-when (:compile-toplevel :load-toplevel :execute)
     ;; NB. The :LOAD-TOPLEVEL is needed for cases like (DEFVAR *FOO*
     ;; (GET-MACRO-CHARACTER #\"))
     (setf *readtable* (ensure-readtable ',name))
     (when (or (find-package :swank) (find-package :slynk))
       (%frob-swank-readtable-alist *package* *readtable*))
     *readtable*))

Macroexpansion:
(eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (ensure-readtable (quote mgl-pax:macro))) (when (or (find-package :swank) (find-package :slynk)) (%frob-swank-readtable-alist *package* *readtable*)) *readtable*)