diff --git "a/test_chat.jsonl" "b/test_chat.jsonl" deleted file mode 100644--- "a/test_chat.jsonl" +++ /dev/null @@ -1,669 +0,0 @@ -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(for-all* nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by FOR-ALL*\n\n(for-all* nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro for-all* (bindings &body body)\n \"Bind BINDINGS to random variables and test BODY *num-trials* times.\n\nWorks like FOR-ALL but variables are defined sequentially - subsequent\ngenerator bindings may use value of a previous generator.\n\nExample:\n\n (for-all* ((a (gen-integer))\n (b (gen-integer :min a :max (+ a 20)))\n (is (<= a b)))\"\n (with-gensyms (test-lambda-args)\n `(perform-random-testing\n nil\n (lambda (,test-lambda-args)\n (declare (ignore ,test-lambda-args))\n (dbind-rec ,bindings\n (if (and ,@(delete-if #'null (mapcar #'third bindings)))\n (progn ,@body)\n (throw 'run-once\n (list :guard-conditions-failed))))))))\n\n;; macroexpand:\n(perform-random-testing nil\n (lambda (#:test-lambda-args135)\n (declare (ignore #:test-lambda-args135))\n (dbind-rec nil\n (if (and)\n (progn :key nil)\n (throw 'run-once\n (list :guard-conditions-failed))))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(when-let* nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WHEN-LET*\n\n(when-let* nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro when-let* (bindings &body body)\n \"Creates new variable bindings, and conditionally executes BODY.\n\nBINDINGS must be either single binding of the form:\n\n (variable initial-form)\n\nor a list of bindings of the form:\n\n ((variable-1 initial-form-1)\n (variable-2 initial-form-2)\n ...\n (variable-n initial-form-n))\n\nEach INITIAL-FORM is executed in turn, and the variable bound to the\ncorresponding value. INITIAL-FORM expressions can refer to variables\npreviously bound by the WHEN-LET*.\n\nExecution of WHEN-LET* stops immediately if any INITIAL-FORM evaluates to NIL.\nIf all INITIAL-FORMs evaluate to true, then BODY is executed as an implicit\nPROGN.\"\n (let ((binding-list (if (and (consp bindings) (symbolp (car bindings)))\n (list bindings)\n bindings)))\n (labels ((bind (bindings body)\n (if bindings\n `(let (,(car bindings))\n (when ,(caar bindings)\n ,(bind (cdr bindings) body)))\n `(progn ,@body))))\n (bind binding-list body))))\n\n;; macroexpand:\n(progn :key nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(is-expand nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IS-EXPAND\n\n(is-expand nil nil)"}, {"role": "assistant", "content": "(defmacro is-expand (got expected &optional desc)\n (with-gensyms (duration expanded)\n (once-only (desc)\n `(with-duration ((,duration ,expanded) (macroexpand-1 ',got))\n (let (*gensym-alist*)\n (test ,expanded ',expected ,desc\n :duration ,duration\n :got-form ',got\n :report-expected-label \"be expanded to\"\n :test-fn #'gensym-tree-equal))))))\n\n;; macroexpand:\n(let ((#:desc175 nil))\n (prove.test::with-duration ((#:duration173 #:expanded174)\n (macroexpand-1 'nil))\n (let (prove.test::*gensym-alist*)\n (prove.test::test #:expanded174 'nil #:desc175 :duration #:duration173\n :got-form 'nil :report-expected-label \"be expanded to\"\n :test-fn #'prove.test::gensym-tree-equal))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(export-class\n common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by EXPORT-CLASS\n\n(export-class\n common-lisp:nil\n (common-lisp:progn))"}, {"role": "assistant", "content": "(defmacro EXPORT-CLASS ...)\n\n;; macroexpand:\n(common-lisp:progn\n (export-class\n common-lisp:nil)\n (export-class\n (common-lisp:progn)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-unique-names nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-UNIQUE-NAMES\n\n(with-unique-names nil\n (progn))"}, {"role": "assistant", "content": "(defmacro with-unique-names (names &body body)\n `(let ,(mapcar (lambda (sym)\n `(,sym (gensym ,(symbol-name sym))))\n names)\n ,@body))\n\n;; macroexpand:\n(let ()\n (progn))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(accumulating-to 'some-name)\n\nProblem: Macro call that should be transformed by ACCUMULATING-TO\n\n(accumulating-to 'some-name)"}, {"role": "assistant", "content": "(defmacro ACCUMULATING-TO ...)\n\n;; macroexpand:\n(((with quote)) #S(accumulator :var quote :function #'cons)\n #S(finalization :form (setf quote (funcall #'nreverse quote)))\n ((with some-name)) #S(accumulator :var some-name :function #'cons)\n #S(finalization :form (setf some-name (funcall #'nreverse some-name))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(pop-assoc nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by POP-ASSOC\n\n(pop-assoc nil :key nil)"}, {"role": "assistant", "content": "(defmacro pop-assoc (key alist &rest args &environment env)\n \"Like `assoc' but, if there was a match, delete it from ALIST.\n\nFrom Newlisp.\"\n (multiple-value-bind (vars vals new setter getter)\n (get-setf-expansion alist env)\n (with-gensyms (match)\n `(let* (,@(mapcar #'list vars vals)\n (,(car new) ,getter))\n (let ((,match (assoc ,key ,(car new) ,@args)))\n (declare (list ,match))\n (prog1 ,match\n (when ,match\n (setf ,(car new) (efface ,match ,(car new))))\n ,setter))))))\n\n;; macroexpand:\n(let* ((#:new285 :key))\n (let ((#:match286 (assoc nil #:new285 nil)))\n (declare (list #:match286))\n (prog1 #:match286\n (when #:match286 (setf #:new285 (efface #:match286 #:new285)))\n (setq :key #:new285))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(do-tags-in-lexenv 'some-name)\n\nProblem: Macro call that should be transformed by DO-TAGS-IN-LEXENV\n\n(do-tags-in-lexenv 'some-name)"}, {"role": "assistant", "content": "(defmacro DO-TAGS-IN-LEXENV ...)\n\n;; macroexpand:\n(block nil (iterate-tags-in-lexenv (lambda (some-name)) quote))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-standard-io-syntax nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-STANDARD-IO-SYNTAX\n\n(with-standard-io-syntax nil :key nil)"}, {"role": "assistant", "content": "(defmacro WITH-STANDARD-IO-SYNTAX ...)\n\n;; macroexpand:\n(sb-int:dx-flet ((#:thunk ()\n nil\n :key\n nil))\n (sb-impl::%with-standard-io-syntax #'#:thunk))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(gather-next nil (progn))\n\nIssue: Macro call that should be transformed by GATHER-NEXT\n\n(gather-next nil (progn))"}, {"role": "assistant", "content": "(defmacro GATHER-NEXT ...)\n\n;; macroexpand:\n(common-lisp:funcall nil (progn) nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(counting 'some-name)\n\nProblem: Macro call that should be transformed by COUNTING\n\n(counting 'some-name)"}, {"role": "assistant", "content": "(defmacro COUNTING ...)\n\n;; macroexpand:\n((with 'some-name) #S(initialization :form (setf 'some-name 0))\n #S(step :form (setf 'some-name (1+ 'some-name))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-explicit-encoder\n nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-EXPLICIT-ENCODER\n\n(with-explicit-encoder\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro with-explicit-encoder (&body body)\n `(with-local-encoder (use-explicit-encoder)\n ,@body))\n\n;; macroexpand:\n(with-local-encoder\n (use-explicit-encoder)\n nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(<* nil nil)\n\nPattern to recognize: Macro call that should be transformed by <*\n\n(<* nil nil)"}, {"role": "assistant", "content": "(defmacro <* (parser &rest parsers)\n \"Combination of parsers yielding the result of the leftmost one.\"\n (let ((offset (gensym \"<*-OFFSET\")))\n `(lambda (,offset)\n ,(reduce (lambda (i p)\n (let ((res0 (gensym \"<*-RES\"))\n (next (gensym \"<*-NEXT\")))\n `(multiple-value-bind (,res0 ,next) ,i\n (if (ok? ,res0)\n (multiple-value-bind (res next) (funcall ,p ,next)\n (if (ok? res)\n (values ,res0 next)\n (fail next)))\n (fail ,next)))))\n parsers\n :initial-value `(funcall ,parser ,offset)))))\n\n;; macroexpand:\n(lambda (#:<*-offset179)\n (multiple-value-bind (#:<*-res180 #:<*-next181)\n (funcall nil #:<*-offset179)\n (if (ok? #:<*-res180)\n (multiple-value-bind (res next)\n (funcall nil #:<*-next181)\n (if (ok? res)\n (values #:<*-res180 next)\n (fail next)))\n (fail #:<*-next181))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-constant-inject-hook nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-CONSTANT-INJECT-HOOK\n\n(with-constant-inject-hook nil\n (progn))"}, {"role": "assistant", "content": "(defmacro with-constant-inject-hook (func &body body)\n (let ((func-name (gensym \"hook\")))\n `(let* ((,func-name ,func)\n (*constant-inject-hook* ,func-name))\n ,@body)))\n\n;; macroexpand:\n(let* ((#:|hook173| nil) (varjo.internals::*constant-inject-hook* #:|hook173|))\n (progn))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(inext nil)\n\nPattern to recognize: Macro call that should be transformed by INEXT\n\n(inext nil)"}, {"role": "assistant", "content": "(defmacro INEXT ...)\n\n;; macroexpand:\n(let ((vals (multiple-value-list (funcall (i-coro nil) nil))))\n (if (not vals)\n (coexit!)\n (car vals)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(to nil)\n\nProblem: Macro call that should be transformed by TO\n\n(to nil)"}, {"role": "assistant", "content": "(defmacro TO ...)\n\n;; macroexpand:\n(from 0 :to nil :by nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(defunit nil)\n\nPattern to recognize: Macro call that should be transformed by DEFUNIT\n\n(defunit nil)"}, {"role": "assistant", "content": "(defmacro defunit (name &optional docstring\n &environment env)\n \"Define a unit type.\n\nA unit type is a type with only one instance.\n\nYou can think of a unit type as a singleton without state.\n\nUnit types are useful for many of the same purposes as quoted symbols\n\\(or keywords) but, unlike a symbol, a unit type is tagged with its\nown individual type.\"\n (let ((ctor (symbolicate '%make- name))\n (super (env-super env '%unit)))\n `(progn\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (defstruct (,name\n (:include ,super)\n (:constructor ,ctor)\n (:copier nil)\n (:predicate nil)\n (:print-function print-unit))\n ,@(unsplice docstring)))\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (defmethod make-load-form ((x ,name) &optional env)\n (declare (ignore env))\n '(intern-unit ',name ',ctor)))\n (defmethod %constructor= ((x ,name) (y ,name))\n t)\n (defconst ,name (intern-unit ',name ',ctor))\n (declaim-freeze-type ,name)\n (fmakunbound ',ctor)\n ',name)))\n\n;; macroexpand:\n(progn\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (defstruct\n (nil (:include serapeum/defining-types::%unit) (:constructor %make-nil)\n (:copier nil) (:predicate nil)\n (:print-function serapeum/defining-types::print-unit))))\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (defmethod make-load-form\n ((serapeum/defining-types::x nil)\n &optional serapeum/defining-types::env)\n (declare (ignore serapeum/defining-types::env))\n '(serapeum/defining-types::intern-unit 'nil '%make-nil)))\n (defmethod serapeum/defining-types::%constructor=\n ((serapeum/defining-types::x nil) (serapeum/defining-types::y nil))\n t)\n (defconst nil (serapeum/defining-types::intern-unit 'nil '%make-nil))\n (declaim-freeze-type nil)\n (fmakunbound '%make-nil)\n 'nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(as->* nil nil)\n\nWhat needs to change: Macro call that should be transformed by AS->*\n\n(as->* nil nil)"}, {"role": "assistant", "content": "(defmacro AS->* ...)\n\n;; macroexpand:\n(as-> nil nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(ignorable common-lisp:nil)\n\nProblem: Macro call that should be transformed by IGNORABLE\n\n(ignorable common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro IGNORABLE ...)\n\n;; macroexpand:\n'(common-lisp:declare (common-lisp:ignorable))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(define-screamer-package nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-SCREAMER-PACKAGE\n\n(define-screamer-package nil\n nil)"}, {"role": "assistant", "content": "(defmacro define-screamer-package (defined-package-name &body options)\n \"Convenience wrapper around DEFPACKAGE. Passes its argument directly\nto DEFPACKAGE, and automatically injects two additional options:\n\n \\(:shadowing-import-from :screamer :defun :multiple-value-bind :y-or-n-p)\n \\(:use :cl :screamer)\"\n `(defpackage ,defined-package-name\n ,@options\n (:shadowing-import-from :screamer :defun :multiple-value-bind :y-or-n-p)\n (:use :cl :screamer)))\n\n;; macroexpand:\n(defpackage nil\n ()\n (:shadowing-import-from :screamer :defun :multiple-value-bind :y-or-n-p)\n (:use :cl :screamer))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(lret nil\n (progn))\n\nIssue: Macro call that should be transformed by LRET\n\n(lret nil\n (progn))"}, {"role": "assistant", "content": "(defmacro lret ((&rest bindings) &body body)\n \"Return the initial value of the last binding in BINDINGS. The idea\nis to create something, initialize it, and then return it.\n\n (lret ((x 1)\n (y (make-array 1)))\n (setf (aref y 0) x))\n => #(1)\n\nNote that the value returned is the value initially bound. Subsequent\nassignments are ignored.\n\n (lret ((x 1))\n (setf x 2))\n => 1\n\nFurthermore, on Lisps that support it, the variable may be made\nread-only, making assignment a compiler-time error.\n\n`lret' may seem trivial, but it fufills the highest purpose a macro\ncan: it eliminates a whole class of bugs (initializing an object, but\nforgetting to return it).\n\nCf. `aprog1' in Anaphora.\"\n `(lret-aux let ,bindings\n ,@body))\n\n;; macroexpand:\n(serapeum/binding::lret-aux let\n nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(pecase nil (progn))\n\nPattern to recognize: Macro call that should be transformed by PECASE\n\n(pecase nil (progn))"}, {"role": "assistant", "content": "(defmacro pecase (pred keyform &rest clauses)\n \"Like ECASE, but uses given PRED instead of EQL to select appropriate CLAUSE.\n\n Example usage:\n\n CL-USER> (pecase '< 1\n (0 (print \\\"Below zero\\\"))\n (2 (print \\\"OK\\\")))\n\"\n (expand-predicate-case pred keyform clauses 'ecase))\n\n;; macroexpand:\n(let ((#:keyform209 (progn)))\n (cond (t (error 'case-failure))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-active-layers* nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-ACTIVE-LAYERS*\n\n(with-active-layers* nil\n nil)"}, {"role": "assistant", "content": "(defmacro WITH-ACTIVE-LAYERS* ...)\n\n;; macroexpand:\n(progn nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(enable-quasiquote-2.0)\n\nProblem: Macro call that should be transformed by ENABLE-QUASIQUOTE-2.0\n\n(enable-quasiquote-2.0)"}, {"role": "assistant", "content": "(defmacro ENABLE-QUASIQUOTE-2.0 ...)\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute) (%enable-quasiquote-2.0))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(aif nil nil)\n\nProblem: Macro call that should be transformed by AIF\n\n(aif nil nil)"}, {"role": "assistant", "content": "(defmacro AIF ...)\n\n;; macroexpand:\n(let ((it nil))\n (if it\n nil\n nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(terminate)\n\nProblem: Macro call that should be transformed by TERMINATE\n\n(terminate)"}, {"role": "assistant", "content": "(defmacro terminate () ; recommended for use with FOR ... NEXT\n \"Use within FOR ... DO-/NEXT clause to end the iteration\"\n '(finish))\n\n;; macroexpand:\n(finish)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda-match\n 'some-name)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-MATCH\n\n(lambda-match\n 'some-name)"}, {"role": "assistant", "content": "(defmacro LAMBDA-MATCH ...)\n\n;; macroexpand:\n(lambda (#:arg150)\n (match #:arg150\n 'some-name))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(defobserver nil (progn))\n\nIssue: Macro call that should be transformed by DEFOBSERVER\n\n(defobserver nil (progn))"}, {"role": "assistant", "content": "(defmacro defobserver (slotname &rest args &aux (aroundp (eq :around (first args))))\n (when aroundp (setf args (cdr args)))\n\n #+irritating\n (when (find slotname '(value kids))\n (warn \"d: did you mean .value or .kids when you coded ~a?\" slotname))\n\n (destructuring-bind ((&optional (self-arg 'self) (new-varg 'new-value)\n (oldvarg 'old-value) (oldvargboundp 'old-value-boundp) (cell-arg 'c))\n &body output-body) args\n `(progn\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (get ',slotname :output-defined) t))\n ,(if (eql (last1 output-body) :test)\n (let ((temp1 (gensym))\n (loc-self (gensym)))\n `(defmethod slot-value-observe #-(or cormanlisp) ,(if aroundp :around 'progn)\n ((slotname (eql ',slotname)) ,self-arg ,new-varg ,oldvarg ,oldvargboundp ,cell-arg)\n (let ((,temp1 (bump-output-count ,slotname))\n (,loc-self ,(if (listp self-arg)\n (car self-arg)\n self-arg)))\n (when (and ,oldvargboundp ,oldvarg)\n (format t \"~&output ~d (~a ~a) old: ~a\" ,temp1 ',slotname ,loc-self ,oldvarg ,cell-arg))\n (format t \"~&output ~d (~a ~a) new: ~a\" ,temp1 ',slotname ,loc-self ,new-varg ,cell-arg))))\n `(defmethod slot-value-observe\n #-(or cormanlisp) ,(if aroundp :around 'progn)\n ((slotname (eql ',slotname)) ,self-arg ,new-varg ,oldvarg ,oldvargboundp ,cell-arg)\n (declare (ignorable\n ,@(flet ((arg-name (arg-spec)\n (etypecase arg-spec\n (list (car arg-spec))\n (atom arg-spec))))\n (list (arg-name self-arg)(arg-name new-varg)\n (arg-name oldvarg)(arg-name oldvargboundp) (arg-name cell-arg)))))\n ,@output-body)))))\n\n;; macroexpand:\n(progn\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (get 'nil :output-defined) t))\n (defmethod slot-value-observe progn\n ((slotname (eql 'nil)) progn new-value old-value old-value-boundp\n c)\n (declare (ignorable progn new-value old-value old-value-boundp c))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(group-by 'some-name)\n\nProblem: Macro call that should be transformed by GROUP-BY\n\n(group-by 'some-name)"}, {"role": "assistant", "content": "(defmacro group-by (&rest expressions)\n `(apply #'make-clause :group-by ',expressions))\n\n;; macroexpand:\n(apply #'make-clause :group-by '('some-name))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-destructured-lambda-form nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-DESTRUCTURED-LAMBDA-FORM\n\n(with-destructured-lambda-form nil\n (progn))"}, {"role": "assistant", "content": "(defmacro WITH-DESTRUCTURED-LAMBDA-FORM ...)\n\n;; macroexpand:\n(destructuring-bind\n (#:function128 #:name129 #:qualifiers130 #:lambda-list131 #:docstring132\n #:declarations133 #:forms134)\n (split-lambda-form (progn))\n (declare\n (ignore #:function128 #:name129 #:qualifiers130 #:lambda-list131\n #:docstring132 #:declarations133 #:forms134)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(the-part nil (progn))\n\nIssue: Macro call that should be transformed by THE-PART\n\n(the-part nil (progn))"}, {"role": "assistant", "content": "(defmacro THE-PART ...)\n\n;; macroexpand:\n(send part nil (progn))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(and-let* nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AND-LET*\n\n(and-let* nil)"}, {"role": "assistant", "content": "(defmacro and-let* ((&rest clauses) &body body &environment env)\n \"Scheme's guarded LET* (SRFI-2).\n\nEach clause should have one of the following forms:\n\n- `identifier', in which case IDENTIFIER's value is tested.\n\n- `(expression)', in which case the value of EXPRESSION is tested.\n\n- `(identifier expression)' in which case EXPRESSION is evaluated,\n and, if its value is not false, IDENTIFIER is bound to that value\n for the remainder of the clauses and the optional body.\n\nNote that, of course, the semantics are slightly different in Common\nLisp than in Scheme, because our AND short-circuits on null, not\nfalse.\n\nAlso, this version makes the bindings immutable.\"\n (multiple-value-bind (body decls)\n (parse-body body)\n (labels ((expand (clauses body)\n (unsplice\n (ematch clauses\n (() (if body `(progn ,@body) nil))\n ((list* (and var (type symbol)) clauses)\n `(and ,var ,@(expand clauses body)))\n ((list* (list var expr) clauses)\n (let ((temp (gensym (string var))))\n (multiple-value-bind (local-decls other-decls)\n (partition-declarations (list var) decls env)\n ;; The use of the temporary here is so we still\n ;; get style warnings if the variable is\n ;; unused.\n `(let* ((,temp ,expr)\n (,var ,temp))\n ,@local-decls\n (and ,temp\n ,@(expand clauses\n (append other-decls body)))))))\n ((list* (list expr) clauses)\n `(and ,expr ,@(expand clauses body)))))))\n (car (expand clauses body)))))\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-attributes nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-ATTRIBUTES\n\n(with-attributes nil\n (progn))"}, {"role": "assistant", "content": "(defmacro WITH-ATTRIBUTES ...)\n\n;; macroexpand:\n(let ((#:unit161 (progn)))\n (symbol-macrolet ()))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(optional common-lisp:nil (common-lisp:progn))\n\nProblem: Macro call that should be transformed by OPTIONAL\n\n(optional common-lisp:nil (common-lisp:progn))"}, {"role": "assistant", "content": "(defmacro OPTIONAL ...)\n\n;; macroexpand:\n'(common-lisp:progn :initform common-lisp:nil :initarg :progn)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with-yield\n nil)\n\nIssue: Macro call that should be transformed by WITH-YIELD\n\n(with-yield\n nil)"}, {"role": "assistant", "content": "(defmacro with-yield (&body body)\n (let ((point (gensym))\n (current (gensym)))\n `(let (,point ,current)\n (with-call/cc\n\t (labels ((yield (&rest values)\n\t\t (setf ,current values)\n\t\t (let/cc k\n\t\t (setf ,point k))))\n\t ,@body\n\t (setf ,point nil)))\n (gen-lambda ()\n\t (cond ((null ,point)\n\t\t'generator-stop)\n\t (t\n\t\t(let ((current ,current))\n\t\t (funcall ,point nil)\n\t\t ;values-handler: see gen-lambda\n\t\t (apply #'values (funcall values-handler current)))))))))\n\n;; macroexpand:\n(let (#:g128 #:g129)\n (with-call/cc\n (labels ((yield (&rest values)\n (setf #:g129 values)\n (let/cc k\n (setf #:g128 k))))\n nil\n (setf #:g128 nil)))\n (gen-lambda nil\n (cond ((null #:g128) 'generator-stop)\n (t\n (let ((current #:g129))\n (funcall #:g128 nil)\n (apply #'values (funcall values-handler current)))))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(ith-value nil :key nil)\n\nProblem: Macro call that should be transformed by ITH-VALUE\n\n(ith-value nil :key nil)"}, {"role": "assistant", "content": "(defmacro ITH-VALUE ...)\n\n;; macroexpand:\n(block ith-value\n (let ((#:i139 (value-of nil)))\n (for-effects\n (let ((value :key))\n (if (zerop #:i139)\n (return-from ith-value value)\n (decf #:i139))))\n nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(push nil (progn))\n\nProblem: Macro call that should be transformed by PUSH\n\n(push nil (progn))"}, {"role": "assistant", "content": "(defmacro PUSH ...)\n\n;; macroexpand:\n(let* ((#:new224 (cons nil (progn))))\n (funcall #'(setf progn) #:new224))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(nunionf nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by NUNIONF\n\n(nunionf nil :key nil)"}, {"role": "assistant", "content": "(defmacro NUNIONF ...)\n\n;; macroexpand:\n(setq nil (nunion nil :key nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(nearest nil (progn))\n\nPattern to recognize: Macro call that should be transformed by NEAREST\n\n(nearest nil (progn))"}, {"role": "assistant", "content": "(defmacro nearest (self-form type)\n (let ((self (gensym)))\n `(bwhen (,self ,self-form)\n (if (typep ,self ',type) ,self (upper ,self ,type)))))\n\n;; macroexpand:\n(bwhen (#:g158 nil)\n (if (typep #:g158 '(progn))\n #:g158\n (upper #:g158 (progn))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(ensure-get nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by ENSURE-GET\n\n(ensure-get nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro! ensure-get (o!key o!map &body (&optional default))\n `(multiple-value-bind (,g!value ,g!in-map?) (get ,g!key ,g!map)\n (if ,g!in-map?\n\t (values ,g!value t)\n\t (values\n\t (setf (get ,g!key ,g!map) ,default)\n\t nil))))\n\n;; macroexpand:\n(let ((#:key198 nil) (#:map199 :key))\n (multiple-value-bind (#:value197 #:in-map?196)\n (get #:key198 #:map199)\n (if #:in-map?196\n (values #:value197 t)\n (values (setf (get #:key198 #:map199) nil) nil))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(iter\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by ITER\n\n(iter\n nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro iter (&body body &environment env)\n \"Jonathan Amsterdam's powerful and extensible iteration facility,\nproviding multiple accumulation, generators, memory of previous\niterations, over 50 clauses to start with and a Lisp-like syntax.\nEvaluate (iter:display-iter-clauses) for an overview of clauses.\"\n (let* ((*env* env)\n (*result-var* (genvar 'result))\n (*type-alist* nil)\n (*declare-variables* *always-declare-variables*)\n (*bindings* nil)\n (*internal-variables* nil)\n (*previous-vars-alist* nil)\n (*declarations* nil)\n (*loop-body-wrappers* nil)\n (*accum-var-alist* nil)\n (*shared-bindings-alist* nil)\n (*top-level?* t)\n (*declaration-context?* nil)\n (*temps* nil)\n (*temps-in-use* nil)\n (*driver-info-alist* nil)\n (*block-name* (when (symbolp (car body))\n (pop body)))\n (*loop-top* (ensure-symbol *block-name* :format \"loop-top-~a\"))\n (*loop-step* (ensure-symbol *block-name* :format \"loop-step-~a\"))\n (*loop-end* (ensure-symbol *block-name* :format \"loop-end-~a\"))\n (*loop-step-used?* nil)\n (*loop-end-used?* nil))\n (process-top-level-decls body)\n (multiple-value-bind (body decls init-code steppers final-code final-prot)\n (walk-list body)\n (multiple-value-bind (init step)\n (insert-previous-code)\n (augment init-code init)\n (augment steppers step)\n (prepend (default-driver-code) body)\n (let ((it-bod `(block ,*block-name*\n (tagbody\n ,.init-code\n ,*loop-top*\n ,.body\n ,.(when *loop-step-used?* (list *loop-step*))\n ,.steppers\n (go ,*loop-top*)\n ,.(when *loop-end-used?* (list *loop-end*))\n ,.final-code)\n ,(if (member *result-var* *bindings* :key #'car)\n *result-var*\n nil))))\n (wrap-form *loop-body-wrappers*\n `(let* ,(nreverse *bindings*)\n ,.(if *declarations*\n `((declare .,*declarations*)))\n ,.decls\n ,(if final-prot\n `(unwind-protect ,it-bod .,final-prot)\n it-bod))))))))\n\n;; macroexpand:\n(let* ()\n (block nil (tagbody loop-top-nil :key nil (go loop-top-nil)) nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(defgeneric nil :key nil)\n\nProblem: Macro call that should be transformed by DEFGENERIC\n\n(defgeneric nil :key nil)"}, {"role": "assistant", "content": "(defmacro DEFGENERIC ...)\n\n;; macroexpand:\n(progn\n (walk-environment\n (closer-mop:defgeneric nil\n :key\n nil))\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (static-dispatch::add-compiler-macro 'nil)\n (static-dispatch::remove-defined-methods 'nil))\n (let ((#:gf187 (fdefinition 'nil)))\n (when (typep #:gf187 'generic-function)\n (setf (static-dispatch::combination-options 'nil) '(standard nil)))\n #:gf187))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(defmethod nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFMETHOD\n\n(defmethod nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro DEFMETHOD ...)\n\n;; macroexpand:\n(common-lisp:defmethod nil :key ())"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(do-external-symbols (quote some-name))\n\nProblem: Macro call that should be transformed by DO-EXTERNAL-SYMBOLS\n\n(do-external-symbols (quote some-name))"}, {"role": "assistant", "content": "(defmacro DO-EXTERNAL-SYMBOLS ...)\n\n;; macroexpand:\n(block nil\n (with-package-iterator\n (#:iterator182 (sb-int:find-undeleted-package-or-lose some-name)\n :external)\n (tagbody\n #:next184\n (multiple-value-bind (#:winp183 quote)\n (#:iterator182)\n (declare (ignorable quote))\n (if #:winp183\n (tagbody (go #:next184))\n (return nil))))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(subtest 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by SUBTEST\n\n(subtest 'some-name)"}, {"role": "assistant", "content": "(defmacro subtest (desc &body body)\n `(%subtest ,desc (lambda () ,@body)))\n\n;; macroexpand:\n(prove.test::%subtest 'some-name (lambda ()))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(decide 'some-name)\n\nPattern to recognize: Macro call that should be transformed by DECIDE\n\n(decide 'some-name)"}, {"role": "assistant", "content": "(defmacro DECIDE ...)\n\n;; macroexpand:\n(let ((#:argument-127 'some-name))\n (either\n (progn (assert!-true #:argument-127) t)\n (progn (assert!-false #:argument-127) nil)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(collect-min nil)\n\nPattern to recognize: Macro call that should be transformed by COLLECT-MIN\n\n(collect-min nil)"}, {"role": "assistant", "content": "(defmacro COLLECT-MIN ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-273 (generator nil))\n #:numbers-267\n (#:number-269 nil))\n (declare (type generator #:generator-273))\n (tagbody\n #:ll-274\n (setq #:numbers-267 (next-in #:generator-273 (go end)))\n (if (or (null #:number-269) (> #:number-269 #:numbers-267))\n (setq #:number-269 #:numbers-267))\n (go #:ll-274)\n end)\n (if (null #:number-269)\n (setq #:number-269 nil))\n #:number-269)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(ok? 'some-name)\n\nProblem: Macro call that should be transformed by OK?\n\n(ok? 'some-name)"}, {"role": "assistant", "content": "(defmacro ok? (x)\n \"Did parsing succeed?\"\n `(cl:not (failure? ,x)))\n\n;; macroexpand:\n(common-lisp:not (failure? 'some-name))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(ps-once-only 'some-name)\n\nProblem: Macro call that should be transformed by PS-ONCE-ONLY\n\n(ps-once-only 'some-name)"}, {"role": "assistant", "content": "(defmacro PS-ONCE-ONLY ...)\n\n;; macroexpand:\n(let* ((#:quote1 (ps-gensym 'quote)) (#:some-name2 (ps-gensym 'some-name)))\n `(let* (,(list #:quote1 quote) ,(list #:some-name2 some-name))\n ,(let* ((quote #:quote1) (some-name #:some-name2)))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(as->* nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AS->*\n\n(as->* nil :key nil)"}, {"role": "assistant", "content": "(defmacro AS->* ...)\n\n;; macroexpand:\n(as-> nil nil :key)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(reversef nil)\n\nWhat needs to change: Macro call that should be transformed by REVERSEF\n\n(reversef nil)"}, {"role": "assistant", "content": "(defmacro REVERSEF ...)\n\n;; macroexpand:\n(setq nil (reverse nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(unless-match common-lisp:nil\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by UNLESS-MATCH\n\n(unless-match common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro unless-match (pattern arg &body body)\n \"Equivalent to (match ARG (PATTERN) (_ BODY...)).\"\n `(match ,arg\n (,pattern)\n (_ ,.body)))\n\n;; macroexpand:\n(match common-lisp:nil\n (common-lisp:nil)\n (trivia.level2.impl::_))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(nand 'some-name)\n\nPattern to recognize: Macro call that should be transformed by NAND\n\n(nand 'some-name)"}, {"role": "assistant", "content": "(defmacro nand (&rest forms)\n \"Equivalent to (not (and ...)).\"\n (if (null forms) nil\n (if (null (rest forms))\n `(not ,(first forms))\n `(if ,(first forms)\n (nand ,@(rest forms))\n t))))\n\n;; macroexpand:\n(not 'some-name)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(some-<> nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SOME-<>\n\n(some-<> nil\n nil)"}, {"role": "assistant", "content": "(defmacro some-<> (init &body exps) (diamond-wand init exps nil t))\n\n;; macroexpand:\n(block #:g126 (nil (or nil (return-from #:g126 nil))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(select-dao nil)\n\nPattern to recognize: Macro call that should be transformed by SELECT-DAO\n\n(select-dao nil)"}, {"role": "assistant", "content": "(defmacro select-dao (class &body clauses)\n \"Build custom queries with SxQL.\n\nExample:\n\n (select-dao 'tweet\n (where (:like :status \\\"%Japan%\\\")))\n\nYou can use \\\"includes\\\" to eagerly load another table and prevent the \\\"N+1 query\\\" performance problem:\n\n (select-dao 'tweet\n (includes 'user)\n (where (:like :status \\\"%Japan%\\\")))\n\nYou can use \\\"joins\\\" to add JOIN clauses for filtering by related table columns.\nNote: \\\"joins\\\" does NOT automatically load foreign objects. Use \\\"includes\\\" if you need the ghost slots populated:\n\n ;; Filter by related table - ghost slot NOT populated\n (select-dao 'blog\n (joins 'user)\n (where (:= :user.status \\\"active\\\")))\n\n ;; Filter AND load foreign objects\n (select-dao 'blog\n (joins 'user)\n (includes 'user)\n (where (:= :user.status \\\"active\\\")))\n\nSee the SxQL documentation for the available clauses and operators.\"\n (with-gensyms (sql clause results include-classes foreign-class)\n (once-only (class)\n `(#+sb-package-locks locally #+sb-package-locks (declare (sb-ext:disable-package-locks sxql:where))\n #-sb-package-locks cl-package-locks:with-packages-unlocked #-sb-package-locks (sxql)\n (progn\n (setf ,class (ensure-class ,class))\n (let* ((sxql:*sql-symbol-conversion* #'unlispify)\n (,sql\n (sxql:select :*\n (sxql:from (sxql:make-sql-symbol (table-name ,class)))))\n (,include-classes '()))\n (macrolet ((where (expression)\n `(sxql:make-clause :where ,(expand-op expression ',class))))\n ;; ignore compiler-note when includes is not used\n #+sbcl (declare (sb-ext:muffle-conditions sb-ext:code-deletion-note))\n (flet ((includes (&rest classes)\n (appendf ,include-classes (mapcar #'ensure-class classes))\n nil)\n (joins (foreign-class &key (type :inner))\n (let ((foreign-class (ensure-class foreign-class)))\n (add-child ,sql\n (ecase type\n (:inner (sxql:inner-join\n (sxql:make-sql-symbol (table-name foreign-class))\n :on (make-join-condition ,class foreign-class)))\n (:left (sxql:left-join\n (sxql:make-sql-symbol (table-name foreign-class))\n :on (make-join-condition ,class foreign-class)))))\n nil)))\n (dolist (,clause (list ,@clauses))\n (when ,clause\n (add-child ,sql ,clause)))\n (let ((,results (select-by-sql ,class ,sql)))\n (unless *want-cursor*\n (dolist (,foreign-class (remove-duplicates ,include-classes))\n (include-foreign-objects ,foreign-class ,results)))\n (values ,results ,sql))))))))))\n\n;; macroexpand:\n(let ((#:class253 nil))\n (locally\n (declare (sb-ext:disable-package-locks sxql:where))\n (progn\n (setf #:class253 (mito.util:ensure-class #:class253))\n (let* ((sxql/operator:*sql-symbol-conversion* #'mito.util:unlispify)\n (#:sql248\n (sxql:select :*\n (sxql:from\n (sxql/sql-type:make-sql-symbol\n (mito.class.table:table-name #:class253)))))\n (#:include-classes251 'nil))\n (macrolet ((sxql:where (mito.dao::expression)\n `(sxql/clause:make-clause :where\n ,(mito.dao::expand-op\n mito.dao::expression\n '#:class253))))\n (declare (sb-ext:muffle-conditions sb-ext:code-deletion-note))\n (flet ((includes (&rest mito.dao::classes)\n (alexandria:appendf #:include-classes251\n (mapcar #'mito.util:ensure-class\n mito.dao::classes))\n nil)\n (joins (mito.dao::foreign-class &key (type :inner))\n (let ((mito.dao::foreign-class\n (mito.util:ensure-class mito.dao::foreign-class)))\n (sxql/statement:add-child #:sql248\n (ecase type\n (:inner\n (sxql:inner-join\n (sxql/sql-type:make-sql-symbol\n (mito.class.table:table-name\n mito.dao::foreign-class))\n :on\n (mito.dao::make-join-condition\n #:class253\n mito.dao::foreign-class)))\n (:left\n (sxql:left-join\n (sxql/sql-type:make-sql-symbol\n (mito.class.table:table-name\n mito.dao::foreign-class))\n :on\n (mito.dao::make-join-condition\n #:class253\n mito.dao::foreign-class)))))\n nil)))\n (dolist (#:clause249 (list))\n (when #:clause249 (sxql/statement:add-child #:sql248 #:clause249)))\n (let ((#:results250 (select-by-sql #:class253 #:sql248)))\n (unless mito.dao::*want-cursor*\n (dolist\n (#:foreign-class252 (remove-duplicates #:include-classes251))\n (include-foreign-objects #:foreign-class252 #:results250)))\n (values #:results250 #:sql248))))))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(with-constant-inject-hook nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-CONSTANT-INJECT-HOOK\n\n(with-constant-inject-hook nil)"}, {"role": "assistant", "content": "(defmacro with-constant-inject-hook (func &body body)\n (let ((func-name (gensym \"hook\")))\n `(let* ((,func-name ,func)\n (*constant-inject-hook* ,func-name))\n ,@body)))\n\n;; macroexpand:\n(let* ((#:|hook171| nil) (varjo.internals::*constant-inject-hook* #:|hook171|)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(fsetf nil (progn))\n\nIssue: Macro call that should be transformed by FSETF\n\n(fsetf nil (progn))"}, {"role": "assistant", "content": "(defmacro fsetf (place value &rest more)\n ;; First we need to find the \"container\" variable\n (let ((container (find-container place)))\n (with-gensyms (val-sym)\n (if more\n `(let ((,val-sym ,value))\n (setf ,container (modf ,place ,val-sym))\n (fsetf ,@more))\n `(let ((,val-sym ,value))\n (setf ,container (modf ,place ,val-sym))\n ,val-sym)))))\n\n;; macroexpand:\n(let ((#:val-sym123 (progn)))\n (setf nil (modf nil #:val-sym123))\n #:val-sym123)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(cll-outer 'some-name)\n\nPattern to recognize: Macro call that should be transformed by CLL-OUTER\n\n(cll-outer 'some-name)"}, {"role": "assistant", "content": "(defmacro cll-outer (val &body body)\n `(let ((outer-val ,val))\n ,@body))\n\n;; macroexpand:\n(let ((outer-val 'some-name)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defunwalker-handler nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFUNWALKER-HANDLER\n\n(defunwalker-handler nil\n (progn))"}, {"role": "assistant", "content": "(defmacro DEFUNWALKER-HANDLER ...)\n\n;; macroexpand:\n(progn\n (def layered-method unwalk-form ((-form- nil))\n (block nil\n (flet ((recurse (node)\n (unwalk-form node))\n (recurse-on-body (nodes)\n (mapcar #'unwalk-form nodes)))\n (declare (ignorable (function recurse) (function recurse-on-body)))\n (with-slots (progn)\n -form-))))\n 'nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(nunionf nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by NUNIONF\n\n(nunionf nil :key nil)"}, {"role": "assistant", "content": "(defmacro NUNIONF ...)\n\n;; macroexpand:\n(setq nil (nunion nil :key nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(print-values)\n\nIssue: Macro call that should be transformed by PRINT-VALUES\n\n(print-values)"}, {"role": "assistant", "content": "(defmacro PRINT-VALUES ...)\n\n;; macroexpand:\n(catch 'succeed\n (for-effects\n (let ((value (progn)))\n (print value)\n (unless (y-or-n-p \"Do you want another solution?\")\n (throw 'succeed value)))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(fm-other?! 'some-name)\n\nProblem: Macro call that should be transformed by FM-OTHER?!\n\n(fm-other?! 'some-name)"}, {"role": "assistant", "content": "(defmacro fm-other?! (md-name &optional (starting 'self))\n `(fm-find-one ,starting ,(if (consp md-name)\n `(list ',(car md-name) ,(cadr md-name))\n `',md-name)\n :must-find nil\n :global-search nil))\n\n;; macroexpand:\n(fm-find-one self (list 'quote some-name) :must-find nil :global-search nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(ok? nil)\n\nWrite a macro that addresses: Macro call that should be transformed by OK?\n\n(ok? nil)"}, {"role": "assistant", "content": "(defmacro ok? (x)\n \"Did parsing succeed?\"\n `(cl:not (failure? ,x)))\n\n;; macroexpand:\n(common-lisp:not (failure? nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(execute nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by EXECUTE\n\n(execute nil :key nil)"}, {"role": "assistant", "content": "(defmacro execute (query &rest args)\n \"Execute a query, ignore the results. So, in effect, like a query called with\nformat :none. Returns the amount of affected rows as its first returned\nvalue. (Also returns this amount as the second returned value, but use of this\nis deprecated.)\"\n `(let ((rows (nth-value 1 (query ,query ,@args :none))))\n (if rows (values rows rows) 0)))\n\n;; macroexpand:\n(let ((rows (nth-value 1 (query nil :key nil :none))))\n (if rows\n (values rows rows)\n 0))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(lambda-match\n 'some-name)\n\nIssue: Macro call that should be transformed by LAMBDA-MATCH\n\n(lambda-match\n 'some-name)"}, {"role": "assistant", "content": "(defmacro lambda-match (&body body)\n \"Equivalent to (lambda (arg) (match arg BODY...)).\"\n (multiple-value-bind (preamble clauses) (parse-matcher-body body)\n (with-gensyms (clause)\n `(lambda (,clause)\n ,@preamble\n (match ,clause\n ,@clauses)))))\n\n;; macroexpand:\n(common-lisp:lambda (#:clause179)\n (match #:clause179\n 'some-name))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(make-name-transformer nil nil)\n\nProblem: Macro call that should be transformed by MAKE-NAME-TRANSFORMER\n\n(make-name-transformer nil nil)"}, {"role": "assistant", "content": "(defmacro make-name-transformer (&rest elements)\n \"Return an accessor name transformer.\nThe unquoted `name' symbol argument is substituted for the slot name.\nClass option examples:\n\n :accessor-name-transformer (make-name-transformer \\\"FOO-\\\" name \\\"-BAR\\\")\n\nUse the slot name directly:\n\n :accessor-name-transformer (make-name-transformer name)\"\n `(lambda (name definition)\n (declare (ignorable definition))\n (concatenate-symbol ,@(mapcar (lambda (el)\n (if (and (symbolp el)\n (string= (symbol-name el) \"NAME\"))\n 'name\n el))\n elements))))\n\n;; macroexpand:\n(lambda (name definition)\n (declare (ignorable definition))\n (concatenate-symbol nil nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(define-parse-method nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFINE-PARSE-METHOD\n\n(define-parse-method nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro define-parse-method (name lambda-list &body body)\n \"Define a type parser on NAME and lists whose CAR is NAME.\"\n (discard-docstring body)\n (warn-if-kw-or-belongs-to-cl name)\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (find-type-parser ',name)\n (lambda ,lambda-list ,@body))\n ',name))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (find-type-parser 'nil) (lambda :key nil))\n 'nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(right nil (progn))\n\nPattern to recognize: Macro call that should be transformed by RIGHT\n\n(right nil (progn))"}, {"role": "assistant", "content": "(defmacro right (parser &rest parsers)\n \"Combination of parsers yielding the result of the rightmost one.\"\n `(*> ,parser ,@parsers))\n\n;; macroexpand:\n(*> nil (progn))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(auto-permute-typecase nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by AUTO-PERMUTE-TYPECASE\n\n(auto-permute-typecase nil\n (progn))"}, {"role": "assistant", "content": "(defmacro AUTO-PERMUTE-TYPECASE ...)\n\n;; macroexpand:\n(typecase nil (progn))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(for-effects\n 'some-name)\n\nWhat needs to change: Macro call that should be transformed by FOR-EFFECTS\n\n(for-effects\n 'some-name)"}, {"role": "assistant", "content": "(defmacro FOR-EFFECTS ...)\n\n;; macroexpand:\n(choice-point (progn 'some-name (fail)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(html5 nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by HTML5\n\n(html5 nil :key nil)"}, {"role": "assistant", "content": "(defmacro html5 (&rest tags)\n `(with-doctype :html5\n (tag->string (cons :html ',tags))))\n\n;; macroexpand:\n(with-doctype :html5\n (tag->string (cons :html '(nil :key nil))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(returning 'some-name)\n\nIssue: Macro call that should be transformed by RETURNING\n\n(returning 'some-name)"}, {"role": "assistant", "content": "(defmacro RETURNING ...)\n\n;; macroexpand:\n(#S(result :form 'some-name))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with-decoder-simple-list-semantics\n 'some-name)\n\nIssue: Macro call that should be transformed by WITH-DECODER-SIMPLE-LIST-SEMANTICS\n\n(with-decoder-simple-list-semantics\n 'some-name)"}, {"role": "assistant", "content": "(defmacro with-decoder-simple-list-semantics (&body body)\n \"Execute BODY in a dynamic environement where the decoder semantics\nis such as set by SET-DECODER-SIMPLE-LIST-SEMANTICS.\"\n `(with-shadowed-custom-vars\n (set-decoder-simple-list-semantics)\n ,@body))\n\n;; macroexpand:\n(with-shadowed-custom-vars\n (set-decoder-simple-list-semantics)\n 'some-name)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-string-dispatch nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-STRING-DISPATCH\n\n(with-string-dispatch nil\n (progn))"}, {"role": "assistant", "content": "(defmacro with-string-dispatch ((&rest types) var &body body)\n \"Like `with-subtype-dispatch' with an overall type of `string'.\"\n `(with-subtype-dispatch string\n ;; Always specialize for (simple-array character (*)).\n ((simple-array character (*))\n (simple-array base-char (*))\n ,@types)\n ,var\n ,@body))\n\n;; macroexpand:\n(with-subtype-dispatch string\n ((simple-array character (*)) (simple-array base-char (*)))\n (progn))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(defwalker-handler nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFWALKER-HANDLER\n\n(defwalker-handler nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro DEFWALKER-HANDLER ...)\n\n;; macroexpand:\n(progn\n (define-layered-method walk-form/compound\n ((-name- (eql 'nil)) -form- -parent- -environment-)\n (declare (ignorable -parent- -environment-))\n (with-walker-handler-lexical-environment\n :key\n nil))\n 'nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(shift-decf nil nil)\n\nProblem: Macro call that should be transformed by SHIFT-DECF\n\n(shift-decf nil nil)"}, {"role": "assistant", "content": "(defmacro SHIFT-DECF ...)\n\n;; macroexpand:\n(let* ((#:temp325 nil) (#:new324 (- #:temp325 nil)))\n (setq nil #:new324)\n #:temp325)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(dreletf* nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DRELETF*\n\n(dreletf* nil\n nil)"}, {"role": "assistant", "content": "(defmacro DRELETF* ...)\n\n;; macroexpand:\n(progn nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(enable-dot-syntax)\n\nPattern to recognize: Macro call that should be transformed by ENABLE-DOT-SYNTAX\n\n(enable-dot-syntax)"}, {"role": "assistant", "content": "(defmacro enable-dot-syntax ()\n \"Enable reader syntax.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (%enable-dot-syntax)))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute) (%enable-dot-syntax))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(boolean-if nil nil)\n\nWhat needs to change: Macro call that should be transformed by BOOLEAN-IF\n\n(boolean-if nil nil)"}, {"role": "assistant", "content": "(defmacro boolean-if (branch then &optional else &environment env)\n \"Chooses between the forms to include based on whether a macroexpand-time\nbranch is true. The first argument must be a symbol naming a branch in the\nlexically enclosing WITH-BOOLEAN form.\n\\\nIt is an error to use this macro outside the lexical environment established by\nWITH-BOOLEAN.\"\n (cond (*boolean-bypass*\n `(if ,branch ,then ,else))\n ((not (member branch (macroexpand-1 '%all-branches% env)))\n (missing-branch branch))\n ((not (macroexpand-1 '%in-branching% env))\n (conditional-error 'if))\n ((member branch (macroexpand-1 '%true-branches% env))\n then)\n (t (or else `(progn)))))\n\n;; macroexpand:\n(simple-program-error\n \"The macroexpand-time branch ~S was not defined in any encloding\n WITH-BOOLEAN form.\"\n 'nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(cond-> nil)\n\nPattern to recognize: Macro call that should be transformed by COND->\n\n(cond-> nil)"}, {"role": "assistant", "content": "(defmacro COND-> ...)\n\n;; macroexpand:\n(let* ((#:|cond130| nil))\n #:|cond130|)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(define-class-method nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-CLASS-METHOD\n\n(define-class-method nil\n nil)"}, {"role": "assistant", "content": "(defmacro DEFINE-CLASS-METHOD ...)\n\n;; macroexpand:\n(progn\n (define-incongruent-method nil\n nil)\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (add-class-principal-method 'nil 'nil)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(do-iter-values nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DO-ITER-VALUES\n\n(do-iter-values nil\n (progn))"}, {"role": "assistant", "content": "(defmacro do-iter-values ((&rest iters) &body forms)\n \"Iterate over the remaining elements of a sequence pointed to by static iterators.\n\n Evaluate FORMS at each iteration, for each remaining element, until\n one of the iterators reaches the end of the sequence.\n\n NOTE: May only be used inside a WITH-ITERATORS form.\n\n ITERS:\n\n List of bindings. Each element is of the form (PATTERN ITER),\n interpreted as if to WITH-ITER-VALUE, where PATTERN is a binding\n pattern, for the binding to the sequence element value, and ITER\n is a static iterator identifier symbol, introduced in a parent\n WITH-ITERATORS form.\n\n FORMS\n\n List of forms evaluated for each remaining element in the\n sequences pointed to by the static iterators.\n\n At each evaluation the next element of each sequence, pointed by\n each ITER in ITERS, is bound to the variable(s) specified by the\n corresponding PATTERN. After which the iterators are advanced to\n the next elements.\n\n If one of the iterators has reached the end of its sequence, a\n non-local jump outside the enclosing WITH-ITERATORS form is\n performed, i.e. any forms following this form, within the enclosing\n WITH-ITERATORS form, will not be evaluated.\"\n\n (with-gensyms (start)\n `(tagbody\n ,start\n (with-iter-values ,iters ,@forms)\n (go ,start))))\n\n;; macroexpand:\n(tagbody\n #:start213\n (with-iter-values nil\n (progn))\n (go #:start213))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(sif nil nil)\n\nIssue: Macro call that should be transformed by SIF\n\n(sif nil nil)"}, {"role": "assistant", "content": "(defmacro sif (test then &optional else)\n \"Like IF, except binds the test form to IT (via SYMBOL-MACROLET) for\nthe scope of the then and else expressions. IT can be set with SETF\"\n `(symbolic if ,test ,then ,else))\n\n;; macroexpand:\n(symbolic if nil nil nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(if-it nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by IF-IT\n\n(if-it nil :key nil)"}, {"role": "assistant", "content": "(defmacro if-it (test then &optional else)\n \"Like IF. IT is bound to TEST.\"\n `(let ((it ,test))\n (if it ,then ,else)))\n\n;; macroexpand:\n(let ((it nil))\n (if it\n :key\n nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(defmacro-driver 'some-name)\n\nIssue: Macro call that should be transformed by DEFMACRO-DRIVER\n\n(defmacro-driver 'some-name)"}, {"role": "assistant", "content": "(defmacro defmacro-driver (clause-template &body body)\n \"Create iterators which may also be used as generators\"\n (define-clause 'defmacro clause-template body t))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (defmacro clause-quote-1 (&key ((:quote some-name)) generate))\n (install-clause-info '(quote) '(quote) 'clause-quote-1 nil t)\n ''some-name)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(isnt-values 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ISNT-VALUES\n\n(isnt-values 'some-name)"}, {"role": "assistant", "content": "(defmacro isnt-values (form &body body)\n (multiple-value-bind (comp-expected expected comparison description format-args)\n (destructure-is-values-body body)\n `(eval-in-context\n *context*\n (make-instance 'multiple-value-comparison-result\n :expression '(isnt-values ,form ,@comp-expected)\n :value-form ',form\n :body (lambda () ,form)\n :expected (list ,@expected)\n :comparison (list ,@comparison)\n :comparison-geq NIL\n ,@(when description\n `(:description (format NIL ,description ,@format-args)))))))\n\n;; macroexpand:\n(eval-in-context *context*\n (make-instance 'multiple-value-comparison-result :expression\n '(isnt-values 'some-name) :value-form\n ''some-name :body (lambda () 'some-name)\n :expected (list) :comparison (list)\n :comparison-geq nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(ecase-using nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by ECASE-USING\n\n(ecase-using nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro ecase-using (pred keyform &body clauses)\n \"Exhaustive variant of `case-using'.\"\n (once-only (keyform)\n `(case-using ,pred ,keyform\n ,@clauses\n (otherwise\n (error \"~s fell through ~a with ~s\"\n ,keyform\n 'ecase-using\n ',pred)))))\n\n;; macroexpand:\n(let ((#:keyform359 :key))\n (case-using nil\n #:keyform359\n nil\n (otherwise\n (error \"~s fell through ~a with ~s\" #:keyform359 'ecase-using 'nil))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-last nil (progn))\n\nWhat needs to change: Macro call that should be transformed by COLLECT-LAST\n\n(collect-last nil (progn))"}, {"role": "assistant", "content": "(defmacro COLLECT-LAST ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-525 (generator nil))\n #:items-519\n (#:item-521 (progn)))\n (declare (type generator #:generator-525)\n (type (null-or t) #:item-521))\n (tagbody\n #:ll-526\n (setq #:items-519 (next-in #:generator-525 (go end)))\n (setq #:item-521 #:items-519)\n (go #:ll-526)\n end)\n #:item-521)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(do-each 'some-name)\n\nPattern to recognize: Macro call that should be transformed by DO-EACH\n\n(do-each 'some-name)"}, {"role": "assistant", "content": "(defmacro do-each ((var seq &optional return) &body body &environment env)\n \"Iterate over the elements of SEQ, a sequence.\nIf SEQ is a list, this is equivalent to `dolist'.\"\n (unless (speed-matters? env)\n (return-from do-each\n `(do-each/map (,var ,seq ,@(unsplice return))\n ,@body)))\n ;; We hoist the body and use sb-ext:muffle-conditions to prevent\n ;; SBCL from spamming us with code deletion notes. (It may also be\n ;; desirable in itself to avoid needless code duplication in Lisps\n ;; without type inference.)\n (with-thunk ((body :name do-each) var)\n (let ((iter-spec `(,var ,seq ,@(unsplice return))))\n `(locally (declare #+sbcl (sb-ext:muffle-conditions sb-ext:code-deletion-note))\n #+(or sbcl abcl)\n (sequence:dosequence ,iter-spec\n (,body ,var))\n #-(or sbcl abcl)\n (%do-each ,iter-spec\n (,body ,var))))))\n\n;; macroexpand:\n(flet ((#:stack-fn-do-each2 (quote)\n ))\n (declare (dynamic-extent (function #:stack-fn-do-each2)))\n (symbol-macrolet ((#:stack-fn-do-each2 #'#:stack-fn-do-each2))\n (locally\n (declare (sb-ext:muffle-conditions sb-ext:code-deletion-note))\n (sb-sequence:dosequence 'some-name\n (#:stack-fn-do-each2 quote)))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(insert-into nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by INSERT-INTO\n\n(insert-into nil\n nil)"}, {"role": "assistant", "content": "(defmacro insert-into (table &body clauses)\n `(make-statement :insert-into\n ,(expand-expression table)\n ,@(if (and (listp (car clauses))\n (keywordp (caar clauses)))\n `(',(car clauses) ,@(cdr clauses))\n clauses)))\n\n;; macroexpand:\n(make-statement :insert-into nil nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(bind nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by BIND\n\n(bind nil\n (progn))"}, {"role": "assistant", "content": "(defmacro bind ((&rest bindings) &body body)\n \"Bind variables from BINDINGS to be active inside BODY, as if by LET*,\ncombined with MULTIPLE-VALUE-BIND, DESTRUCTURING-BIND and other -bind forms,\ndepending on the type of the first argument.\"\n (let ((rez body))\n (dolist (binding (reverse bindings))\n (setf rez `((,@(funcall #'expand-binding binding rez)))))\n (first rez)))\n\n;; macroexpand:\n(progn)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(export-slots)\n\nWhat needs to change: Macro call that should be transformed by EXPORT-SLOTS\n\n(export-slots)"}, {"role": "assistant", "content": "(defmacro EXPORT-SLOTS ...)\n\n;; macroexpand:\ncommon-lisp:nil"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with* 'some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH*\n\n(with* 'some-name)"}, {"role": "assistant", "content": "(defmacro WITH* ...)\n\n;; macroexpand:\n(multiple-value-bind (quote) nil (multiple-value-bind (some-name) nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(push-end-new nil nil)\n\nIssue: Macro call that should be transformed by PUSH-END-NEW\n\n(push-end-new nil nil)"}, {"role": "assistant", "content": "(defmacro push-end-new (item place\n &rest kwargs\n &key key test test-not\n &environment env)\n \"Pushes ITEM to the end of place (like `push-end') but only if it not already a member of PLACE (like `pushnew').\n\nFor the use of KEY, TEST, and TEST-NOT, see `pushnew'.\"\n (declare (ignore key test test-not))\n (once-only (item)\n (multiple-value-bind (dummies vals temps setter getter)\n (get-setf-expansion place env)\n (when (rest temps) (error \"Invalid place for push-end\"))\n (let ((temp (car temps)))\n `(let* (,@(mapcar #'list dummies vals)\n (,temp ,getter))\n (unless (member ,item ,temp ,@kwargs)\n (setf ,temp (nconc1 ,temp ,item)))\n ,setter)))))\n\n;; macroexpand:\n(let ((#:item277 nil))\n (let* ((#:new278 nil))\n (unless (member #:item277 #:new278)\n (setf #:new278 (nconc1 #:new278 #:item277)))\n (setq nil #:new278)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(cll-inner nil)\n\nProblem: Macro call that should be transformed by CLL-INNER\n\n(cll-inner nil)"}, {"role": "assistant", "content": "(defmacro cll-inner (expr)\n `(,expr outer-val))\n\n;; macroexpand:\n(nil outer-val)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-unique-names nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-UNIQUE-NAMES\n\n(with-unique-names nil\n (progn))"}, {"role": "assistant", "content": "(defmacro WITH-UNIQUE-NAMES ...)\n\n;; macroexpand:\n(let ()\n (progn))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-integrity nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-INTEGRITY\n\n(with-integrity nil :key nil)"}, {"role": "assistant", "content": "(defmacro with-integrity ((&optional opcode defer-info debug) &rest body)\n (declare (ignorable debug))\n (when opcode\n (assert (find opcode *ufb-opcodes*) ()\n \"Invalid opcode for with-integrity: ~a. Allowed values: ~a\" opcode *ufb-opcodes*))\n `(call-with-integrity ,opcode ,defer-info\n (lambda (opcode defer-info)\n (declare (ignorable opcode defer-info))\n ;;; ,(when debug\n ;;; `(trc \"integrity action entry\" opcode defer-info ',body))\n ;;; (when *c-debug*\n ;;; (when (eq opcode :change)\n ;;; (trc \"-------w/integ :change go--------------->:\" defer-info)))\n ,@body)\n nil\n #+noway (when *c-debug* ',body)))\n\n;; macroexpand:\n(call-with-integrity nil nil\n (lambda (opcode defer-info)\n (declare (ignorable opcode defer-info))\n :key\n nil)\n nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(without-c-dependency\n 'some-name)\n\nPattern to recognize: Macro call that should be transformed by WITHOUT-C-DEPENDENCY\n\n(without-c-dependency\n 'some-name)"}, {"role": "assistant", "content": "(defmacro without-c-dependency (&body body)\n ` (let (*depender*)\n ,@body))\n\n;; macroexpand:\n(let (*depender*)\n 'some-name)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(select-dao nil)\n\nProblem: Macro call that should be transformed by SELECT-DAO\n\n(select-dao nil)"}, {"role": "assistant", "content": "(defmacro select-dao (type &optional (test t) &rest ordering)\n \"Select DAO objects for the rows in the associated table for which the given\ntest (either an S-SQL expression or a string) holds. When sorting arguments\nare given, which can also be S-SQL forms or strings, these are used to sort\nthe result.\n\n(Note that, if you want to sort, you have to pass the test argument.)\n\n (select-dao 'user (:> 'score 10000) 'name)\"\n\n `(query-dao% ,type (sql ,(generate-dao-query type test ordering))\n (dao-row-reader (find-class ,type))))\n\n;; macroexpand:\n(query-dao% nil\n (sql (:select '* :from (dao-table-name (find-class nil)) :where t))\n (dao-row-reader (find-class nil)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(returning nil nil)\n\nProblem: Macro call that should be transformed by RETURNING\n\n(returning nil nil)"}, {"role": "assistant", "content": "(defmacro RETURNING ...)\n\n;; macroexpand:\n(#S(result :form nil) #S(result :form nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(product-of nil\n (progn))\n\nProblem: Macro call that should be transformed by PRODUCT-OF\n\n(product-of nil\n (progn))"}, {"role": "assistant", "content": "(defmacro PRODUCT-OF ...)\n\n;; macroexpand:\n(lc (nil (progn)) multiply)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(eval-when-execute\n common-lisp:nil\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EVAL-WHEN-EXECUTE\n\n(eval-when-execute\n common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro EVAL-WHEN-EXECUTE ...)\n\n;; macroexpand:\n(common-lisp:eval-when (:execute) common-lisp:nil common-lisp:nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(letmatch nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by LETMATCH\n\n(letmatch nil\n nil)"}, {"role": "assistant", "content": "(defmacro LETMATCH ...)\n\n;; macroexpand:\n(ifmatch (nil nil nil (error \"LETMATCH: mismatch.\")))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(mapping nil)\n\nProblem: Macro call that should be transformed by MAPPING\n\n(mapping nil)"}, {"role": "assistant", "content": "(defmacro MAPPING ...)\n\n;; macroexpand:\n(mapping-mac nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(fm-other?! nil (progn))\n\nIssue: Macro call that should be transformed by FM-OTHER?!\n\n(fm-other?! nil (progn))"}, {"role": "assistant", "content": "(defmacro fm-other?! (md-name &optional (starting 'self))\n `(fm-find-one ,starting ,(if (consp md-name)\n `(list ',(car md-name) ,(cadr md-name))\n `',md-name)\n :must-find nil\n :global-search nil))\n\n;; macroexpand:\n(fm-find-one (progn) 'nil :must-find nil :global-search nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(econd nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by ECOND\n\n(econd nil (progn))"}, {"role": "assistant", "content": "(defmacro econd (&rest clauses)\n \"Like `cond', but signal an error of type `econd-failure' if no\nclause succeeds.\"\n (let ((test-count (length clauses)))\n `(cond ,@clauses\n ;; SBCL will silently eliminate this branch if it is\n ;; unreachable.\n (t (error 'econd-failure :test-count ',test-count)))))\n\n;; macroexpand:\n(cond nil (progn) (t (error 'econd-failure :test-count '2)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(rte-case 'some-name)\n\nProblem: Macro call that should be transformed by RTE-CASE\n\n(rte-case 'some-name)"}, {"role": "assistant", "content": "(defmacro RTE-CASE ...)\n\n;; macroexpand:\n(let ((#:rte170 'some-name))\n (typecase #:rte170\n ((not sequence) nil)\n (t\n (funcall\n (lambda (#:rte170)\n (declare (optimize (speed 3) (debug 0) (safety 0)))\n (block check\n (typecase #:rte170\n (list nil)\n (simple-vector\n (let ((i 0) (len (length #:rte170)))\n (declare (type (and unsigned-byte fixnum) i len)\n (ignorable len))\n nil))\n (vector\n (let ((i 0) (len (length #:rte170)))\n (declare (type (and fixnum unsigned-byte) i len)\n (ignorable len))\n nil))\n (sequence\n (let ((i 0) (len (sb-sequence:length #:rte170)))\n (declare (type (and fixnum unsigned-byte) i len)\n (ignorable len))\n nil))\n (t nil))))\n #:rte170))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(step nil)\n\nWrite a macro that addresses: Macro call that should be transformed by STEP\n\n(step nil)"}, {"role": "assistant", "content": "(defmacro STEP ...)\n\n;; macroexpand:\n(locally\n (declare (optimize debug (sb-c:insert-step-conditions 0)))\n (let ((sb-impl::*step-out* :maybe))\n (unwind-protect\n (sb-impl::with-stepping-enabled\n (multiple-value-prog1\n (locally (declare (optimize (sb-c:insert-step-conditions 3))) nil)\n (sb-impl::step-finished))))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(raw nil :key nil)\n\nProblem: Macro call that should be transformed by RAW\n\n(raw nil :key nil)"}, {"role": "assistant", "content": "(defmacro raw (&rest forms)\n `(list ,@forms))\n\n;; macroexpand:\n(list nil :key nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(def-c-unchanged-test 'some-name)\n\nProblem: Macro call that should be transformed by DEF-C-UNCHANGED-TEST\n\n(def-c-unchanged-test 'some-name)"}, {"role": "assistant", "content": "(defmacro def-c-unchanged-test ((class slotname) &body test)\n `(defmethod c-unchanged-test ((self ,class) (slotname (eql ',slotname)))\n ,@test))\n\n;; macroexpand:\n(defmethod c-unchanged-test ((self quote) (slotname (eql 'some-name))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with 'some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH\n\n(with 'some-name)"}, {"role": "assistant", "content": "(defmacro WITH ...)\n\n;; macroexpand:\n(#S(binding :var quote :default some-name :default-provided? t))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(ignore-errors nil nil)\n\nIssue: Macro call that should be transformed by IGNORE-ERRORS\n\n(ignore-errors nil nil)"}, {"role": "assistant", "content": "(defmacro IGNORE-ERRORS ...)\n\n;; macroexpand:\n(handler-case (progn nil nil) (error (condition) (values nil condition)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(having 'some-name)\n\nWhat needs to change: Macro call that should be transformed by HAVING\n\n(having 'some-name)"}, {"role": "assistant", "content": "(defmacro having (expression)\n `(make-clause :having\n ,(if (and (listp expression)\n (keywordp (car expression)))\n (expand-op expression)\n `,expression)))\n\n;; macroexpand:\n(make-clause :having 'some-name)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(accase 'some-name)\n\nIssue: Macro call that should be transformed by ACCASE\n\n(accase 'some-name)"}, {"role": "assistant", "content": "(defmacro accase (keyform &body cases)\n \"Like CCASE, except binds the result of the keyform to IT (via LET) for the\nscope of the cases. Unlike CCASE, the keyform/place doesn't receive new values\npossibly stored with STORE-VALUE restart; the new value is received by IT.\"\n `(anaphoric ccase ,keyform ,@cases))\n\n;; macroexpand:\n(anaphoric ccase\n 'some-name)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(fdec nil (progn))\n\nProblem: Macro call that should be transformed by FDEC\n\n(fdec nil (progn))"}, {"role": "assistant", "content": "(defmacro fdec (place &optional (delta 1))\n \"DEPRECATED: use `shift-decf' instead.\"\n (simple-style-warning \"~s is deprecated, use ~s instead\"\n 'finc 'shift-incf)\n `(shift-decf ,place ,delta))\n\n;; macroexpand:\n(shift-decf nil (progn))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(-> nil nil)\n\nIssue: Macro call that should be transformed by ->\n\n(-> nil nil)"}, {"role": "assistant", "content": "(defmacro -> ...)\n\n;; macroexpand:\n(nil nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(ensure-transaction-with-isolation-level nil)\n\nWhat needs to change: Macro call that should be transformed by ENSURE-TRANSACTION-WITH-ISOLATION-LEVEL\n\n(ensure-transaction-with-isolation-level nil)"}, {"role": "assistant", "content": "(defmacro ensure-transaction-with-isolation-level (isolation-level &body body)\n \"Executes body within a with-transaction form if and only if no transaction is\nalready in progress. This adds the ability to specify an isolation level other\nthan the current default\"\n `(call-with-ensured-transaction (lambda () ,@body) ,isolation-level))\n\n;; macroexpand:\n(call-with-ensured-transaction (lambda ()) nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(printing-unreadably nil nil)\n\nWhat needs to change: Macro call that should be transformed by PRINTING-UNREADABLY\n\n(printing-unreadably nil nil)"}, {"role": "assistant", "content": "(defmacro printing-unreadably (fields-list class-std-form\n &key (type t) (identity t))\n \"Automatically generates the unreadable printing boiler plate to print classes and its fields (from FIELDS-LIST).\"\n (let ((g!stream (gensym \"STREAM\"))\n (name (cadr class-std-form)))\n `(progn ,class-std-form\n (defmethod print-object ((,name ,name) ,g!stream)\n (print-unreadable-object (,name ,g!stream\n :type ,type\n :identity ,identity)\n (format ,g!stream\n ,(format nil \"~{~a: ~~s~^,~^ ~}\" fields-list)\n ,@(mapcar (lambda (a1)\n `(,a1 ,name))\n fields-list)))))))\n\n;; macroexpand:\n(progn\n nil\n (defmethod print-object ((nil nil) #:stream125)\n (print-unreadable-object (nil #:stream125 :type t :identity t)\n (format #:stream125 #A((0) base-char . \"\")))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(dynamic-relet nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DYNAMIC-RELET\n\n(dynamic-relet nil)"}, {"role": "assistant", "content": "(defmacro DYNAMIC-RELET ...)\n\n;; macroexpand:\n(dynamic-wind\n :proceed\n #:proceed188\n (let ()\n (declare (special))\n (#:proceed188)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(yield-all 'some-name)\n\nWhat needs to change: Macro call that should be transformed by YIELD-ALL\n\n(yield-all 'some-name)"}, {"role": "assistant", "content": "(defmacro yield-all (generator)\n \"Walks through generator, re-yielding all of the items in it. Only meant for use inside of a defgenerator or with-yield block.\"\n (let ((x (gensym)))\n `(do-generator (,x ,generator)\n (yield ,x))))\n\n;; macroexpand:\n(do-generator (#:g139 'some-name)\n (yield #:g139))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(fgather-next nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FGATHER-NEXT\n\n(fgather-next nil nil)"}, {"role": "assistant", "content": "(defmacro FGATHER-NEXT ...)\n\n;; macroexpand:\n(nil nil nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(undefmessage 'some-name)\n\nWhat needs to change: Macro call that should be transformed by UNDEFMESSAGE\n\n(undefmessage 'some-name)"}, {"role": "assistant", "content": "(defmacro UNDEFMESSAGE ...)\n\n;; macroexpand:\n(fmakunbound ''some-name)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defdata nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFDATA\n\n(defdata nil\n nil)"}, {"role": "assistant", "content": "(defmacro defdata (adt-name &body constructors)\n \"Define a new ADT. ADT-name has the following grammar:\n\nADT-NAME := \n | ( *)\n\nThere is no difference between specifying it as a symbol or as a\nsingleton list. There are two possible options, specified as a\nproperty list:\n\n * :MUTABLE {T, NIL} (default: NIL): Specifies whether the fields\n of the type are mutable, allowing the use of SET-DATA.\n\n * :INCLUDE : Specifies whether another defined ADT\n should be inherited.\n\nConstructors is a list of clauses with the following grammar:\n\n := \n | ( *)\n\nEach clause defines a constructor for the ADT. Nullary constructors\nwill define constants and all other constructors will define\nfunctions.\"\n ;; Do some extreme sanity checking.\n (assert\n (or\n ;; Must be a symbol, or...\n (symbolp adt-name)\n (and\n ;; a list that is...\n (listp adt-name)\n ;; non-empty\n (not (null adt-name))\n ;; whose first element is a symbol (the name of the adt)\n (symbolp (first adt-name))\n ;; and the rest is a property list\n (property-list-p (rest adt-name))))\n (adt-name)\n \"ADT-NAME must either be a symbol, a singleton list with the ADT ~\n name as a symbol, or a list of two elements with the ADT name ~\n and :MUTABLE respectively. Given ~S.\"\n adt-name)\n (let ((valid-options (list ':mutable ':include)))\n (when (and (listp adt-name) (= (mod (length (rest adt-name)) 2) 0))\n (loop for opt in (rest adt-name) by #'cddr do\n\t (when (not (member opt valid-options))\n\t (error \"Option ~A is not valid, valid options are member of ~A.\" opt valid-options)))))\n\n (let ((adt-name (ensure-car adt-name))\n (mutable? (and (listp adt-name)\n (getf (rest adt-name) ':mutable)\n t))\n (include (or (and (listp adt-name)\n (getf (rest adt-name) ':include))\n 'algebraic-data-type))\n (object (gensym \"OBJECT-\"))\n (stream (gensym \"STREAM-\"))\n (depth (gensym \"DEPTH-\"))\n (env (gensym \"ENVIRONMENT-\"))\n (documentation\n (when (stringp (car constructors))\n (pop constructors))))\n\n ;; Sanity check that INCLUDE is a proper algebraic data type.\n (assert (algebraic-data-type-p include)\n ()\n \"When defining the algebraic data type ~S, the :INCLUDE option ~\n was specified with ~S, which is not another algebraic data ~\n type.\"\n adt-name\n include)\n\n ;; Add constructors and their arity to the database.\n (flet ((constructor-and-arity (ctor)\n (if (listp ctor)\n (list (first ctor) (length (rest ctor)))\n (list ctor 0))))\n (set-constructors adt-name (append (get-constructors include)\n (mapcar #'constructor-and-arity constructors))))\n\n (flet ((make-printer (name &optional (nfields 0))\n \"Make a printer function for the structs.\"\n `(lambda (,object ,stream ,depth)\n (declare (ignore ,depth)\n (ignorable ,object))\n ;; We don't check *PRINT-READABLY* because these can\n ;; be readably printed always, provided the arguments\n ;; can be printed readably.\n ;;\n ;; However, we do respect a convenience option\n ;; *PRINT-ADT-READABLY* in case someone finds the\n ;; printing of the #. to be annoying.\n (when *print-adt-readably*\n (write-string \"#.\" ,stream))\n ,(when (plusp nfields)\n `(write-char #\\( ,stream))\n (prin1 ',name ,stream)\n ,@(when (plusp nfields)\n (loop :for i :below nfields\n :append (list\n `(write-char #\\Space ,stream)\n `(prin1 (,(field name i) ,object)\n ,stream))))\n ,(when (plusp nfields)\n `(write-char #\\) ,stream)))))\n ;; Define everything.\n (let ((component-documentation\n ;; Force the adt-name symbol to print with a package\n ;; prefix\n (let ((*package* (find-package :keyword)))\n (format nil \"A component of ADT ~S\" adt-name))))\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n ;; Define the data type.\n (defstruct (,adt-name (:constructor nil)\n (:copier nil)\n (:predicate nil)\n (:include ,include))\n ,@(unsplice documentation))\n\n ;; Define each of the field constructors.\n ,@(loop :for ctor :in (unwrap-singletons constructors)\n :collect\n (etypecase ctor\n ;; Nullary constructor\n (symbol `(progn\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (defstruct\n (,ctor\n (:include ,adt-name)\n (:constructor ,(internal ctor))\n (:copier nil)\n (:predicate nil)\n (:print-function ,(make-printer ctor)))\n ,component-documentation))\n #+sbcl (declaim (sb-ext:freeze-type ,ctor))\n (defmethod make-load-form ((,object ,ctor) &optional ,env)\n (make-load-form-saving-slots ,object\n :slot-names nil\n :environment ,env))\n (define-constant ,ctor (,(internal ctor))\n ,component-documentation)\n (fmakunbound ',(internal ctor))))\n\n ;; N-ary constructors\n (list (let* ((ctor-name (first ctor))\n (field-types (rest ctor))\n (field-names (gen-names (length field-types))))\n `(progn\n (defstruct (,ctor-name\n (:include ,adt-name)\n (:constructor ,ctor-name (,@field-names))\n (:conc-name ,ctor-name)\n (:copier nil)\n (:predicate nil)\n (:print-function\n ,(make-printer ctor-name\n (length field-names))))\n ,component-documentation\n ,@(mapcar (lambda (name type)\n `(,name (error \"Unspecified field.\")\n :type ,type\n ,@(if mutable?\n nil\n '(:read-only t))))\n field-names\n field-types))\n #+sbcl (declaim (sb-ext:freeze-type ,ctor-name))\n (defmethod make-load-form ((,object ,ctor-name) &optional ,env)\n (make-load-form-saving-slots ,object\n :slot-names ',field-names\n :environment ,env)))))))\n ;; Return the type name\n ',adt-name)))))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (defstruct\n (nil (:constructor nil) (:copier nil) (:predicate nil)\n (:include algebraic-data-type)))\n (progn\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (defstruct\n (nil (:include nil) (:constructor %nil) (:copier nil) (:predicate nil)\n (:print-function\n (lambda (#:object-141 #:stream-142 #:depth-143)\n (declare (ignore #:depth-143)\n (ignorable #:object-141))\n (when *print-adt-readably* (write-string \"#.\" #:stream-142))\n nil\n (prin1 'nil #:stream-142)\n nil)))\n #A((34) base-char . \"A component of ADT COMMON-LISP:NIL\")))\n (declaim (sb-ext:freeze-type nil))\n (defmethod make-load-form ((#:object-141 nil) &optional #:environment-144)\n (make-load-form-saving-slots #:object-141 :slot-names nil :environment\n #:environment-144))\n (define-constant nil (%nil)\n #A((34) base-char . \"A component of ADT COMMON-LISP:NIL\"))\n (fmakunbound '%nil))\n 'nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda ())\n\nWhat needs to change: Macro call that should be transformed by LAMBDA\n\n(lambda ())"}, {"role": "assistant", "content": "(defmacro LAMBDA ...)\n\n;; macroexpand:\n#'(lambda ())"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defun-cmatch* common-lisp:nil\n (common-lisp:progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFUN-CMATCH*\n\n(defun-cmatch* common-lisp:nil\n (common-lisp:progn))"}, {"role": "assistant", "content": "(defmacro defun-cmatch* (name args &body body)\n \"Equivalent to (defun (arg) [decl-and-docstring] (cmatch arg (PATTERN BODY...))).\"\n (multiple-value-bind (preamble clauses) (parse-matcher-body body)\n `(defun ,name ,args\n ,@preamble\n (cmatch* ,args\n ,@clauses))))\n\n;; macroexpand:\n(common-lisp:defun common-lisp:nil (common-lisp:progn)\n (cmatch* (common-lisp:progn)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(match common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by MATCH\n\n(match common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro match (what &body clauses)\n #.+match-doc+\n `(match2 ,what\n ,@clauses\n (_ nil)))\n\n;; macroexpand:\n(match2 common-lisp:nil\n (trivia.level2.impl::_ common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with nil)\n\nIssue: Macro call that should be transformed by WITH\n\n(with nil)"}, {"role": "assistant", "content": "(defmacro WITH ...)\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(awhen 'some-name)\n\nPattern to recognize: Macro call that should be transformed by AWHEN\n\n(awhen 'some-name)"}, {"role": "assistant", "content": "(defmacro awhen (test &body body)\n \"Like WHEN, except binds the result of the test to IT (via LET) for the scope\nof the body.\"\n `(anaphoric when ,test ,@body))\n\n;; macroexpand:\n(anaphoric when\n 'some-name)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(lexpr-$send nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by LEXPR-$SEND\n\n(lexpr-$send nil :key nil)"}, {"role": "assistant", "content": "(defmacro LEXPR-$SEND ...)\n\n;; macroexpand:\n(apply #'send-message nil :key nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(acond\n 'some-name)\n\nIssue: Macro call that should be transformed by ACOND\n\n(acond\n 'some-name)"}, {"role": "assistant", "content": "(defmacro ACOND ...)\n\n;; macroexpand:\n(let (it)\n (cond ((setf it quote) some-name)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(n^ 'some-name)\n\nPattern to recognize: Macro call that should be transformed by N^\n\n(n^ 'some-name)"}, {"role": "assistant", "content": "(defmacro n^ (type)\n `(nearest self ,type))\n\n;; macroexpand:\n(nearest self 'some-name)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(shift-incf 'some-name)\n\nProblem: Macro call that should be transformed by SHIFT-INCF\n\n(shift-incf 'some-name)"}, {"role": "assistant", "content": "(defmacro SHIFT-INCF ...)\n\n;; macroexpand:\n(let* ((#:some-name259 some-name)\n (#:temp260 '#:some-name259)\n (#:new258 (+ #:temp260 1)))\n (funcall #'(setf quote) #:new258 #:some-name259)\n #:temp260)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(do-sequences nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DO-SEQUENCES\n\n(do-sequences nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro do-sequences (name/seqs &body forms &environment env)\n \"Iterate over the elements of one or more sequences.\n\n Iteration is performed using the iterator interface, and over\n multiple sequences simultaneously.\n\n The macro arguments can be in one of the following two forms:\n\n 1. (NAME (&REST SEQS) &BODY BODY)\n\n 2. ((&REST SEQS) &BODY BODY)\n\n NAME is a symbol serving as the name of the BLOCK from which the\n forms in BODY can return, using (RETURN-FROM NAME ...). If not\n given defaults to NIL.\n\n Each element of SEQS is a list of the form (VAR SEQUENCE . ARGS),\n where VAR is the variable to which the element of the sequence,\n SEQUENCE, is bound, at each iteration, and ARGS are arguments\n passed to the ITERATOR function, after the sequence.\n\n BODY is a list of forms evaluated at each iteration. RETURN-FROM to\n the block named NAME may be used to terminate the iteration early\n and return a value from the DO-SEQUENCES form. NIL is returned if\n there is no explicit RETURN.\"\n\n (let-if ((name name/seqs)\n (seqs (first forms) name/seqs)\n (forms (rest forms) forms))\n (symbolp name/seqs)\n\n (let ((safety (cadr (assoc 'safety (declaration-information 'optimize env)))))\n `(,(if (> safety 2)\n 'do-sequences-safe%\n 'do-sequences-fast%)\n\n ,name\n ,seqs\n ,@forms))))\n\n;; macroexpand:\n(generic-cl.iterator::do-sequences-fast% nil\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(fbind* nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FBIND*\n\n(fbind* nil\n nil)"}, {"role": "assistant", "content": "(defmacro fbind* (bindings &body body &environment env)\n \"Like `fbind', but creates bindings sequentially.\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbind* `(locally ,@body)))\n (mvlet* ((fn (caar bindings))\n (body decls (parse-body body))\n (local others (partition-declarations `((function ,fn))\n decls\n env)))\n `(fbind (,(first bindings))\n ,@local\n (fbind* ,(rest bindings)\n ,@others\n ,@body))))\n\n;; macroexpand:\n(locally nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(dynamic-progv nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DYNAMIC-PROGV\n\n(dynamic-progv nil\n nil)"}, {"role": "assistant", "content": "(defmacro DYNAMIC-PROGV ...)\n\n;; macroexpand:\n(let* ((#:fixed-symbols235 nil)\n (#:fixed-bindings236 (compute-bindings #:fixed-symbols235 nil)))\n (dynamic-wind\n :proceed\n #:proceed237\n (progv #:fixed-symbols235 #:fixed-bindings236 (#:proceed237))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defclause-driver 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFCLAUSE-DRIVER\n\n(defclause-driver 'some-name)"}, {"role": "assistant", "content": "(defmacro defclause-driver (clause-template &body body)\n \"Macro for for defining (with DEFUN) iterators, which may also be used\nas generators.\"\n (define-clause 'defun clause-template body t))\n\n;; macroexpand:\n(eval-always\n (defun clause-quote-2 (&key ((:quote some-name)) rutils.iter::generate))\n (rutils.iter::install-clause-info '(quote) '(quote) 'clause-quote-2 nil t)\n ''some-name)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(declaration common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by DECLARATION\n\n(declaration common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro DECLARATION ...)\n\n;; macroexpand:\n(common-lisp:declaim (common-lisp:declaration))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(unionf nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by UNIONF\n\n(unionf nil nil)"}, {"role": "assistant", "content": "(defmacro UNIONF ...)\n\n;; macroexpand:\n(setq nil (union nil nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(gen-lambda-with-sticky-stop nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by GEN-LAMBDA-WITH-STICKY-STOP\n\n(gen-lambda-with-sticky-stop nil (progn))"}, {"role": "assistant", "content": "(defmacro gen-lambda-with-sticky-stop (&rest rest)\n `(make-instance \n 'basic-generator \n :function (sticky-stop-lambda ,@rest)))\n\n;; macroexpand:\n(make-instance 'basic-generator :function\n (sticky-stop-lambda nil\n (progn)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defpattern nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPATTERN\n\n(defpattern nil\n nil)"}, {"role": "assistant", "content": "(defmacro defpattern (name lambda-list &body body)\n \"Defines a derived pattern specifier named NAME. This is analogous\nto DEFTYPE.\n\nExamples:\n\n ;; Defines a LIST pattern.\n (defpattern list (&rest args)\n (when args\n `(cons ,(car args) (list ,@(cdr args)))))\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (pattern-expand-function ',name) (lambda ,lambda-list ,@body))))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (pattern-expand-function 'nil) (lambda ())))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defun-match* common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFUN-MATCH*\n\n(defun-match* common-lisp:nil\n :key\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro defun-match* (name args &body body)\n \"Equivalent to (defun (arg) [decl-and-docstring] (match arg (PATTERN BODY...))).\"\n (multiple-value-bind (preamble clauses) (parse-matcher-body body)\n `(defun ,name ,args\n ,@preamble\n (match* ,args\n ,@clauses))))\n\n;; macroexpand:\n(common-lisp:defun common-lisp:nil :key\n (match* :key\n common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(symbol-value-in-$instance nil (progn))\n\nPattern to recognize: Macro call that should be transformed by SYMBOL-VALUE-IN-$INSTANCE\n\n(symbol-value-in-$instance nil (progn))"}, {"role": "assistant", "content": "(defmacro SYMBOL-VALUE-IN-$INSTANCE ...)\n\n;; macroexpand:\n(slot-value nil (progn))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(ekx nil nil)\n\nPattern to recognize: Macro call that should be transformed by EKX\n\n(ekx nil nil)"}, {"role": "assistant", "content": "(defmacro ekx (ekx-id &rest body)\n (let ((result (gensym)))\n `(let ((,result (,@body)))\n (trc ,(string-downcase (symbol-name ekx-id)) :=> ,result)\n ,result)))\n\n;; macroexpand:\n(let ((#:g165 (nil)))\n (trc #A((3) base-char . \"nil\") :=> #:g165)\n #:g165)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(-<> nil)\n\nWrite a macro that addresses: Macro call that should be transformed by -<>\n\n(-<> nil)"}, {"role": "assistant", "content": "(defmacro -<> ...)\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(->>)\n\nWrite a macro that addresses: Macro call that should be transformed by ->>\n\n(->>)"}, {"role": "assistant", "content": "(defmacro ->> ...)\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(ps\n 'some-name)\n\nProblem: Macro call that should be transformed by PS\n\n(ps\n 'some-name)"}, {"role": "assistant", "content": "(defmacro PS ...)\n\n;; macroexpand:\n\"'someName';\""}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(without-dependency-capture\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITHOUT-DEPENDENCY-CAPTURE\n\n(without-dependency-capture\n nil)"}, {"role": "assistant", "content": "(defmacro WITHOUT-DEPENDENCY-CAPTURE ...)\n\n;; macroexpand:\n(let ((%dependent% nil))\n nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(ps)\n\nWhat needs to change: Macro call that should be transformed by PS\n\n(ps)"}, {"role": "assistant", "content": "(defmacro PS ...)\n\n;; macroexpand:\n\"\""}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(subtest nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SUBTEST\n\n(subtest nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro subtest (desc &body body)\n `(%subtest ,desc (lambda () ,@body)))\n\n;; macroexpand:\n(prove.test::%subtest nil (lambda () :key nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(initially 'some-name)\n\nPattern to recognize: Macro call that should be transformed by INITIALLY\n\n(initially 'some-name)"}, {"role": "assistant", "content": "(defmacro INITIALLY ...)\n\n;; macroexpand:\n(#S(initialization :form 'some-name))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defobject-amendment nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFOBJECT-AMENDMENT\n\n(defobject-amendment nil)"}, {"role": "assistant", "content": "(defmacro DEFOBJECT-AMENDMENT ...)\n\n;; macroexpand:\n(defobject nil\n (standard-object))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(defparameter-unbound nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFPARAMETER-UNBOUND\n\n(defparameter-unbound nil\n nil)"}, {"role": "assistant", "content": "(defmacro defparameter-unbound (var &body (docstring))\n \"Like `defvar-unbound', but ensures VAR is unbound when evaluated.\"\n `(progn\n (defvar ,var)\n (makunbound ',var)\n (setf (documentation ',var 'variable) ,docstring)\n ',var))\n\n;; macroexpand:\n(progn\n (defvar nil)\n (makunbound 'nil)\n (setf (documentation 'nil 'variable) nil)\n 'nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(c_in\n nil\n nil)\n\nProblem: Macro call that should be transformed by C_IN\n\n(c_in\n nil\n nil)"}, {"role": "assistant", "content": "(defmacro c_in (&body body)\n `(c-input (:lazy :once-asked) (progn ,@body)))\n\n;; macroexpand:\n(c-input (:lazy :once-asked) (progn nil nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(for-all* nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by FOR-ALL*\n\n(for-all* nil\n (progn))"}, {"role": "assistant", "content": "(defmacro for-all* (bindings &body body)\n \"Bind BINDINGS to random variables and test BODY *num-trials* times.\n\nWorks like FOR-ALL but variables are defined sequentially - subsequent\ngenerator bindings may use value of a previous generator.\n\nExample:\n\n (for-all* ((a (gen-integer))\n (b (gen-integer :min a :max (+ a 20)))\n (is (<= a b)))\"\n (with-gensyms (test-lambda-args)\n `(perform-random-testing\n nil\n (lambda (,test-lambda-args)\n (declare (ignore ,test-lambda-args))\n (dbind-rec ,bindings\n (if (and ,@(delete-if #'null (mapcar #'third bindings)))\n (progn ,@body)\n (throw 'run-once\n (list :guard-conditions-failed))))))))\n\n;; macroexpand:\n(perform-random-testing nil\n (lambda (#:test-lambda-args134)\n (declare (ignore #:test-lambda-args134))\n (dbind-rec nil\n (if (and)\n (progn (progn))\n (throw 'run-once\n (list :guard-conditions-failed))))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(doiter nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DOITER\n\n(doiter nil\n (progn))"}, {"role": "assistant", "content": "(defmacro doiter (name/iter &body body)\n \"Sames as DOITERS however for the special case of iterating over a\n single sequence.\n\n The macro arguments can be in one of the following two forms:\n\n 1. (NAME (ITER &REST ARGS) &BODY BODY)\n\n 2. ((ITER &REST ARGS) &BODY BODY)\n\n NAME is the block name, NIL if not given.\n\n ITER is the variable to which the sequence iterator is bound.\n\n ARGS are the arguments passed to the ITERATOR function, the result\n of which is bound to ITER.\n\n BODY is the list of forms in the loop body.\"\n\n (let-if ((name name/iter)\n (iter (first body) name/iter)\n (body (rest body) body))\n (symbolp name/iter)\n\n (destructuring-bind (iter &rest args) iter\n `(doiters ,name ((,iter ,@args)) ,@body))))\n\n;; macroexpand:\n(doiters nil\n ((progn)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(is-traced$method 'some-name)\n\nPattern to recognize: Macro call that should be transformed by IS-TRACED$METHOD\n\n(is-traced$method 'some-name)"}, {"role": "assistant", "content": "(defmacro IS-TRACED$METHOD ...)\n\n;; macroexpand:\n(mcs-is-traced quote some-name)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(odig 'some-name)\n\nIssue: Macro call that should be transformed by ODIG\n\n(odig 'some-name)"}, {"role": "assistant", "content": "(defmacro ODIG ...)\n\n;; macroexpand:\n(odig 1 'some-name)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(c-envalue\n nil)\n\nPattern to recognize: Macro call that should be transformed by C-ENVALUE\n\n(c-envalue\n nil)"}, {"role": "assistant", "content": "(defmacro c-envalue (&body body)\n `(make-c-envaluer\n :envalue-rule (c-lambda ,@body)))\n\n;; macroexpand:\n(make-c-envaluer :envalue-rule\n (c-lambda\n nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(define-test+run nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-TEST+RUN\n\n(define-test+run nil\n nil)"}, {"role": "assistant", "content": "(defmacro define-test+run (name &body args-and-body)\n `(progn\n (define-test ,name ,@args-and-body)\n (eval-when (:execute)\n (let* ((*silence-plain-compilation-errors-p* nil) ; must be let*! the order matters!\n (report (test ',name :report 'plain)))\n (if (member (status report) '(:passed :skipped))\n report\n (values report\n (loop for result across (results report)\n when (and (not (typep result 'test-result))\n (eql :failed (status result)))\n collect (expression result))))))))\n\n;; macroexpand:\n(progn\n (define-test nil\n nil)\n (eval-when (:execute)\n (let* ((*silence-plain-compilation-errors-p* nil)\n (report (test 'nil :report 'plain)))\n (if (member (status report) '(:passed :skipped))\n report\n (values report\n (loop for result across (results report)\n when (and (not (typep result 'test-result))\n (eql :failed (status result)))\n collect (expression result)))))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(doc 'some-name)\n\nProblem: Macro call that should be transformed by DOC\n\n(doc 'some-name)"}, {"role": "assistant", "content": "(defmacro DOC ...)\n\n;; macroexpand:\n(documentation 'some-name)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(define-alternate-type-name nil nil)\n\nProblem: Macro call that should be transformed by DEFINE-ALTERNATE-TYPE-NAME\n\n(define-alternate-type-name nil nil)"}, {"role": "assistant", "content": "(defmacro define-alternate-type-name (current-type-name alternate-type-name)\n `(add-alternate-type-name ',alternate-type-name ',current-type-name))\n\n;; macroexpand:\n(add-alternate-type-name 'nil 'nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(fail nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FAIL\n\n(fail nil)"}, {"role": "assistant", "content": "(defmacro fail (form &optional (type 'error) description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(fail ,form ,type)\n :value-form '(capture-error ,form)\n :body (lambda () (capture-error ,form ,(maybe-unquote type)))\n :expected ',(maybe-unquote type)\n :comparison 'typep\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))\n\n;; macroexpand:\n(eval-in-context *context*\n (make-instance 'comparison-result :expression\n '(fail nil error) :value-form\n '(capture-error nil) :body\n (lambda () (capture-error nil error)) :expected\n 'error :comparison 'typep))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(mvlet nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MVLET\n\n(mvlet nil\n nil)"}, {"role": "assistant", "content": "(defmacro mvlet ((&rest bindings) &body body)\n \"Parallel (`let'-like) version of `mvlet*'.\"\n (cond ((null bindings)\n `(locally ,@body))\n ((null (rest bindings))\n (let* ((bindings (canonicalize-bindings bindings))\n (b (first bindings)))\n `(multiple-value-bind ,(butlast b) ,(lastcar b)\n ,@body)))\n ((every #'simple-binding-p bindings)\n `(let ,bindings\n ,@body))\n (t (let* ((bindings (canonicalize-bindings bindings))\n (binds\n (mapcar #'butlast bindings))\n (exprs\n (mapcar #'lastcar bindings))\n (temp-binds\n (loop for vars in binds\n collect (mapcar #'string-gensym vars)))\n (temp-bindings\n (loop for temp-bind in temp-binds\n for expr in exprs\n collect (append temp-bind (list expr))))\n (rebindings\n (loop for vars in binds\n for temp-vars in temp-binds\n append (loop for var in vars\n for temp-var in temp-vars\n collect (list var temp-var)))))\n `(mvlet* ,temp-bindings\n (let ,rebindings\n ,@body))))))\n\n;; macroexpand:\n(locally nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(maxf nil nil)\n\nPattern to recognize: Macro call that should be transformed by MAXF\n\n(maxf nil nil)"}, {"role": "assistant", "content": "(defmacro MAXF ...)\n\n;; macroexpand:\n(setq nil (max nil nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(rotatef nil nil)\n\nWhat needs to change: Macro call that should be transformed by ROTATEF\n\n(rotatef nil nil)"}, {"role": "assistant", "content": "(defmacro ROTATEF ...)\n\n;; macroexpand:\n(let* ()\n (multiple-value-bind (#:new269)\n nil\n (multiple-value-bind (#:new270)\n nil\n (setq nil #:new269)\n (setq nil #:new270)\n nil)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(appendf 'some-name)\n\nWhat needs to change: Macro call that should be transformed by APPENDF\n\n(appendf 'some-name)"}, {"role": "assistant", "content": "(defmacro APPENDF ...)\n\n;; macroexpand:\n(let* ((#:some-name158 some-name) (#:new157 (append '#:some-name158)))\n (funcall #'(setf quote) #:new157 #:some-name158))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(c?once\n nil)\n\nPattern to recognize: Macro call that should be transformed by C?ONCE\n\n(c?once\n nil)"}, {"role": "assistant", "content": "(defmacro c?once (&body body)\n `(make-c-dependent\n :code '(without-c-dependency ,@body)\n :inputp nil\n :value-state :unevaluated\n :rule (c-lambda (without-c-dependency ,@body))))\n\n;; macroexpand:\n(make-c-dependent :code\n '(without-c-dependency\n nil)\n :inputp nil :value-state :unevaluated :rule\n (c-lambda\n (without-c-dependency\n nil)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-special-initargs nil)\n\nProblem: Macro call that should be transformed by WITH-SPECIAL-INITARGS\n\n(with-special-initargs nil)"}, {"role": "assistant", "content": "(defmacro WITH-SPECIAL-INITARGS ...)\n\n;; macroexpand:\n(funcall-with-special-initargs (list) (lambda ()))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(when-let nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WHEN-LET\n\n(when-let nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro when-let (bindings &body forms)\n \"Creates new variable bindings, and conditionally executes FORMS.\n\nBINDINGS must be either single binding of the form:\n\n (variable initial-form)\n\nor a list of bindings of the form:\n\n ((variable-1 initial-form-1)\n (variable-2 initial-form-2)\n ...\n (variable-n initial-form-n))\n\nAll initial-forms are executed sequentially in the specified order. Then all\nthe variables are bound to the corresponding values.\n\nIf all variables were bound to true values, then FORMS are executed as an\nimplicit PROGN.\"\n (let* ((binding-list (if (and (consp bindings) (symbolp (car bindings)))\n (list bindings)\n bindings))\n (variables (mapcar #'car binding-list)))\n `(let ,binding-list\n (when (and ,@variables)\n ,@forms))))\n\n;; macroexpand:\n(let ()\n (when (and) :key nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(cmatch* 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by CMATCH*\n\n(cmatch* 'some-name)"}, {"role": "assistant", "content": "(defmacro cmatch* (whats &body clauses)\n #.+match*-doc+ \n (let ((temps (make-gensyms whats \"OTHERWISE\")))\n `(match2* ,whats\n ,@clauses\n (,temps\n (cerror \"continue\" 'match-error :pattern ',clauses :values (list ,@temps))))))\n\n;; macroexpand:\n(match2* 'some-name\n ((#:otherwise161 #:otherwise162)\n (common-lisp:cerror \"continue\" 'match-error :pattern 'common-lisp:nil\n :values\n (common-lisp:list #:otherwise161 #:otherwise162))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-html\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-HTML\n\n(with-html\n nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-html (&body body &environment env)\n \"Interpret BODY as HTML. Consult README.txt for the syntax.\"\n `(let ((*html* (ensure-html-stream *html*)))\n ,(if (and (null (cdr body)) (atom (car body)))\n (car body)\n `(progn ,@(parse-html body env)))))\n\n;; macroexpand:\n(let ((*html* (ensure-html-stream *html*)))\n (progn nil :key nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-max nil)\n\nWhat needs to change: Macro call that should be transformed by COLLECT-MAX\n\n(collect-max nil)"}, {"role": "assistant", "content": "(defmacro COLLECT-MAX ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-340 (generator nil))\n #:numbers-334\n (#:number-336 nil))\n (declare (type generator #:generator-340))\n (tagbody\n #:ll-341\n (setq #:numbers-334 (next-in #:generator-340 (go end)))\n (if (or (null #:number-336) (< #:number-336 #:numbers-334))\n (setq #:number-336 #:numbers-334))\n (go #:ll-341)\n end)\n (if (null #:number-336)\n (setq #:number-336 nil))\n #:number-336)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(summing\n 'some-name)\n\nIssue: Macro call that should be transformed by SUMMING\n\n(summing\n 'some-name)"}, {"role": "assistant", "content": "(defmacro summing (&body body)\n \"Within BODY, bind `sum' to a function that gathers numbers to sum.\n\nIf the first form in BODY is a literal number, it is used instead of 0\nas the initial sum.\n\nTo see the running sum, call `sum' with no arguments.\n\nReturn the total.\"\n ;; TODO This should be numerically stable, at least if the zero is a\n ;; float.\n (let ((zero (if (numberp (first body)) (pop body) 0)))\n (with-gensyms (running-total x x-supplied?)\n (with-current-package-symbols (sum)\n `(let ((,running-total ,zero))\n (declare (number ,running-total))\n (flet ((,sum (&optional (,x 0 ,x-supplied?))\n (if ,x-supplied?\n (incf ,running-total ,x)\n ,running-total)))\n (declare (ignorable (function ,sum)))\n ,@body)\n (the number ,running-total))))))\n\n;; macroexpand:\n(let ((#:running-total201 0))\n (declare (number #:running-total201))\n (flet ((sum (&optional (#:x202 0 #:x-supplied?203))\n (if #:x-supplied?203\n (incf #:running-total201 #:x202)\n #:running-total201)))\n (declare (ignorable (function sum)))\n 'some-name)\n (the number #:running-total201))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-condition-restarts nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-CONDITION-RESTARTS\n\n(with-condition-restarts nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro WITH-CONDITION-RESTARTS ...)\n\n;; macroexpand:\n(let ((#:condition-form171 nil))\n (let ((#:restarts172 :key))\n (unwind-protect\n (progn\n (dolist (#:restart173 #:restarts172)\n (push #:condition-form171\n (sb-kernel:restart-associated-conditions #:restart173)))\n nil)\n (dolist (#:restart173 #:restarts172)\n (pop (sb-kernel:restart-associated-conditions #:restart173))))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(producing nil)\n\nPattern to recognize: Macro call that should be transformed by PRODUCING\n\n(producing nil)"}, {"role": "assistant", "content": "(defmacro PRODUCING ...)\n\n;; macroexpand:\n(non-opt-producing nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(enable-static-dispatch)\n\nPattern to recognize: Macro call that should be transformed by ENABLE-STATIC-DISPATCH\n\n(enable-static-dispatch)"}, {"role": "assistant", "content": "(defmacro enable-static-dispatch (&rest names)\n (simple-style-warning \"ENABLE-STATIC-DISPATCH is deprecated. Use STATIC-DISPATCH-TYPE declaration instead.\")\n\n `(progn\n ,@(iter (for name in names)\n (match name\n ((list :inline name)\n (collect `(declaim (static-dispatch-type inline ,name))))\n\n ((list :function name)\n (collect `(declaim (static-dispatch-type function ,name))))))))\n\n;; macroexpand:\n(progn)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(declaim (quote some-name))\n\nWrite a macro that addresses: Macro call that should be transformed by DECLAIM\n\n(declaim (quote some-name))"}, {"role": "assistant", "content": "(defmacro DECLAIM ...)\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (sb-c::%proclaim ''some-name (sb-c:source-location)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(letrec nil\n nil)\n\nIssue: Macro call that should be transformed by LETREC\n\n(letrec nil\n nil)"}, {"role": "assistant", "content": "(defmacro letrec ((&rest bindings) &body body)\n \"Recursive LET.\nThe idea is that functions created in BINDINGS can close over one\nanother, and themselves.\n\nNote that `letrec' only binds variables: it can define recursive\nfunctions, but can't bind them as functions. (But see `fbindrec'.)\"\n `(letrec-with psetq ,bindings\n ,@body))\n\n;; macroexpand:\n(serapeum/binding::letrec-with psetq\n nil\n nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(some-> nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SOME->\n\n(some-> nil)"}, {"role": "assistant", "content": "(defmacro some-> (init &body exps) (arrow-macro init exps nil t))\n\n;; macroexpand:\n(block #:g155 nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(enable-quasi-quoted-binary-to-binary-emitting-form-syntax 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BINARY-TO-BINARY-EMITTING-FORM-SYNTAX\n\n(enable-quasi-quoted-binary-to-binary-emitting-form-syntax 'some-name)"}, {"role": "assistant", "content": "(defmacro ENABLE-QUASI-QUOTED-BINARY-TO-BINARY-EMITTING-FORM-SYNTAX ...)\n\n;; macroexpand:\n(eval-when (:compile-toplevel :execute)\n (setf *readtable* (copy-readtable *readtable*))\n (set-quasi-quoted-binary-to-binary-emitting-form-syntax-in-readtable\n 'some-name :with-inline-emitting nil :declarations 'nil :start-character nil\n :end-character nil :unquote-character #\\COMMA :splice-character\n #\\COMMERCIAL_AT :destructive-splice-character #\\FULL_STOP\n :dispatched-quasi-quote-name \"bin\")\n (values))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(aecase nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AECASE\n\n(aecase nil)"}, {"role": "assistant", "content": "(defmacro aecase (keyform &body cases)\n \"Like ECASE, except binds the result of the keyform to IT (via LET) for the\nscope of the cases.\"\n `(anaphoric ecase ,keyform ,@cases))\n\n;; macroexpand:\n(anaphoric ecase\n nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-context-variables nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-CONTEXT-VARIABLES\n\n(with-context-variables nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-context-variables ((&rest vars) &body body)\n `(symbol-macrolet\n ,(loop for var in vars\n for form = `(context ,(intern (string var) :keyword))\n collect `(,var ,form))\n ,@body))\n\n;; macroexpand:\n(symbol-macrolet ()\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defgeneric nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFGENERIC\n\n(defgeneric nil (progn))"}, {"role": "assistant", "content": "(defmacro DEFGENERIC ...)\n\n;; macroexpand:\n(progn\n (walk-environment\n (closer-mop:defgeneric nil\n (progn)))\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (static-dispatch::add-compiler-macro 'nil)\n (static-dispatch::remove-defined-methods 'nil))\n (let ((#:gf186 (fdefinition 'nil)))\n (when (typep #:gf186 'generic-function)\n (setf (static-dispatch::combination-options 'nil) '(standard nil)))\n #:gf186))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(assert common-lisp:nil)\n\nProblem: Macro call that should be transformed by ASSERT\n\n(assert common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro assert (datum cl:&optional (format-string \"\") cl:&rest format-data)\n \"Signal an error unless `datum` is `True`.\n\nIf the assertion fails, the signaled error will apply the `format-data`\nto the `format-string` via `cl:format` to produce an error message.\"\n ;; OPTIMIZE: lazily evaluate the FORMAT-DATA only when the assertion fails\n (cl:check-type format-string cl:string)\n (cl:let* ((datum-temp (cl:gensym \"ASSERT-DATUM-\"))\n (format-data-temps (alexandria:make-gensym-list (cl:length format-data)\n \"ASSERT-FORMAT-DATUM-\")))\n `(let ((,datum-temp ,datum)\n ,@(cl:mapcar #'cl:list format-data-temps format-data))\n (progn\n (lisp (-> :any) (,datum-temp ,@format-data-temps)\n (cl:assert ,datum-temp ()\n ,(cl:format cl:nil\n \"Assertion ~a failed: ~a\"\n datum format-string)\n ,@format-data-temps))\n Unit))))\n\n;; macroexpand:\n(let ((#:assert-datum-201 common-lisp:nil))\n (progn\n (lisp (-> :any)\n (#:assert-datum-201)\n (common-lisp:assert #:assert-datum-201 common-lisp:nil\n #A((22) common-lisp:base-char\n . \"Assertion NIL failed: \")))\n unit))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-guessing-encoder\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-GUESSING-ENCODER\n\n(with-guessing-encoder\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro with-guessing-encoder (&body body)\n `(with-local-encoder (use-guessing-encoder)\n ,@body))\n\n;; macroexpand:\n(with-local-encoder\n (use-guessing-encoder)\n nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(define-method-combination nil)\n\nProblem: Macro call that should be transformed by DEFINE-METHOD-COMBINATION\n\n(define-method-combination nil)"}, {"role": "assistant", "content": "(defmacro define-method-combination (name &rest args)\n `(progn\n (define-method-combination% ,name ,@args)\n (c2mop:define-method-combination ,name ,@args)))\n\n;; macroexpand:\n(progn\n (define-method-combination% nil)\n (common-lisp:define-method-combination nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(fail-compile nil (progn))\n\nProblem: Macro call that should be transformed by FAIL-COMPILE\n\n(fail-compile nil (progn))"}, {"role": "assistant", "content": "(defmacro fail-compile (form &optional (type 'error) description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(fail-expansion ,form)\n :value-form '(nth-value 3 (try-compile ',form ',type))\n :body (lambda () (nth-value 3 (try-compile ',form ',type)))\n :expected ',(maybe-unquote type)\n :comparison 'typep\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))\n\n;; macroexpand:\n(eval-in-context *context*\n (make-instance 'comparison-result :expression\n '(fail-expansion nil) :value-form\n '(nth-value 3 (try-compile 'nil '(progn)))\n :body\n (lambda ()\n (nth-value 3 (try-compile 'nil '(progn))))\n :expected '(progn) :comparison 'typep))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(=> nil (progn))\n\nWhat needs to change: Macro call that should be transformed by =>\n\n(=> nil (progn))"}, {"role": "assistant", "content": "(defmacro => (fn1 fn2 &rest fns)\n \"Function composition of FN1, FN2 and all the other FNS.\"\n (let ((arg (gensym \"ARG\")))\n `(lambda (,arg)\n ,(if fns\n `(,fn1 (call (=> ,fn2 ,@fns) ,arg))\n `(,fn1 (,fn2 ,arg))))))\n\n;; macroexpand:\n(lambda (#:arg150) (nil ((progn) #:arg150)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(char-ecase nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by CHAR-ECASE\n\n(char-ecase nil\n (progn))"}, {"role": "assistant", "content": "(defmacro char-ecase (keyform &body clauses)\n \"Like `ecase', but specifically for characters.\nExpands into `tree-case'.\"\n `(char-ecase-1 ,keyform\n ,@(expand-char-case-keys clauses)))\n\n;; macroexpand:\n(char-ecase-1 nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(iterate 'some-name)\n\nIssue: Macro call that should be transformed by ITERATE\n\n(iterate 'some-name)"}, {"role": "assistant", "content": "(defmacro ITERATE ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-265 (generator nil))\n #:m-259\n (#:generator-263 (generator nil))\n #:m-260)\n (declare (type generator #:generator-265)\n (type generator #:generator-263))\n (tagbody\n #:ll-266\n (setq #:m-259 (next-in #:generator-265 (go end)))\n (setq #:m-260 (next-in #:generator-263 (go end)))\n ((lambda (quote some-name)) #:m-260 #:m-259)\n (go #:ll-266)\n end)\n nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-cached-reader-conditionals\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-CACHED-READER-CONDITIONALS\n\n(with-cached-reader-conditionals\n nil)"}, {"role": "assistant", "content": "(defmacro WITH-CACHED-READER-CONDITIONALS ...)\n\n;; macroexpand:\n(call-with-cached-reader-conditionals (lambda () nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(define-declaration nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-DECLARATION\n\n(define-declaration nil\n (progn))"}, {"role": "assistant", "content": "(defmacro DEFINE-DECLARATION ...)\n\n;; macroexpand:\n(sb-cltl2:define-declaration nil\n (#:args226 #:env225)\n (declare (ignorable #:env225))\n (let ((progn (rest #:args226)))\n (multiple-value-call #'cl-environments.cltl2::wrap-declaration-result\n (progn))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(defpackage nil)\n\nPattern to recognize: Macro call that should be transformed by DEFPACKAGE\n\n(defpackage nil)"}, {"role": "assistant", "content": "(defmacro DEFPACKAGE ...)\n\n;; macroexpand:\n(common-lisp:defpackage nil\n (:use :adhoc :closer-mop :cl)\n (:shadowing-import-from :closer-mop\n #:defmethod\n #:standard-generic-function\n #:defgeneric\n #:standard-method\n #:standard-class)\n (:shadowing-import-from :adhoc #:defpackage #:variable #:the))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(lambda ())\n\nIssue: Macro call that should be transformed by LAMBDA\n\n(lambda ())"}, {"role": "assistant", "content": "(defmacro LAMBDA ...)\n\n;; macroexpand:\n#'(lambda ())"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(fn nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FN\n\n(fn nil\n nil)"}, {"role": "assistant", "content": "(defmacro FN ...)\n\n;; macroexpand:\n(labels ((nil ()\n ))\n #'nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(live\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by LIVE\n\n(live\n nil\n nil)"}, {"role": "assistant", "content": "(defmacro live (&body forms)\n \"Define a live block consisting of FORMS.\n\nThe FORMS are evaluated once when the LIVE form is first evaluated,\nafter which they are evaluated again whenever the values of the cells\nreferenced by them change. Cells may be referenced either directly in\nFORMS or by a function called during the evaluation of FORMS.\n\nReturns a function which when called, stops the live block. Once\nstopped the live block will no longer be called when the values of the\nreferenced cells change.\"\n\n (let ((spec (make-instance 'watch-function-spec :body forms)))\n (generate-watch-function spec)))\n\n;; macroexpand:\n(let ((#:updating?195 nil)\n (#:waiting-for-change?196 nil)\n (#:arguments200 (make-hash-set)))\n (labels ((#:will-update197 (#:arg201)\n (declare (ignore #:arg201))\n (when (not #:updating?195)\n (setf #:updating?195 t\n #:waiting-for-change?196 nil)))\n (#:update198 (#:arg201 #:did-change202)\n (declare (ignore #:arg201))\n (when\n (or #:updating?195\n (and #:did-change202 #:waiting-for-change?196))\n (setf #:updating?195 nil\n #:waiting-for-change?196 (not #:did-change202))\n (when #:did-change202 (#:watch199))))\n (#:watch199 ()\n (handler-case\n (with-tracker ((#:arg201)\n (unless (memberp #:arg201 #:arguments200)\n (->> (nadjoin #:arg201 #:arguments200)\n (setf #:arguments200))\n (call-add-observer #:arg201\n (make-observer :key '#:g194\n :will-update\n #'#:will-update197\n :update\n #'#:update198))))\n nil\n nil)\n (condition nil nil)))\n (#:stop203 ()\n (doseq (#:arg201 #:arguments200)\n (call-remove-observer #:arg201\n (make-observer :key '#:g194 :will-update\n #'#:will-update197 :update\n #'#:update198)))\n (clear #:arguments200)\n nil))\n (#:watch199)\n #'#:stop203))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(newq nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NEWQ\n\n(newq nil nil)"}, {"role": "assistant", "content": "(defmacro NEWQ ...)\n\n;; macroexpand:\n(new 'nil nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(cmatch common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CMATCH\n\n(cmatch common-lisp:nil\n :key\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro cmatch (what &body clauses)\n #.+match-doc+\n (with-gensyms (otherwise)\n `(match2 ,what\n ,@clauses\n (,otherwise (cerror \"continue\" 'match-error :pattern ',clauses :values (list ,otherwise))))))\n\n;; macroexpand:\n(match2 common-lisp:nil\n :key\n common-lisp:nil\n (#:otherwise166\n (common-lisp:cerror \"continue\" 'match-error :pattern '(:key common-lisp:nil)\n :values (common-lisp:list #:otherwise166))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(listcase nil)\n\nProblem: Macro call that should be transformed by LISTCASE\n\n(listcase nil)"}, {"role": "assistant", "content": "(defmacro listcase (list &body cases)\n \"A typecase-like macro to destinguish between 3 possible kinds of LIST:\n simple lists, alists, and dlists.\n Evaluates the appropriate key-form depending on the kind:\n ALIST, DLIST or simple list (T).\"\n (once-only (list)\n `(if (consp (first ,list))\n (cond ((consp (second ,list))\n (progn ,@(assoc1 'alist cases)))\n ((second ,list)\n (progn ,@(assoc1 'dlist cases)))\n (t\n (progn ,@(assoc1 't cases))))\n (progn ,@(assoc1 't cases)))))\n\n;; macroexpand:\n(let ((#:list152 nil))\n (if (consp (first #:list152))\n (cond ((consp (second #:list152)) (progn)) ((second #:list152) (progn))\n (t (progn)))\n (progn)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(nor 'some-name)\n\nWhat needs to change: Macro call that should be transformed by NOR\n\n(nor 'some-name)"}, {"role": "assistant", "content": "(defmacro nor (&rest forms)\n \"Equivalent to (not (or ...)).\n\nFrom Arc.\"\n (if (null forms) t\n (if (null (rest forms))\n `(not ,(first forms))\n `(if ,(first forms)\n nil\n (nor ,@(rest forms))))))\n\n;; macroexpand:\n(not 'some-name)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(fm! 'some-name)\n\nPattern to recognize: Macro call that should be transformed by FM!\n\n(fm! 'some-name)"}, {"role": "assistant", "content": "(defmacro fm! (md-name &optional (starting 'self))\n `(without-c-dependency \n (fm-find-one ,starting ,(if (consp md-name)\n `(list ',(car md-name) ,(cadr md-name))\n `',md-name)\n :must-find t\n :global-search nil)))\n\n;; macroexpand:\n(without-c-dependency\n (fm-find-one self (list 'quote some-name) :must-find t :global-search nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(doiter 'some-name)\n\nWhat needs to change: Macro call that should be transformed by DOITER\n\n(doiter 'some-name)"}, {"role": "assistant", "content": "(defmacro doiter (name/iter &body body)\n \"Sames as DOITERS however for the special case of iterating over a\n single sequence.\n\n The macro arguments can be in one of the following two forms:\n\n 1. (NAME (ITER &REST ARGS) &BODY BODY)\n\n 2. ((ITER &REST ARGS) &BODY BODY)\n\n NAME is the block name, NIL if not given.\n\n ITER is the variable to which the sequence iterator is bound.\n\n ARGS are the arguments passed to the ITERATOR function, the result\n of which is bound to ITER.\n\n BODY is the list of forms in the loop body.\"\n\n (let-if ((name name/iter)\n (iter (first body) name/iter)\n (body (rest body) body))\n (symbolp name/iter)\n\n (destructuring-bind (iter &rest args) iter\n `(doiters ,name ((,iter ,@args)) ,@body))))\n\n;; macroexpand:\n(doiters nil\n ('some-name))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(slet nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by SLET\n\n(slet nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro slet (form &body body)\n \"Binds the FORM to IT (via SYMBOL-MACROLET) in the scope of the BODY. IT can\nbe set with SETF.\"\n `(symbolic ignore-first ,form (progn ,@body)))\n\n;; macroexpand:\n(symbolic ignore-first nil (progn :key nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(local*\n nil\n (progn))\n\nIssue: Macro call that should be transformed by LOCAL*\n\n(local*\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro local* (&body body)\n \"Like `local', but leave the last form in BODY intact.\n\n (local*\n (defun aux-fn ...)\n (defun entry-point ...))\n =>\n (labels ((aux-fn ...))\n (defun entry-point ...))\"\n `(local\n ,@(butlast body)\n (without-internal-definitions ,@(last body))))\n\n;; macroexpand:\n(local\n nil\n (serapeum/internal-definitions::without-internal-definitions\n (progn)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(if-match common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IF-MATCH\n\n(if-match common-lisp:nil\n :key\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro if-match (pattern arg &body (then &optional else))\n \"Equivalent to (match ARG (PATTERN THEN) (_ ELSE)).\"\n `(match ,arg\n (,pattern ,then)\n (_ ,else)))\n\n;; macroexpand:\n(match :key\n (common-lisp:nil common-lisp:nil)\n (trivia.level2.impl::_ common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(dotree 'some-name)\n\nIssue: Macro call that should be transformed by DOTREE\n\n(dotree 'some-name)"}, {"role": "assistant", "content": "(defmacro dotree ((subtree tree &optional result) &body body)\n \"Iterate over each SUBTREE of the TREE in depth-first order.\n Optionally return RESULT.\"\n (with-gensyms (rec child)\n `(block nil\n (labels ((,rec (,subtree)\n ,@body\n (unless (atom ,subtree)\n (dolist (,child ,subtree)\n (,rec ,child)))))\n (when-it ,tree\n (,rec it))\n ,result))))\n\n;; macroexpand:\n(block nil\n (labels ((#:g238 (quote)\n (unless (atom quote) (dolist (#:g239 quote) (#:g238 #:g239)))))\n (when-it some-name\n (#:g238 it))\n nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(jif nil :key nil)\n\nProblem: Macro call that should be transformed by JIF\n\n(jif nil :key nil)"}, {"role": "assistant", "content": "(defmacro jif (test then &optional (else nil))\n \"JSON-aware version of `cl:if'.\nIf TEST is `jtruep' evaluate THEN, otherwise evaluate ELSE.\"\n `(if (jtruep ,test)\n ,then\n ,else))\n\n;; macroexpand:\n(if (jtruep nil)\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(example\n 'some-name)\n\nIssue: Macro call that should be transformed by EXAMPLE\n\n(example\n 'some-name)"}, {"role": "assistant", "content": "(defmacro example (&body body)\n \"Like `comment'.\"\n `(comment ,@body))\n\n;; macroexpand:\n(comment\n 'some-name)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(defmethod* nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFMETHOD*\n\n(defmethod* nil (progn))"}, {"role": "assistant", "content": "(defmacro DEFMETHOD* ...)\n\n;; macroexpand:\n(let* ((#:nil127 (ensure-generic*-function 'nil))\n (temp-method (defmethod #:nil126 (progn)))\n (actual-gf\n (ensure-generic*-function 'nil :lambda-list\n (sb-mop:generic-function-lambda-list\n (symbol-function '#:nil126))\n :special-variables 'nil))\n (actual-method\n (add-method* #:nil127\n (make-instance 'method* :special-variables (list)\n :qualifiers 'nil :specializers\n (sb-mop:method-specializers temp-method)\n :lambda-list\n (sb-mop:method-lambda-list temp-method)\n :documentation\n (documentation temp-method t) :function\n (sb-mop:method-function temp-method)))))\n (declare (ignorable #:nil127)\n (ignore actual-gf))\n (setf (documentation actual-method t) (documentation temp-method t))\n actual-method)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with)\n\nIssue: Macro call that should be transformed by WITH\n\n(with)"}, {"role": "assistant", "content": "(defmacro WITH ...)\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(is-values nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by IS-VALUES\n\n(is-values nil :key nil)"}, {"role": "assistant", "content": "(defmacro is-values (got expected &rest args)\n `(is (multiple-value-list ,got) ,expected ,@args))\n\n;; macroexpand:\n(is (multiple-value-list nil) :key nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(*let nil)\n\nWhat needs to change: Macro call that should be transformed by *LET\n\n(*let nil)"}, {"role": "assistant", "content": "(defmacro *LET ...)\n\n;; macroexpand:\n(let* ())"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(defmacro+ps nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFMACRO+PS\n\n(defmacro+ps nil\n nil)"}, {"role": "assistant", "content": "(defmacro DEFMACRO+PS ...)\n\n;; macroexpand:\n(progn\n (defmacro nil ())\n (defpsmacro nil\n nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n;; Common pattern: test a value, use result in then-branch\n(let ((result (compute-something)))\n (if result\n (format t \"Got: ~a~%\" result)\n :nothing))\n\n;; Want: implicit 'it' bound to test result\n\nPattern to recognize: Repeated pattern of binding test result then branching on it \u2014 want implicit 'it' anaphor\n\n;; Common pattern: test a value, use result in then-branch\n(let ((result (compute-something)))\n (if result\n (format t \"Got: ~a~%\" result)\n :nothing))\n\n;; Want: implicit 'it' bound to test result"}, {"role": "assistant", "content": "(defmacro aif (test then &optional else)\n `(let ((it ,test))\n (if it ,then ,else)))\n\n;; macroexpand:\n;; (aif (compute-something)\n;; (format t \"Got: ~a~%\" it)\n;; :nothing)\n;; Expands to:\n;; (LET ((IT (COMPUTE-SOMETHING)))\n;; (IF IT\n;; (FORMAT T \"Got: ~a~%\" IT)\n;; :NOTHING))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(batch\n 'some-name)\n\nWhat needs to change: Macro call that should be transformed by BATCH\n\n(batch\n 'some-name)"}, {"role": "assistant", "content": "(defmacro batch (&body forms)\n \"Batch assignments to the values of mutable cells.\n\nThe forms in FORMS are evaluated, in an implicit PROGN, with mutable\ncell assignment batching in effect. This means that when the value of\na mutable cell is set by SETF within the dynamic extent of the BATCH\nform, the observers of the cell are only notified after the last form\nin FORMS is evaluated, or the BATCH form is exited by a non-local exit\nsuch as by RETURN-FROM. The effect of this is that the cells appear to\nhave their values changed simultaneously.\n\n.. note::\n\n When a BATCH form is nested in the dynamic extent of another BATCH\n form, the nested BATCH form has no effect other than to evaluate\n FORMS. The observers of the cells are only notified when exiting\n the outermost BATCH form.\n\nReturns the value of the last form in FORMS.\"\n\n `(if *batch-in-effect-p*\n (progn ,@forms)\n\n (let ((*batch-in-effect-p* t)\n (*batch-list* nil))\n\n (unwind-protect (progn ,@forms)\n (end-batch)))))\n\n;; macroexpand:\n(if *batch-in-effect-p*\n (progn 'some-name)\n (let ((*batch-in-effect-p* t) (*batch-list* nil))\n (unwind-protect (progn 'some-name) (end-batch))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(modf-eval nil :key nil)\n\nIssue: Macro call that should be transformed by MODF-EVAL\n\n(modf-eval nil :key nil)"}, {"role": "assistant", "content": "(defmacro modf-eval (&rest args)\n `(progn ,@args))\n\n;; macroexpand:\n(progn nil :key nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(is-true 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by IS-TRUE\n\n(is-true 'some-name)"}, {"role": "assistant", "content": "(defmacro is-true (condition &rest reason-args)\n \"Like IS this check generates a pass if CONDITION returns true\n and a failure if CONDITION returns false. Unlike IS this check\n does not inspect CONDITION to determine how to report the\n failure.\"\n `(if ,condition\n (add-result 'test-passed :test-expr ',condition)\n (process-failure ',condition\n ,@(or reason-args\n `(\"~S did not return a true value\" ',condition)))))\n\n;; macroexpand:\n(if 'some-name\n (add-result 'test-passed :test-expr ''some-name)\n (process-failure ''some-name \"~S did not return a true value\" ''some-name))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(ignore-errors)\n\nProblem: Macro call that should be transformed by IGNORE-ERRORS\n\n(ignore-errors)"}, {"role": "assistant", "content": "(defmacro IGNORE-ERRORS ...)\n\n;; macroexpand:\n(handler-case (progn) (error (condition) (values nil condition)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(-> nil nil)\n\nProblem: Macro call that should be transformed by ->\n\n(-> nil nil)"}, {"role": "assistant", "content": "(defmacro -> (functions (&rest args) &optional values)\n \"Declaim the ftype of one or multiple FUNCTIONS from ARGS to VALUES.\n\n (-> mod-fixnum+ (fixnum fixnum) fixnum)\n (defun mod-fixnum+ (x y) ...)\n\n (-> (mod-float+ mod-single-float+) (float float) float)\n (defun mod-float+ (x y) ...)\n (defun mode-single-float+ (x y) ...)\"\n `(declaim (ftype (-> (,@args) ,@(when values\n (list values)))\n\t\t ,@(if (consp functions)\n\t\t\t (if (find-symbol (symbol-name (first functions))\n\t\t\t\t\t :cl)\n\t\t\t (list functions)\n\t\t\t functions)\n\t\t\t (list functions)))))\n\n;; macroexpand:\n(declaim (ftype (-> nil) nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(with-properties nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-PROPERTIES\n\n(with-properties nil\n (progn))"}, {"role": "assistant", "content": "(defmacro WITH-PROPERTIES ...)\n\n;; macroexpand:\n(let ((#:g134 (progn)))\n (symbol-macrolet ()))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(dispatch-case nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DISPATCH-CASE\n\n(dispatch-case nil\n nil)"}, {"role": "assistant", "content": "(defmacro dispatch-case ((&rest exprs-and-types) &body clauses)\n \"Dispatch on the types of multiple expressions, exhaustively.\n\nSay you are working on a project where you need to handle timestamps\nrepresented both as universal times, and as instances of\n`local-time:timestamp'. You start by defining the appropriate types:\n\n (defpackage :dispatch-case-example\n (:use :cl :alexandria :serapeum :local-time)\n (:shadow :time))\n \\(in-package :dispatch-case-example)\n\n (deftype universal-time ()\n '(integer 0 *))\n\n (deftype time ()\n '(or universal-time timestamp))\n\nNow you want to write a `time=' function that works on universal\ntimes, timestamps, and any combination thereof.\n\nYou can do this using `etypecase-of':\n\n (defun time= (t1 t2)\n (etypecase-of time t1\n (universal-time\n (etypecase-of time t2\n (universal-time\n (= t1 t2))\n (timestamp\n (= t1 (timestamp-to-universal t2)))))\n (timestamp\n (etypecase-of time t2\n (universal-time\n (time= t2 t1))\n (timestamp\n (timestamp= t1 t2))))))\n\nThis has the advantage of efficiency and exhaustiveness checking, but\nthe serious disadvantage of being hard to read: to understand what\neach branch matches, you have to backtrack to the enclosing branch.\nThis is bad enough when the nesting is only two layers deep.\n\nAlternately, you could do it with `defgeneric':\n\n (defgeneric time= (t1 t2)\n (:method ((t1 integer) (t2 integer))\n (= t1 t2))\n (:method ((t1 timestamp) (t2 timestamp))\n (timestamp= t1 t2))\n (:method ((t1 integer) (t2 timestamp))\n (= t1 (timestamp-to-universal t2)))\n (:method ((t1 timestamp) (t2 integer))\n (time= t2 t1)))\n\nThis is easy to read, but it has three potential disadvantages. \\(1)\nThere is no exhaustiveness checking. If, at some point in the future,\nyou want to add another representation of time to your project, the\ncompiler will not warn you if you forget to update `time='. \\(This is\nbad enough with only two objects to dispatch on, but with three or\nmore it gets rapidly easier to miss a case.) \\(2) You cannot use the\n`universal-time' type you just defined; it is a type, not a class, so\nyou cannot specialize methods on it. \\(3) You are paying a run-time\nprice for extensibility -- the inherent overhead of a generic function\n-- when extensibility is not what you want.\n\nUsing `dispatch-case' instead gives you the readability of\n`defgeneric' with the efficiency and safety of `etypecase-of'.\n\n (defun time= (t1 t2)\n (dispatch-case ((t1 time)\n (t2 time))\n ((universal-time universal-time)\n (= t1 t2))\n ((timestamp timestamp)\n (timestamp= t1 t2))\n ((universal-time timestamp)\n (= t1 (timestamp-to-universal t2)))\n ((timestamp universal-time)\n (time= t2 t1))))\n\nThe syntax of `dispatch-case' is much closer to `defgeneric' than it\nis to `etypecase'. The order in which clauses are defined does not\nmatter, and you can define fallthrough clauses in the same way you\nwould define fallthrough methods in `defgeneric'.\n\nSuppose you wanted to write a `time=' function like the one above, but\nalways convert times to timestamps before comparing them. You could\nwrite that using `dispatch-case' like so:\n\n (defun time= (x y)\n (dispatch-case ((x time)\n (y time))\n ((* universal-time)\n (time= x (universal-to-timestamp y)))\n ((universal-time *)\n (time= (universal-to-timestamp x) y))\n ((timestamp timestamp)\n (timestamp= x y))))\n\n\\(In the list of types, you can use as asterisk as a shorthand for the\ntype of the corresponding argument to `dispatch-case'; in that above,\n`time'.)\n\nNote that this requires only three clauses, where writing it out using\nnested `etypecase-of' forms would require four clauses. This is a\nsmall gain; but with more subtypes to dispatch on, or more objects,\nsuch fallthrough clauses become more useful.\"\n (let ((*gensym-counter* 0))\n `(dispatch-case-let\n ,(loop for (expr type) in exprs-and-types\n for i from 0\n for var = (string-gensym 'arg)\n collect `((,var ,type) ,expr))\n ,@clauses)))\n\n;; macroexpand:\n(dispatch-case-let nil\n nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defpattern nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPATTERN\n\n(defpattern nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro defpattern (name lambda-list &body body)\n \"Defines a derived pattern specifier named NAME. This is analogous\nto DEFTYPE.\n\nExamples:\n\n ;; Defines a LIST pattern.\n (defpattern list (&rest args)\n (when args\n `(cons ,(car args) (list ,@(cdr args)))))\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (pattern-expand-function ',name) (lambda ,lambda-list ,@body))))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (pattern-expand-function 'nil) (lambda :key nil)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(some-<> 'some-name)\n\nPattern to recognize: Macro call that should be transformed by SOME-<>\n\n(some-<> 'some-name)"}, {"role": "assistant", "content": "(defmacro some-<> (init &body exps) (diamond-wand init exps nil t))\n\n;; macroexpand:\n(block #:g129 'some-name)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(enable-punch-syntax)\n\nPattern to recognize: Macro call that should be transformed by ENABLE-PUNCH-SYNTAX\n\n(enable-punch-syntax)"}, {"role": "assistant", "content": "(defmacro enable-punch-syntax ()\n '(eval-when (:compile-toplevel :load-toplevel :execute)\n (cl-syntax:use-syntax punch-syntax)))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (cl-syntax:use-syntax punch-syntax))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(resolving\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by RESOLVING\n\n(resolving\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro RESOLVING ...)\n\n;; macroexpand:\n(resolve\n nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(handler-case nil)\n\nPattern to recognize: Macro call that should be transformed by HANDLER-CASE\n\n(handler-case nil)"}, {"role": "assistant", "content": "(defmacro HANDLER-CASE ...)\n\n;; macroexpand:\n(sb-int:dx-flet ((#:form-fun-261 ()\n (progn nil)))\n (declare (inline #:form-fun-261))\n (block #:block260\n (sb-kernel::%handler-bind nil (return-from #:block260 (#:form-fun-261)))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-foreign-strings nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-FOREIGN-STRINGS\n\n(with-foreign-strings nil\n (progn))"}, {"role": "assistant", "content": "(defmacro with-foreign-strings (bindings &body body)\n \"See WITH-FOREIGN-STRING's documentation.\"\n (if bindings\n `(with-foreign-string ,(first bindings)\n (with-foreign-strings ,(rest bindings)\n ,@body))\n `(progn ,@body)))\n\n;; macroexpand:\n(progn (progn))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(bgo nil)\n\nWrite a macro that addresses: Macro call that should be transformed by BGO\n\n(bgo nil)"}, {"role": "assistant", "content": "(defmacro bgo (msg)\n `(break \"BGO ~a\" ',msg))\n\n;; macroexpand:\n(break \"BGO ~a\" 'nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(continue-whopper)\n\nWhat needs to change: Macro call that should be transformed by CONTINUE-WHOPPER\n\n(continue-whopper)"}, {"role": "assistant", "content": "(defmacro CONTINUE-WHOPPER ...)\n\n;; macroexpand:\n(call-next-method-fn self class-env inst-env mcs%caller mcs%next-methods\n mcs%args)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(infix 'some-name)\n\nIssue: Macro call that should be transformed by INFIX\n\n(infix 'some-name)"}, {"role": "assistant", "content": "(defmacro INFIX ...)\n\n;; macroexpand:\n'some-name"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(c?n-dbg\n 'some-name)\n\nWhat needs to change: Macro call that should be transformed by C?N-DBG\n\n(c?n-dbg\n 'some-name)"}, {"role": "assistant", "content": "(defmacro c?n-dbg (&body body)\n `(make-c-dependent\n :code '(without-c-dependency ,@body)\n :inputp t\n :debug t\n :value-state :unevaluated\n :rule (c-lambda (without-c-dependency ,@body))))\n\n;; macroexpand:\n(make-c-dependent :code\n '(without-c-dependency\n 'some-name)\n :inputp t :debug t :value-state :unevaluated :rule\n (c-lambda\n (without-c-dependency\n 'some-name)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(cond-<>\n nil\n (progn))\n\nIssue: Macro call that should be transformed by COND-<>\n\n(cond-<>\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro COND-<> ...)\n\n;; macroexpand:\n(let* ((#:var136 nil)\n (#:var137\n (if progn\n (-<>\n #:var136)\n #:var136)))\n #:var137)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(export\n common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by EXPORT\n\n(export\n common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro EXPORT ...)\n\n;; macroexpand:\n(common-lisp:progn\n (export\n common-lisp:nil)\n (export\n common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(push-end nil (progn))\n\nPattern to recognize: Macro call that should be transformed by PUSH-END\n\n(push-end nil (progn))"}, {"role": "assistant", "content": "(defmacro push-end (item place &environment env)\n \"Destructively push ITEM to the end of PLACE.\nLike `push', but affects the last item rather than the first.\n\nYou may want to use `enq' on a `queue' instead.\n\nFrom LispWorks.\"\n (multiple-value-bind (dummies vals temps setter getter)\n (get-setf-expansion place env)\n (when (rest temps) (error \"Invalid place for push-end\"))\n (let ((temp (car temps)))\n `(let* (,@(mapcar #'list dummies vals)\n (,temp ,getter))\n (setf ,temp (nconc1 ,temp ,item))\n ,setter))))\n\n;; macroexpand:\n(let* ((#:new301 (progn)))\n (setf #:new301 (nconc1 #:new301 nil))\n (funcall #'(setf progn) #:new301))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-active-layers* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-ACTIVE-LAYERS*\n\n(with-active-layers* nil\n (progn))"}, {"role": "assistant", "content": "(defmacro WITH-ACTIVE-LAYERS* ...)\n\n;; macroexpand:\n(progn (progn))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(cond-<>\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by COND-<>\n\n(cond-<>\n nil\n nil)"}, {"role": "assistant", "content": "(defmacro COND-<> ...)\n\n;; macroexpand:\n(let* ((#:var134 nil)\n (#:var135\n (if nil\n (-<>\n #:var134)\n #:var134)))\n #:var135)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(nest nil nil)\n\nIssue: Macro call that should be transformed by NEST\n\n(nest nil nil)"}, {"role": "assistant", "content": "(defmacro nest (&rest things)\n \"Like ~>>, but backward.\n\nThis is useful when layering `with-x' macros where the order is not\nimportant, and extra indentation would be misleading.\n\nFor example:\n\n (nest\n (with-open-file (in file1 :direction input))\n (with-open-file (in file2 :direction output))\n ...)\n\nIs equivalent to:\n\n (with-open-file (in file1 :direction input)\n (with-open-file (in file2 :direction output)\n ...))\n\n\\(But see `with-open-files').\n\nIf the outer macro has no arguments, you may omit the parentheses.\n\n (nest\n with-standard-io-syntax\n ...)\n \u2261 (with-standard-io-syntax\n ...)\n\nFrom UIOP, based on a suggestion by Marco Baringer.\"\n (expand-nest things))\n\n;; macroexpand:\n(nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(resolving\n nil)\n\nPattern to recognize: Macro call that should be transformed by RESOLVING\n\n(resolving\n nil)"}, {"role": "assistant", "content": "(defmacro RESOLVING ...)\n\n;; macroexpand:\n(resolve\n nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(lambda-cmatch\n 'some-name)\n\nIssue: Macro call that should be transformed by LAMBDA-CMATCH\n\n(lambda-cmatch\n 'some-name)"}, {"role": "assistant", "content": "(defmacro lambda-cmatch (&body body)\n \"Equivalent to (lambda (arg) (cmatch arg BODY...)).\"\n (multiple-value-bind (preamble clauses) (parse-matcher-body body)\n (with-gensyms (clause)\n `(lambda (,clause)\n ,@preamble\n (cmatch ,clause\n ,@clauses)))))\n\n;; macroexpand:\n(common-lisp:lambda (#:clause152)\n (cmatch #:clause152\n 'some-name))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(some-<>> nil nil)\n\nIssue: Macro call that should be transformed by SOME-<>>\n\n(some-<>> nil nil)"}, {"role": "assistant", "content": "(defmacro SOME-<>> ...)\n\n;; macroexpand:\n(let* ((#:g131 nil))\n (if (null #:g131)\n nil\n (->> #:g131 nil)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(all-of 'some-name)\n\nPattern to recognize: Macro call that should be transformed by ALL-OF\n\n(all-of 'some-name)"}, {"role": "assistant", "content": "(defmacro ALL-OF ...)\n\n;; macroexpand:\n(lc ('some-name) always)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(do-instance-combinations 'some-name)\n\nPattern to recognize: Macro call that should be transformed by DO-INSTANCE-COMBINATIONS\n\n(do-instance-combinations 'some-name)"}, {"role": "assistant", "content": "(defmacro DO-INSTANCE-COMBINATIONS ...)\n\n;; macroexpand:\n(do-combinations 'some-name)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(delete-from-plistf nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DELETE-FROM-PLISTF\n\n(delete-from-plistf nil :key nil)"}, {"role": "assistant", "content": "(defmacro DELETE-FROM-PLISTF ...)\n\n;; macroexpand:\n(setq nil (delete-from-plist nil :key nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(collect nil nil)\n\nIssue: Macro call that should be transformed by COLLECT\n\n(collect nil nil)"}, {"role": "assistant", "content": "(defmacro COLLECT ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-591 (generator nil))\n #:items-584\n #:seq-585\n (#:limit-586\n (common-lisp:multiple-value-bind (x y)\n (decode-seq-type (list 'quote nil))\n (declare (ignore x))\n y))\n (#:lst-587 nil))\n (declare (type generator #:generator-591)\n (type (null-or nonnegative-integer) #:limit-586)\n (type list #:lst-587))\n (tagbody\n #:ll-592\n (setq #:items-584 (next-in #:generator-591 (go end)))\n (setq #:lst-587 (cons #:items-584 #:lst-587))\n (go #:ll-592)\n end)\n (common-lisp:let ((num (length #:lst-587)))\n (declare (type nonnegative-integer num))\n (setq #:seq-585 (make-sequence nil (or #:limit-586 num)))\n (do ((i (1- num) (1- i)))\n ((minusp i))\n (setf (elt #:seq-585 i) (pop #:lst-587))))\n #:seq-585)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(ignore-errors nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by IGNORE-ERRORS\n\n(ignore-errors nil (progn))"}, {"role": "assistant", "content": "(defmacro IGNORE-ERRORS ...)\n\n;; macroexpand:\n(handler-case (progn nil (progn)) (error (condition) (values nil condition)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(and-it)\n\nProblem: Macro call that should be transformed by AND-IT\n\n(and-it)"}, {"role": "assistant", "content": "(defmacro and-it (&rest args)\n \"Like AND. IT is bound to the value of the previous AND form.\"\n (cond ((null args) t)\n ((null (cdr args)) (car args))\n (t `(when-it ,(car args) (and-it ,@(cdr args))))))\n\n;; macroexpand:\nt"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(ltbdd-with-new-hash nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by LTBDD-WITH-NEW-HASH\n\n(ltbdd-with-new-hash nil\n nil)"}, {"role": "assistant", "content": "(defmacro LTBDD-WITH-NEW-HASH ...)\n\n;; macroexpand:\n(bdd-call-with-new-hash (lambda () nil) :bdd-node-type\n '(or lisp-type-bdd-node bdd-leaf))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(doquery nil\n (progn))\n\nIssue: Macro call that should be transformed by DOQUERY\n\n(doquery nil\n (progn))"}, {"role": "assistant", "content": "(defmacro doquery (query (&rest names) &body body)\n \"Execute the given query (a string or a list starting with a keyword),\niterating over the rows in the result. The body will be executed with the values\nin the row bound to the symbols given in names. To iterate over a\nparameterised query, one can specify a list whose car is the query, and whose\ncdr contains the arguments. For example:\n\n(doquery (:select 'name 'score :from 'scores) (n s)\n (incf (gethash n *scores*) s))\n\n(doquery ((:select 'name :from 'scores :where (:> 'score '$1)) 100) (name)\n (print name))\"\n (let* ((fields (gensym))\n (query-name (gensym))\n args\n (reader-expr\n `(row-reader (,fields)\n (unless (= ,(length names) (length ,fields))\n (error \"Number of field names does not match number of selected fields in query ~A.\"\n ,query-name))\n (loop :while (next-row)\n :do (let ,(loop :for i :from 0\n :for name :in names\n :collect `(,name (next-field (elt ,fields ,i))))\n ,@body)))))\n (when (and (consp query) (not (keywordp (first query))))\n (setf args (cdr query) query (car query)))\n (if args\n `(let ((,query-name ,(real-query query)))\n (prepare-query *database* \"\" ,query-name (list ,@args))\n (exec-prepared *database* \"\" (list ,@args) ,reader-expr))\n `(let ((,query-name ,(real-query query)))\n (exec-query *database* ,query-name ,reader-expr)))))\n\n;; macroexpand:\n(let ((#:g244 nil))\n (exec-query *database* #:g244\n (row-reader (#:g243)\n (unless (= 1 (length #:g243))\n (error\n \"Number of field names does not match number of selected fields in query ~A.\"\n #:g244))\n (loop :while (next-row)\n :do (let ((progn (next-field (elt #:g243 0)))))))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-capped-stack nil)\n\nProblem: Macro call that should be transformed by WITH-CAPPED-STACK\n\n(with-capped-stack nil)"}, {"role": "assistant", "content": "(defmacro with-capped-stack (() &body body)\n `(stack-capper (lambda () ,@body)))\n\n;; macroexpand:\n(stack-capper (lambda ()))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(make-list common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-LIST\n\n(make-list common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro make-list (cl:&rest forms)\n \"Create a heterogeneous Coalton `List` of objects. This macro is\ndeprecated; use `coalton/list:make`.\"\n (cl:labels\n ((list-helper (forms)\n (cl:if (cl:endp forms)\n `coalton:Nil\n `(coalton:Cons ,(cl:car forms) ,(list-helper (cl:cdr forms))))))\n (list-helper forms)))\n\n;; macroexpand:\n(cons common-lisp:nil nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(pprint-coalton-codegen-types\n common-lisp:nil\n (common-lisp:progn))\n\nPattern to recognize: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-TYPES\n\n(pprint-coalton-codegen-types\n common-lisp:nil\n (common-lisp:progn))"}, {"role": "assistant", "content": "(defmacro PPRINT-COALTON-CODEGEN-TYPES ...)\n\n;; macroexpand:\n(common-lisp:let ((#:package228\n (common-lisp:make-package '#:pprint-codegen-package :use\n '(#:cl))))\n (common-lisp:unwind-protect\n (common-lisp:progn\n (common-lisp:do-symbols\n (coalton-impl/reader::symb common-lisp:*package*)\n (common-lisp:unless\n (common-lisp:nth-value 1\n (common-lisp:find-symbol\n (common-lisp:symbol-name\n coalton-impl/reader::symb)\n #:package228))\n (common-lisp:import coalton-impl/reader::symb #:package228)))\n (common-lisp:let ((common-lisp:*package* #:package228))\n (common-lisp:pprint\n (coalton-codegen-types\n common-lisp:nil\n (common-lisp:progn)))\n (common-lisp:values)))\n (common-lisp:delete-package #:package228)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(export-constructors\n 'some-name)\n\nIssue: Macro call that should be transformed by EXPORT-CONSTRUCTORS\n\n(export-constructors\n 'some-name)"}, {"role": "assistant", "content": "(defmacro EXPORT-CONSTRUCTORS ...)\n\n;; macroexpand:\n'some-name"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(multiple-value-prog2 nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by MULTIPLE-VALUE-PROG2\n\n(multiple-value-prog2 nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro multiple-value-prog2 (first-form second-form &body forms)\n \"Evaluates FIRST-FORM, then SECOND-FORM, and then FORMS. Yields as its value\n all the value returned by SECOND-FORM.\"\n `(progn ,first-form (multiple-value-prog1 ,second-form ,@forms)))\n\n;; macroexpand:\n(progn nil (multiple-value-prog1 :key nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(lambda (quote some-name))\n\nProblem: Macro call that should be transformed by LAMBDA\n\n(lambda (quote some-name))"}, {"role": "assistant", "content": "(defmacro LAMBDA ...)\n\n;; macroexpand:\n#'(lambda (quote some-name))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(acond\n 'some-name)\n\nIssue: Macro call that should be transformed by ACOND\n\n(acond\n 'some-name)"}, {"role": "assistant", "content": "(defmacro acond (&body clauses)\n \"Like COND, except result of each test-form is bound to IT (via LET) for the\nscope of the corresponding clause.\"\n (labels ((rec (clauses)\n\t (if clauses\n\t\t (destructuring-bind ((test &body body) . rest) clauses\n\t\t (if body\n\t\t `(anaphoric if ,test (progn ,@body) ,(rec rest))\n\t\t `(anaphoric if ,test it ,(rec rest))))\n\t\t nil)))\n (rec clauses)))\n\n;; macroexpand:\n(anaphoric if\n quote\n (progn some-name)\n nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(some->)\n\nWrite a macro that addresses: Macro call that should be transformed by SOME->\n\n(some->)"}, {"role": "assistant", "content": "(defmacro SOME-> ...)\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(maxf 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by MAXF\n\n(maxf 'some-name)"}, {"role": "assistant", "content": "(defmacro MAXF ...)\n\n;; macroexpand:\n(let* ((#:some-name223 some-name) (#:new222 (max '#:some-name223)))\n (funcall #'(setf quote) #:new222 #:some-name223))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(fail nil :key nil)\n\nIssue: Macro call that should be transformed by FAIL\n\n(fail nil :key nil)"}, {"role": "assistant", "content": "(defmacro fail (&rest message-args)\n \"Simply generate a FAIL.\"\n `(process-failure ',message-args\n ,@message-args))\n\n;; macroexpand:\n(process-failure '(nil :key nil) nil :key nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(fgathering nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by FGATHERING\n\n(fgathering nil\n nil)"}, {"role": "assistant", "content": "(defmacro FGATHERING ...)\n\n;; macroexpand:\n(flet ()\n nil\n (values))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(mvlet* nil)\n\nProblem: Macro call that should be transformed by MVLET*\n\n(mvlet* nil)"}, {"role": "assistant", "content": "(defmacro mvlet* ((&rest bindings) &body body &environment env)\n \"Expand a series of nested `multiple-value-bind' forms.\n\n`mvlet*' is similar in intent to Scheme\u2019s `let-values', but with a\ndifferent and less parenthesis-intensive syntax. Each binding is a\nlist of\n\n (var var*... expr)\n\nA simple example should suffice to show both the implementation and\nthe motivation:\n\n (defun uptime (seconds)\n (mvlet* ((minutes seconds (truncate seconds 60))\n (hours minutes (truncate minutes 60))\n (days hours (truncate hours 24)))\n (declare ((integer 0 *) days hours minutes seconds))\n (fmt \\\"~d day~:p, ~d hour~:p, ~d minute~:p, ~d second~:p\\\"\n days hours minutes seconds)))\n\nNote that declarations work just like `let*'.\"\n (cond ((null bindings)\n `(locally ,@body))\n ((every #'simple-binding-p bindings)\n `(let* ,bindings ,@body))\n (t (multiple-value-bind (body decls)\n (parse-body body)\n (let* ((bindings (canonicalize-bindings bindings))\n (mvbinds (member-if-not #'simple-binding-p bindings))\n (simple-binds (ldiff bindings mvbinds)))\n (if simple-binds\n (multiple-value-bind (local other)\n (partition-declarations (mapcar #'car simple-binds) decls env)\n `(let* ,simple-binds\n ,@local\n (mvlet* ,mvbinds\n ,@other\n ,@body)))\n (let* ((vars (butlast (car bindings)))\n (expr (lastcar (car bindings))))\n (multiple-value-bind (local other)\n (partition-declarations vars decls env)\n `(multiple-value-bind ,vars\n ,expr\n ,@local\n (mvlet* ,(cdr bindings)\n ,@other\n ,@body))))))))))\n\n;; macroexpand:\n(locally)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(jwhen nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by JWHEN\n\n(jwhen nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro jwhen (test &body body)\n \"JSON-aware version of `cl:when'.\nIf TEST is `jtruep' evaluate BODY.\"\n `(jif ,test\n (progn ,@body)))\n\n;; macroexpand:\n(jif nil (progn :key nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(fm-other? nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FM-OTHER?\n\n(fm-other? nil)"}, {"role": "assistant", "content": "(defmacro fm-other? (md-name &optional (starting 'self) (global-search t))\n `(fm-find-one ,starting ,(if (consp md-name)\n `(list ',(car md-name) ,(cadr md-name))\n `',md-name)\n :must-find nil\n :global-search ,global-search))\n\n;; macroexpand:\n(fm-find-one self 'nil :must-find nil :global-search t)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(instead nil (progn))\n\nPattern to recognize: Macro call that should be transformed by INSTEAD\n\n(instead nil (progn))"}, {"role": "assistant", "content": "(defmacro instead (item parser)\n \"Run some parser, but substitute its inner value with some `item' if parsing was\n successful.\"\n `(<$ ,item ,parser))\n\n;; macroexpand:\n(<$ nil (progn))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(declare-unary-operator nil)\n\nWhat needs to change: Macro call that should be transformed by DECLARE-UNARY-OPERATOR\n\n(declare-unary-operator nil)"}, {"role": "assistant", "content": "(defmacro DECLARE-UNARY-OPERATOR ...)\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (infix-math/data::save-unary-operator 'nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(ps-html nil (progn))\n\nPattern to recognize: Macro call that should be transformed by PS-HTML\n\n(ps-html nil (progn))"}, {"role": "assistant", "content": "(defmacro PS-HTML ...)\n\n;; macroexpand:\n(stringify nil (progn))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(\u0192 nil)\n\nWhat needs to change: Macro call that should be transformed by \u0191\n\n(\u0192 nil)"}, {"role": "assistant", "content": "(defmacro \u0191 ...)\n\n;; macroexpand:\n(defun nil (&optional \u03b1)\n (let ((\u03b1 (or \u03b1 t)))\n (cond)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(wnotrc nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WNOTRC\n\n(wnotrc nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro wnotrc ((&optional (min 1) (max 50) &rest banner) &body body )\n (declare (ignore min max banner))\n `(progn ,@body))\n\n;; macroexpand:\n(progn :key nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(u^ 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by U^\n\n(u^ 'some-name)"}, {"role": "assistant", "content": "(defmacro u^ (type)\n `(upper self ,type))\n\n;; macroexpand:\n(upper self 'some-name)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(scond\n 'some-name)\n\nPattern to recognize: Macro call that should be transformed by SCOND\n\n(scond\n 'some-name)"}, {"role": "assistant", "content": "(defmacro scond (&body clauses)\n \"Like COND, except each test-form is bound to IT (via SYMBOL-MACROLET) for the\nscope of the corresponsing clause. IT can be set with SETF.\"\n (labels ((rec (clauses)\n\t (if clauses\n\t\t (destructuring-bind ((test &body body) . rest) clauses\n\t\t (if body\n\t\t `(symbolic if ,test (progn ,@body) ,(rec rest))\n\t\t `(symbolic if ,test it ,(rec rest))))\n\t\t nil)))\n (rec clauses)))\n\n;; macroexpand:\n(symbolic if quote (progn some-name) nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(caching-types\n nil)\n\nPattern to recognize: Macro call that should be transformed by CACHING-TYPES\n\n(caching-types\n nil)"}, {"role": "assistant", "content": "(defmacro CACHING-TYPES ...)\n\n;; macroexpand:\n(call-with-disjoint-hash\n (lambda ()\n (call-with-subtype-hash\n (lambda ()\n (call-with-equiv-hash\n (lambda () (call-with-subtypep-cache (lambda () nil))))))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(live\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by LIVE\n\n(live\n nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro live (&body forms)\n \"Define a live block consisting of FORMS.\n\nThe FORMS are evaluated once when the LIVE form is first evaluated,\nafter which they are evaluated again whenever the values of the cells\nreferenced by them change. Cells may be referenced either directly in\nFORMS or by a function called during the evaluation of FORMS.\n\nReturns a function which when called, stops the live block. Once\nstopped the live block will no longer be called when the values of the\nreferenced cells change.\"\n\n (let ((spec (make-instance 'watch-function-spec :body forms)))\n (generate-watch-function spec)))\n\n;; macroexpand:\n(let ((#:updating?215 nil)\n (#:waiting-for-change?216 nil)\n (#:arguments220 (make-hash-set)))\n (labels ((#:will-update217 (#:arg221)\n (declare (ignore #:arg221))\n (when (not #:updating?215)\n (setf #:updating?215 t\n #:waiting-for-change?216 nil)))\n (#:update218 (#:arg221 #:did-change222)\n (declare (ignore #:arg221))\n (when\n (or #:updating?215\n (and #:did-change222 #:waiting-for-change?216))\n (setf #:updating?215 nil\n #:waiting-for-change?216 (not #:did-change222))\n (when #:did-change222 (#:watch219))))\n (#:watch219 ()\n (handler-case\n (with-tracker ((#:arg221)\n (unless (memberp #:arg221 #:arguments220)\n (->> (nadjoin #:arg221 #:arguments220)\n (setf #:arguments220))\n (call-add-observer #:arg221\n (make-observer :key '#:g214\n :will-update\n #'#:will-update217\n :update\n #'#:update218))))\n nil\n :key\n nil)\n (condition nil nil)))\n (#:stop223 ()\n (doseq (#:arg221 #:arguments220)\n (call-remove-observer #:arg221\n (make-observer :key '#:g214 :will-update\n #'#:will-update217 :update\n #'#:update218)))\n (clear #:arguments220)\n nil))\n (#:watch219)\n #'#:stop223))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-foreign-objects nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-FOREIGN-OBJECTS\n\n(with-foreign-objects nil\n nil)"}, {"role": "assistant", "content": "(defmacro with-foreign-objects (bindings &body body)\n (if bindings\n `(with-foreign-object ,(car bindings)\n (with-foreign-objects ,(cdr bindings)\n ,@body))\n `(progn ,@body)))\n\n;; macroexpand:\n(progn nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(->> nil nil)\n\nWhat needs to change: Macro call that should be transformed by ->>\n\n(->> nil nil)"}, {"role": "assistant", "content": "(defmacro ->> ...)\n\n;; macroexpand:\n(nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(do-sequences nil\n (progn))\n\nIssue: Macro call that should be transformed by DO-SEQUENCES\n\n(do-sequences nil\n (progn))"}, {"role": "assistant", "content": "(defmacro do-sequences (name/seqs &body forms &environment env)\n \"Iterate over the elements of one or more sequences.\n\n Iteration is performed using the iterator interface, and over\n multiple sequences simultaneously.\n\n The macro arguments can be in one of the following two forms:\n\n 1. (NAME (&REST SEQS) &BODY BODY)\n\n 2. ((&REST SEQS) &BODY BODY)\n\n NAME is a symbol serving as the name of the BLOCK from which the\n forms in BODY can return, using (RETURN-FROM NAME ...). If not\n given defaults to NIL.\n\n Each element of SEQS is a list of the form (VAR SEQUENCE . ARGS),\n where VAR is the variable to which the element of the sequence,\n SEQUENCE, is bound, at each iteration, and ARGS are arguments\n passed to the ITERATOR function, after the sequence.\n\n BODY is a list of forms evaluated at each iteration. RETURN-FROM to\n the block named NAME may be used to terminate the iteration early\n and return a value from the DO-SEQUENCES form. NIL is returned if\n there is no explicit RETURN.\"\n\n (let-if ((name name/seqs)\n (seqs (first forms) name/seqs)\n (forms (rest forms) forms))\n (symbolp name/seqs)\n\n (let ((safety (cadr (assoc 'safety (declaration-information 'optimize env)))))\n `(,(if (> safety 2)\n 'do-sequences-safe%\n 'do-sequences-fast%)\n\n ,name\n ,seqs\n ,@forms))))\n\n;; macroexpand:\n(generic-cl.iterator::do-sequences-fast% nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(xor)\n\nWrite a macro that addresses: Macro call that should be transformed by XOR\n\n(xor)"}, {"role": "assistant", "content": "(defmacro xor (&rest args)\n \"Evaluates the ARGS one at a time. If more than one is T,\n evaluation stops and NIL is returned. If exactly one arg is T,\n that value is returned.\"\n (let ((state (gensym \"XOR-state-\"))\n (block-name (gensym \"XOR-block-\"))\n (arg-temp (gensym \"XOR-arg-temp-\")))\n `(let (,state\n ,arg-temp)\n (block ,block-name\n ,@(loop\n :for arg :in args\n :collect `(setf ,arg-temp ,arg)\n :collect `(when ,arg-temp\n ;; arg is T, this can change the state\n (if ,state\n ;; a second T value, return NIL\n (return-from ,block-name nil)\n ;; a first T, swap the state\n (setf ,state ,arg-temp))))\n (return-from ,block-name ,state)))))\n\n;; macroexpand:\n(let (#:|XOR-state-190| #:|XOR-arg-temp-192|)\n (block #:|XOR-block-191| (return-from #:|XOR-block-191| #:|XOR-state-190|)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(collecting-into 'some-name)\n\nIssue: Macro call that should be transformed by COLLECTING-INTO\n\n(collecting-into 'some-name)"}, {"role": "assistant", "content": "(defmacro COLLECTING-INTO ...)\n\n;; macroexpand:\n(accumulating-to 'some-name)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(print-values\n nil)\n\nPattern to recognize: Macro call that should be transformed by PRINT-VALUES\n\n(print-values\n nil)"}, {"role": "assistant", "content": "(defmacro PRINT-VALUES ...)\n\n;; macroexpand:\n(catch 'succeed\n (for-effects\n (let ((value (progn nil)))\n (print value)\n (unless (y-or-n-p \"Do you want another solution?\")\n (throw 'succeed value)))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(def-dynenv-fun nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEF-DYNENV-FUN\n\n(def-dynenv-fun nil\n nil)"}, {"role": "assistant", "content": "(defmacro DEF-DYNENV-FUN ...)\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (defun nil (&rest #:args) (apply (dynenv-function nil) #:args))\n (defvar #:nil143 (lambda ()))\n (setf (get 'nil 'dynenv-fun) '#:nil143))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(v-defun nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by V-DEFUN\n\n(v-defun nil\n (progn))"}, {"role": "assistant", "content": "(defmacro v-defun (name args &body body)\n `(define-vari-function ,name ,args ,@body))\n\n;; macroexpand:\n(define-vari-function nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(with-special-initargs* nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-SPECIAL-INITARGS*\n\n(with-special-initargs* nil\n nil)"}, {"role": "assistant", "content": "(defmacro WITH-SPECIAL-INITARGS* ...)\n\n;; macroexpand:\n(progn nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(some->> nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by SOME->>\n\n(some->> nil\n (progn))"}, {"role": "assistant", "content": "(defmacro some->> (init &body exps) (arrow-macro init exps t t))\n\n;; macroexpand:\n(block #:g132 (progn (or nil (return-from #:g132 nil))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with-connection nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-CONNECTION\n\n(with-connection nil\n nil)"}, {"role": "assistant", "content": "(defmacro with-connection (spec &body body)\n \"Evaluates the body with *database* bound to a connection as specified by spec,\nwhich should be list that connect can be applied to.\"\n `(let ((*database* (apply #'connect ,spec)))\n (unwind-protect (progn ,@body)\n (disconnect *database*))))\n\n;; macroexpand:\n(let ((*database* (apply #'connect nil)))\n (unwind-protect (progn nil) (disconnect *database*)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(secase nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by SECASE\n\n(secase nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro secase (keyform &body cases)\n \"Like ECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for the\nscope of the cases. IT can be set with SETF.\"\n `(symbolic ecase ,keyform ,@cases))\n\n;; macroexpand:\n(symbolic ecase nil :key nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(fdec 'some-name)\n\nPattern to recognize: Macro call that should be transformed by FDEC\n\n(fdec 'some-name)"}, {"role": "assistant", "content": "(defmacro fdec (place &optional (delta 1))\n \"DEPRECATED: use `shift-decf' instead.\"\n (simple-style-warning \"~s is deprecated, use ~s instead\"\n 'finc 'shift-incf)\n `(shift-decf ,place ,delta))\n\n;; macroexpand:\n(shift-decf 'some-name 1)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(iterate)\n\nPattern to recognize: Macro call that should be transformed by ITERATE\n\n(iterate)"}, {"role": "assistant", "content": "(defmacro ITERATE ...)\n\n;; macroexpand:\n(iter)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(f-plusp nil)\n\nIssue: Macro call that should be transformed by F-PLUSP\n\n(f-plusp nil)"}, {"role": "assistant", "content": "(defmacro f-plusp (key &rest body)\n `(with-synapse ,key (prior-fire-value) \n (let ((new-basis (progn ,@body)))\n (values new-basis (if (xor prior-fire-value (plusp new-basis))\n (progn\n (setf prior-fire-value (plusp new-basis))\n :propagate)\n :no-propagate)))))\n\n;; macroexpand:\n(with-synapse nil\n (prior-fire-value)\n (let ((new-basis (progn)))\n (values new-basis\n (if (xor prior-fire-value (plusp new-basis))\n (progn (setf prior-fire-value (plusp new-basis)) :propagate)\n :no-propagate))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(fm-other? nil nil)\n\nIssue: Macro call that should be transformed by FM-OTHER?\n\n(fm-other? nil nil)"}, {"role": "assistant", "content": "(defmacro fm-other? (md-name &optional (starting 'self) (global-search t))\n `(fm-find-one ,starting ,(if (consp md-name)\n `(list ',(car md-name) ,(cadr md-name))\n `',md-name)\n :must-find nil\n :global-search ,global-search))\n\n;; macroexpand:\n(fm-find-one nil 'nil :must-find nil :global-search t)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(f_\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by F_\n\n(f_\n nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro F_ ...)\n\n;; macroexpand:\n(lambda (_) nil :key nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(ignoring nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by IGNORING\n\n(ignoring nil\n nil)"}, {"role": "assistant", "content": "(defmacro ignoring (type &body body)\n \"DEPRECATED: use `alexandria:ignore-some-conditions' instead.\"\n (simple-style-warning \"~s is deprecated, use ~s instead\"\n 'ignoring 'ignore-some-conditions)\n `(ignore-some-conditions (,type)\n ,@body))\n\n;; macroexpand:\n(ignore-some-conditions (nil)\n nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(loop)\n\nProblem: Macro call that should be transformed by LOOP\n\n(loop)"}, {"role": "assistant", "content": "(defmacro LOOP ...)\n\n;; macroexpand:\n(block nil (tagbody #:g190 (progn) (go #:g190)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-standard-input-syntax\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-STANDARD-INPUT-SYNTAX\n\n(with-standard-input-syntax\n nil)"}, {"role": "assistant", "content": "(defmacro with-standard-input-syntax (&body body)\n \"Like `with-standard-io-syntax', but only bind the variables that\ncontrol the reader, not the printer.\n\nThis may be preferable to using `with-standard-io-syntax' when loading\ndata, as it will not effect how errors are printed, thus preserving\ndebugging information.\"\n (with-thunk ((body :name with-standard-input-syntax))\n `(call/standard-input-syntax ,body)))\n\n;; macroexpand:\n(flet ((#:stack-fn-with-standard-input-syntax1 ()\n nil))\n (declare (dynamic-extent (function #:stack-fn-with-standard-input-syntax1)))\n (symbol-macrolet ((#:stack-fn-with-standard-input-syntax1\n #'#:stack-fn-with-standard-input-syntax1))\n (call/standard-input-syntax #:stack-fn-with-standard-input-syntax1)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(dccase 'some-name)\n\nIssue: Macro call that should be transformed by DCCASE\n\n(dccase 'some-name)"}, {"role": "assistant", "content": "(defmacro dccase (keyform &body clauses)\n \"DCCASE is a combination of CCASE and DESTRUCTURING-BIND.\n KEYFORM must evaluate to a CONS.\n\n Clauses are of the form:\n\n ((CASE-KEYS . DESTRUCTURING-LAMBDA-LIST) FORM*)\n\n The clause whose CASE-KEYS matches CAR of KEY, as if by CCASE,\n is selected, and FORMs are then executed with CDR of KEY is destructured and\n bound by the DESTRUCTURING-LAMBDA-LIST.\"\n (expand-destructuring-case keyform clauses 'ccase))\n\n;; macroexpand:\n(let ((#:key171 'some-name))\n (if (typep #:key171 'cons)\n (ccase (car #:key171))\n (error \"Invalid key to D~S: ~S\" 'ccase #:key171)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(c?1)\n\nIssue: Macro call that should be transformed by C?1\n\n(c?1)"}, {"role": "assistant", "content": "(defmacro c?1 (&body body)\n `(c?once ,@body))\n\n;; macroexpand:\n(c?once)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(mapping)\n\nWhat needs to change: Macro call that should be transformed by MAPPING\n\n(mapping)"}, {"role": "assistant", "content": "(defmacro MAPPING ...)\n\n;; macroexpand:\n(mapping-mac)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(letrec* nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by LETREC*\n\n(letrec* nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro letrec* ((&rest bindings) &body body)\n \"Like LETREC, but the bindings are evaluated in order.\nSee Waddell et al., *Fixing Letrec* for motivation.\n\nCf. `fbindrec*'.\"\n `(letrec-with setq ,bindings\n ,@body))\n\n;; macroexpand:\n(serapeum/binding::letrec-with setq\n nil\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(walk-environment\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WALK-ENVIRONMENT\n\n(walk-environment\n nil\n nil)"}, {"role": "assistant", "content": "(defmacro WALK-ENVIRONMENT ...)\n\n;; macroexpand:\n(progn nil nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(jwhen 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by JWHEN\n\n(jwhen 'some-name)"}, {"role": "assistant", "content": "(defmacro jwhen (test &body body)\n \"JSON-aware version of `cl:when'.\nIf TEST is `jtruep' evaluate BODY.\"\n `(jif ,test\n (progn ,@body)))\n\n;; macroexpand:\n(jif 'some-name (progn))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(local\n nil)\n\nProblem: Macro call that should be transformed by LOCAL\n\n(local\n nil)"}, {"role": "assistant", "content": "(defmacro local (&body orig-body &environment env)\n \"Make internal definitions using top-level definition forms.\n\nWithin `local' you can use top-level definition forms and have them\ncreate purely local definitions, like `let', `labels', and `macrolet':\n\n (fboundp 'plus) ; => nil\n\n (local\n (defun plus (x y)\n (+ x y))\n (plus 2 2))\n ;; => 4\n\n (fboundp 'plus) ; => nil\n\nEach form in BODY is subjected to partial expansion (with\n`macroexpand-1') until either it expands into a recognized definition\nform (like `defun') or it can be expanded no further.\n\n\\(This means that you can use macros that expand into top-level\ndefinition forms to create local definitions.)\n\nJust as at the real top level, a form that expands into `progn' (or an\nequivalent `eval-when') is descended into, and definitions that occur\nwithin it are treated as top-level definitions.\n\n\\(Support for `eval-when' is incomplete: `eval-when' is supported only\nwhen it is equivalent to `progn').\n\nThe recognized definition forms are:\n\n- `def', for lexical variables (as with `letrec')\n- `define-values', for multiple lexical variables at once\n- `defun', for local functions (as with `labels')\n- `defalias', to bind values in the function namespace (like `fbindrec*')\n- `declaim', to make declarations (as with `declare')\n- `defconstant' and `defconst', which behave exactly like symbol macros\n- `define-symbol-macro', to bind symbol macros (as with `symbol-macrolet')\n\nAlso, with serious restrictions, you can use:\n\n- `defmacro', for local macros (as with `macrolet')\n\n\\(Note that the top-level definition forms defined by Common Lisp\nare (necessarily) supplemented by three from Serapeum: `def',\n`define-values', and `defalias'.)\n\nThe exact order in which the bindings are made depends on how `local'\nis implemented at the time you read this. The only guarantees are that\nvariables are bound sequentially; functions can always close over the\nbindings of variables, and over other functions; and macros can be\nused once they are defined.\n\n (local\n (def x 1)\n (def y (1+ x))\n y)\n => 2\n\n (local\n (defun adder (y)\n (+ x y))\n (def x 2)\n (adder 1))\n => 3\n\nPerhaps surprisingly, `let' forms (as well as `let*' and\n`multiple-value-bind') *are* descended into; the only difference is\nthat `defun' is implicitly translated into `defalias'. This means you\ncan use the top-level idiom of wrapping `let' around `defun'.\n\n (local\n (let ((x 2))\n (defun adder (y)\n (+ x y)))\n (adder 2))\n => 4\n\nSupport for macros is sharply limited. (Symbol macros, on the other\nhand, are completely supported.)\n\n1. Macros defined with `defmacro' must precede all other expressions.\n\n2. Macros cannot be defined inside of binding forms like `let'.\n\n3. `macrolet' is not allowed at the top level of a `local' form.\n\nThese restrictions are undesirable, but well justified: it is\nimpossible to handle the general case both correctly and portably, and\nwhile some special cases could be provided for, the cost in complexity\nof implementation and maintenance would be prohibitive.\n\nThe value returned by the `local' form is that of the last form in\nBODY. Note that definitions have return values in `local' just like\nthey do at the top level. For example:\n\n (local\n (plus 2 2)\n (defun plus (x y)\n (+ x y)))\n\nReturns `plus', not 4.\n\nThe `local' macro is loosely based on Racket's support for internal\ndefinitions.\"\n (multiple-value-bind (body decls) (parse-body orig-body)\n (catch 'local\n (generate-internal-definitions\n (make 'internal-definitions-env\n :decls decls\n :env env)\n body))))\n\n;; macroexpand:\n(progn nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(group-by nil)\n\nWhat needs to change: Macro call that should be transformed by GROUP-BY\n\n(group-by nil)"}, {"role": "assistant", "content": "(defmacro group-by (&rest expressions)\n `(apply #'make-clause :group-by ',expressions))\n\n;; macroexpand:\n(apply #'make-clause :group-by '(nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(-> nil (progn))\n\nWhat needs to change: Macro call that should be transformed by ->\n\n(-> nil (progn))"}, {"role": "assistant", "content": "(defmacro -> (value &rest forms)\n \"Smart threading macro that dispatches based on clause types returned by forms.\n\n This macro enables immutable query composition by threading clauses through\n query-state objects. Creates a single copy at the beginning, then destructively\n adds clauses for efficiency. Supports both v1 select-statements and composer query-states.\n\n Forms that evaluate to NIL are skipped, enabling conditional composition:\n (-> (from :users)\n (when active-only (where (:= :active 1)))\n (when sort-by-name (order-by :name)))\n\n Examples:\n ;; With composer clause\n (-> (from :users)\n (where (:= :active 1))\n (order-by :name))\n\n ;; With v1 select-statement (backward compatible)\n (-> (select (:id :name) (from :users))\n (where (:= :active 1))\n (order-by :name))\n\n ;; Conditional composition\n (-> (from :users)\n (when include-inactive (where (:= :active 0)))\n (when sort-by-date (order-by :created_at)))\"\n (a:with-gensyms (threaded-var clause-var)\n `(let* ((,threaded-var ,value)\n ;; Convert to query-state and copy once at the beginning\n (,threaded-var\n (typecase ,threaded-var\n (query-state-base (copy-query-state-immutable ,threaded-var))\n (stmt:select-statement (select-statement-to-query-state ,threaded-var))\n (stmt:insert-into-statement (insert-statement-to-query-state ,threaded-var))\n (stmt:update-statement (update-statement-to-query-state ,threaded-var))\n (stmt:delete-from-statement (delete-statement-to-query-state ,threaded-var))\n (otherwise (add-clause (make-select-query-state) ,threaded-var)))))\n ;; Now destructively add clauses (no more copying), skipping NILs\n ,@(loop for form in forms\n collect `(let ((,clause-var ,(if (listp form)\n ;; For list forms, call the function with its arguments (no threading)\n `(,(car form) ,@(cdr form))\n ;; For symbol forms, call the function with no arguments\n `(,form))))\n (when ,clause-var\n (add-clause ,threaded-var ,clause-var))))\n ,threaded-var)))\n\n;; macroexpand:\n(let* ((#:threaded-var145 nil)\n (#:threaded-var145\n (typecase #:threaded-var145\n (sxql/composer:query-state-base\n (sxql/composer::copy-query-state-immutable #:threaded-var145))\n (select-statement\n (sxql/composer::select-statement-to-query-state #:threaded-var145))\n (insert-into-statement\n (sxql/composer::insert-statement-to-query-state #:threaded-var145))\n (update-statement\n (sxql/composer::update-statement-to-query-state #:threaded-var145))\n (delete-from-statement\n (sxql/composer::delete-statement-to-query-state #:threaded-var145))\n (otherwise\n (add-clause (sxql/composer:make-select-query-state)\n #:threaded-var145)))))\n (let ((#:clause-var146 (progn)))\n (when #:clause-var146 (add-clause #:threaded-var145 #:clause-var146)))\n #:threaded-var145)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(alambda nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by ALAMBDA\n\n(alambda nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro alambda (lambda-list &body body)\n \"Like LAMBDA, except that SELF is bound to the resulting function (via LABELS)\nwithin BODY.\"\n `(labels ((self ,lambda-list ,@body))\n #'self))\n\n;; macroexpand:\n(labels ((self ()\n :key\n nil))\n #'self)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(c?n-dbg\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by C?N-DBG\n\n(c?n-dbg\n nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro c?n-dbg (&body body)\n `(make-c-dependent\n :code '(without-c-dependency ,@body)\n :inputp t\n :debug t\n :value-state :unevaluated\n :rule (c-lambda (without-c-dependency ,@body))))\n\n;; macroexpand:\n(make-c-dependent :code\n '(without-c-dependency\n nil\n :key\n nil)\n :inputp t :debug t :value-state :unevaluated :rule\n (c-lambda\n (without-c-dependency\n nil\n :key\n nil)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(local\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by LOCAL\n\n(local\n nil\n nil)"}, {"role": "assistant", "content": "(defmacro local (&body orig-body &environment env)\n \"Make internal definitions using top-level definition forms.\n\nWithin `local' you can use top-level definition forms and have them\ncreate purely local definitions, like `let', `labels', and `macrolet':\n\n (fboundp 'plus) ; => nil\n\n (local\n (defun plus (x y)\n (+ x y))\n (plus 2 2))\n ;; => 4\n\n (fboundp 'plus) ; => nil\n\nEach form in BODY is subjected to partial expansion (with\n`macroexpand-1') until either it expands into a recognized definition\nform (like `defun') or it can be expanded no further.\n\n\\(This means that you can use macros that expand into top-level\ndefinition forms to create local definitions.)\n\nJust as at the real top level, a form that expands into `progn' (or an\nequivalent `eval-when') is descended into, and definitions that occur\nwithin it are treated as top-level definitions.\n\n\\(Support for `eval-when' is incomplete: `eval-when' is supported only\nwhen it is equivalent to `progn').\n\nThe recognized definition forms are:\n\n- `def', for lexical variables (as with `letrec')\n- `define-values', for multiple lexical variables at once\n- `defun', for local functions (as with `labels')\n- `defalias', to bind values in the function namespace (like `fbindrec*')\n- `declaim', to make declarations (as with `declare')\n- `defconstant' and `defconst', which behave exactly like symbol macros\n- `define-symbol-macro', to bind symbol macros (as with `symbol-macrolet')\n\nAlso, with serious restrictions, you can use:\n\n- `defmacro', for local macros (as with `macrolet')\n\n\\(Note that the top-level definition forms defined by Common Lisp\nare (necessarily) supplemented by three from Serapeum: `def',\n`define-values', and `defalias'.)\n\nThe exact order in which the bindings are made depends on how `local'\nis implemented at the time you read this. The only guarantees are that\nvariables are bound sequentially; functions can always close over the\nbindings of variables, and over other functions; and macros can be\nused once they are defined.\n\n (local\n (def x 1)\n (def y (1+ x))\n y)\n => 2\n\n (local\n (defun adder (y)\n (+ x y))\n (def x 2)\n (adder 1))\n => 3\n\nPerhaps surprisingly, `let' forms (as well as `let*' and\n`multiple-value-bind') *are* descended into; the only difference is\nthat `defun' is implicitly translated into `defalias'. This means you\ncan use the top-level idiom of wrapping `let' around `defun'.\n\n (local\n (let ((x 2))\n (defun adder (y)\n (+ x y)))\n (adder 2))\n => 4\n\nSupport for macros is sharply limited. (Symbol macros, on the other\nhand, are completely supported.)\n\n1. Macros defined with `defmacro' must precede all other expressions.\n\n2. Macros cannot be defined inside of binding forms like `let'.\n\n3. `macrolet' is not allowed at the top level of a `local' form.\n\nThese restrictions are undesirable, but well justified: it is\nimpossible to handle the general case both correctly and portably, and\nwhile some special cases could be provided for, the cost in complexity\nof implementation and maintenance would be prohibitive.\n\nThe value returned by the `local' form is that of the last form in\nBODY. Note that definitions have return values in `local' just like\nthey do at the top level. For example:\n\n (local\n (plus 2 2)\n (defun plus (x y)\n (+ x y)))\n\nReturns `plus', not 4.\n\nThe `local' macro is loosely based on Racket's support for internal\ndefinitions.\"\n (multiple-value-bind (body decls) (parse-body orig-body)\n (catch 'local\n (generate-internal-definitions\n (make 'internal-definitions-env\n :decls decls\n :env env)\n body))))\n\n;; macroexpand:\n(progn nil nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(is nil (progn))\n\nProblem: Macro call that should be transformed by IS\n\n(is nil (progn))"}, {"role": "assistant", "content": "(defmacro is (got expected &rest args)\n (with-gensyms (duration result new-args desc)\n (once-only (expected)\n `(let* ((,new-args (list ,@args))\n (,desc (parse-description-and-test ,new-args)))\n (with-catching-errors (:description ,desc :expected ,expected)\n (with-duration ((,duration ,result) ,got)\n (test ,result ,expected ,new-args\n :duration ,duration)))))))\n\n;; macroexpand:\n(let ((#:expected167 (progn)))\n (let* ((#:new-args165 (list))\n (#:desc166 (prove.test::parse-description-and-test #:new-args165)))\n (prove.test::with-catching-errors (:description #:desc166 :expected\n #:expected167)\n (prove.test::with-duration ((#:duration163 #:result164) nil)\n (prove.test::test #:result164 #:expected167 #:new-args165 :duration\n #:duration163)))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(while nil\n nil)\n\nProblem: Macro call that should be transformed by WHILE\n\n(while nil\n nil)"}, {"role": "assistant", "content": "(defmacro WHILE ...)\n\n;; macroexpand:\n(loop while nil\n do (progn nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(atypecase nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ATYPECASE\n\n(atypecase nil)"}, {"role": "assistant", "content": "(defmacro atypecase (keyform &body cases)\n \"Like TYPECASE, except binds the result of the keyform to IT (via LET) for\nthe scope of the cases.\"\n `(anaphoric typecase ,keyform ,@cases))\n\n;; macroexpand:\n(anaphoric typecase\n nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(collecting 'some-name)\n\nProblem: Macro call that should be transformed by COLLECTING\n\n(collecting 'some-name)"}, {"role": "assistant", "content": "(defmacro COLLECTING ...)\n\n;; macroexpand:\n(with-collector-output (output)\n (dolist (quote (alexandria:ensure-list some-name))\n (restart-case (output (progn))\n (skip nil \"Skip this element\"))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(defsubst nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFSUBST\n\n(defsubst nil\n nil)"}, {"role": "assistant", "content": "(defmacro defsubst (name params &body body)\n \"Define an inline function.\n\n (defsubst fn ...)\n \u2261 (declaim (inline fn))\n (defun fn ...)\n\nThe advantage of a separate defining form for inline functions is that\nyou can't forget to declaim the function inline before defining it \u2013\nwithout which it may not actually end up being inlined.\n\nFrom Emacs and other ancient Lisps.\"\n `(progn\n (declaim (inline ,name))\n (defun ,name ,params\n ,@body)))\n\n;; macroexpand:\n(progn (declaim (inline nil)) (defun nil ()))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(char-ecase nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CHAR-ECASE\n\n(char-ecase nil)"}, {"role": "assistant", "content": "(defmacro char-ecase (keyform &body clauses)\n \"Like `ecase', but specifically for characters.\nExpands into `tree-case'.\"\n `(char-ecase-1 ,keyform\n ,@(expand-char-case-keys clauses)))\n\n;; macroexpand:\n(char-ecase-1 nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(letrec nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by LETREC\n\n(letrec nil\n (progn))"}, {"role": "assistant", "content": "(defmacro LETREC ...)\n\n;; macroexpand:\n(let ()\n (flet ()\n nil\n (setf)\n (progn)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(-<>)\n\nWrite a macro that addresses: Macro call that should be transformed by -<>\n\n(-<>)"}, {"role": "assistant", "content": "(defmacro -<> ...)\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(select 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by SELECT\n\n(select 'some-name)"}, {"role": "assistant", "content": "(defmacro select (keyform &body clauses)\n \"Like `case', but with evaluated keys.\n\nNote that, like `case', `select' interprets a list as the first\nelement of a clause as a list of keys. To use a form as a key, you\nmust add an extra set of parentheses.\n\n (select 2\n ((+ 2 2) t))\n => T\n\n (select 4\n (((+ 2 2)) t))\n => T\n\nFrom Zetalisp.\"\n `(selector ,keyform eql\n ,@clauses))\n\n;; macroexpand:\n(selector 'some-name\n eql)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(quoty nil)\n\nIssue: Macro call that should be transformed by QUOTY\n\n(quoty nil)"}, {"role": "assistant", "content": "(defmacro quoty (item &environment env)\n \"Quote undefined symbols, build functions from unknown lists\"\n (cond ((eql item nil)\n\t (values))\n\t((listp item)\n\t (if (or (listp (first item))\n\t\t (not (fboundp! (first item) env)))\n\t `(function-call\n\t (make-node ,(first item))\n\t (make-nodelist ,(rest item)))\n\t item))\n\t((symbolp item)\n\t (if (vboundp! item env)\n\t item\n\t `',item))\n\t(t item)))\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(-<>> nil)\n\nPattern to recognize: Macro call that should be transformed by -<>>\n\n(-<>> nil)"}, {"role": "assistant", "content": "(defmacro -<>> ...)\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with-live-scope\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITH-LIVE-SCOPE\n\n(with-live-scope\n nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-live-scope (&body body)\n \"Stop all live blocks defined in BODY on exiting the form.\n\nAll live blocks, defined using LIVE, are stopped when exiting the\ndynamic extent defined by this form.\n\nMultiple WITH-LIVE-SCOPE forms can be nested, in which case each form\nstops the live blocks defined immediately within it.\"\n\n (with-gensyms (stoppers forms global-live)\n `(let ((,stoppers nil))\n (macrolet ((,global-live (&body ,forms)\n (macroexpand `(live ,@,forms)))\n\n (live (&body ,forms)\n `(push (,',global-live ,@,forms) ,',stoppers)))\n (unwind-protect (progn ,@body)\n (foreach #'funcall ,stoppers))))))\n\n;; macroexpand:\n(let ((#:stoppers168 nil))\n (macrolet ((#:global-live170 (&body #:forms169)\n (macroexpand\n `(live\n ,@#:forms169)))\n (live (&body #:forms169)\n `(push (,'#:global-live170 ,@#:forms169) ,'#:stoppers168)))\n (unwind-protect (progn nil :key nil) (foreach #'funcall #:stoppers168))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(maybe-once-only nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAYBE-ONCE-ONLY\n\n(maybe-once-only nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro MAYBE-ONCE-ONLY ...)\n\n;; macroexpand:\n(let* ((#:g184 nil))\n `(let* ,(nreverse #:g184)\n ,:key\n ,nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(match nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by MATCH\n\n(match nil\n nil)"}, {"role": "assistant", "content": "(defmacro MATCH ...)\n\n;; macroexpand:\n(match* (nil)\n ((nil)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(modf-fn nil)\n\nProblem: Macro call that should be transformed by MODF-FN\n\n(modf-fn nil)"}, {"role": "assistant", "content": "(defmacro modf-fn (symbol)\n \"Expand to the defined Modf function. Basically, \\(MODF-FN SYM) is the\nfunctional analog of #'\\(SETF SYM).\"\n `(function ,(intern (modf-name symbol) :modf)))\n\n;; macroexpand:\n#'|BUILDER:COMMON-LISP:NIL|"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(defpattern-inline common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by DEFPATTERN-INLINE\n\n(defpattern-inline common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro defpattern-inline (name args &body body)\n \"Adds a new inlined derived pattern. These patterns are evaluated from the innermost ones.\nThe default value of &optional arguments are '_, instead of nil.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (symbol-inline-pattern ',name)\n #+sbcl\n (sb-int:named-lambda ',name ,(process-lambda-args args) ,@body)\n #-sbcl\n (lambda ,(process-lambda-args args) ,@body))\n ,@(when (stringp (first body))\n ;; lisp-namespace\n `((setf (documentation ',name 'inline-pattern)\n ,(let ((*print-pretty* t))\n #-clisp\n (format nil \"~~\n ~:@_Defined in ~a~\n ~:>\"\n (list args (list (first body)) *compile-file-pathname*))\n #+clisp\n (format nil \"Lambda-List: ~s~%~a\"\n args (first body))))))))\n\n;; macroexpand:\n(common-lisp:eval-when (:compile-toplevel :load-toplevel :execute)\n (common-lisp:setf (trivia.level2.impl::symbol-inline-pattern\n 'common-lisp:nil)\n (sb-int:named-lambda 'common-lisp:nil\n common-lisp:nil)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(is-values nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by IS-VALUES\n\n(is-values nil\n (progn))"}, {"role": "assistant", "content": "(defmacro is-values (form &body body)\n (multiple-value-bind (comp-expected expected comparison description format-args)\n (destructure-is-values-body body)\n `(eval-in-context\n *context*\n (make-instance 'multiple-value-comparison-result\n :expression '(is-values ,form ,@comp-expected)\n :value-form ',form\n :body (lambda () ,form)\n :expected (list ,@expected)\n :comparison (list ,@comparison)\n ,@(when description\n `(:description (format NIL ,description ,@format-args)))))))\n\n;; macroexpand:\n(eval-in-context *context*\n (make-instance 'multiple-value-comparison-result :expression\n '(is-values nil\n (progn))\n :value-form 'nil :body (lambda () nil)\n :expected (list nil) :comparison (list 'progn)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(doseq! 'some-name)\n\nWhat needs to change: Macro call that should be transformed by DOSEQ!\n\n(doseq! 'some-name)"}, {"role": "assistant", "content": "(defmacro doseq! (name/seq &body body)\n \"Mutable version of DOSEQ, expanding into DO-SEQUENCES!.\"\n\n (let-if ((name name/seq)\n (seq (first body) name/seq)\n (body (rest body) body))\n (symbolp name/seq)\n\n (destructuring-bind (element sequence &rest args) seq\n `(do-sequences! ,name\n ((,element ,sequence ,@args))\n ,@body))))\n\n;; macroexpand:\n(do-sequences! nil\n ('some-name))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(u^ nil)\n\nPattern to recognize: Macro call that should be transformed by U^\n\n(u^ nil)"}, {"role": "assistant", "content": "(defmacro u^ (type)\n `(upper self ,type))\n\n;; macroexpand:\n(upper self nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with-condition-restarts nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-CONDITION-RESTARTS\n\n(with-condition-restarts nil\n (progn))"}, {"role": "assistant", "content": "(defmacro WITH-CONDITION-RESTARTS ...)\n\n;; macroexpand:\n(let ((#:condition-form168 nil))\n (let ((#:restarts169 (progn)))\n (unwind-protect\n (progn\n (dolist (#:restart170 #:restarts169)\n (push #:condition-form168\n (sb-kernel:restart-associated-conditions #:restart170))))\n (dolist (#:restart170 #:restarts169)\n (pop (sb-kernel:restart-associated-conditions #:restart170))))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(with-type-dispatch nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-TYPE-DISPATCH\n\n(with-type-dispatch nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-type-dispatch ((&rest types) var &body body\n &environment env)\n \"A macro for writing fast sequence functions (among other things).\n\nIn the simplest case, this macro produces one copy of BODY for each\ntype in TYPES, with the appropriate declarations to induce your Lisp\nto optimize that version of BODY for the appropriate type.\n\nSay VAR is a string. With this macro, you can trivially emit optimized\ncode for the different kinds of string that VAR might be. And\nthen (ideally) instead of getting code that dispatches on the type of\nVAR every time you call `aref', you get code that dispatches on the\ntype of VAR once, and then uses the appropriately specialized\naccessors. (But see `with-string-dispatch'.)\n\nBut that's the simplest case. Using `with-type-dispatch' also provides\n*transparent portability*. It examines TYPES to deduplicate types that\nare not distinct on the current Lisp, or that are shadowed by other\nprovided types. And the expansion strategy may differ from Lisp to\nLisp: ideally, you should not have to pay for good performance on\nLisps with type inference with pointless code bloat on other Lisps.\n\nThere is an additional benefit for vector types. Around each version\nof BODY, the definition of `vref' is shadowed to expand into an\nappropriate accessor. E.g., within a version of BODY where VAR is\nknown to be a `simple-string', `vref' expands into `schar'.\n\nUsing `vref' instead of `aref' is obviously useful on Lisps that do\nnot do type inference, but even on Lisps with type inference it can\nspeed compilation times (compiling `aref' is relatively slow on SBCL).\n\nWithin `with-type-dispatch', VAR should be regarded as read-only.\n\nNote that `with-type-dispatch' is intended to be used around\nrelatively expensive code, particularly loops. For simpler code, the\ngains from specialized compilation may not justify the overhead of the\ninitial dispatch and the increased code size.\n\nNote also that `with-type-dispatch' is relatively low level. You may\nwant to use one of the other macros in the same family, such as\n`with-subtype-dispatch', `with-string-dispatch', or so forth.\n\nThe design and implementation of `with-type-dispatch' is based on a\nfew sources. It replaces a similar macro formerly included in\nSerapeum, `with-templated-body'. One possible expansion is based on\nthe `string-dispatch' macro used internally in SBCL. But most of the\ncredit should go to the paper \\\"Fast, Maintable, and Portable Sequence\nFunctions\\\", by Ir\u00e8ne Durand and Robert Strandh.\"\n `(locally (declare #+sbcl (sb-ext:muffle-conditions sb-ext:code-deletion-note))\n ,(let* ((types (simplify-subtypes types))\n (var-type (variable-type var env))\n ;; If the var has a declared type, remove excluded types.\n (types (remove-if-not (lambda (type)\n (subtypep type var-type env))\n types)))\n (cond ((null types)\n `(locally ,@body))\n ((not (speed-matters? env))\n `(locally ,@body))\n ;; The advantage of the CMUCL/SBCL way (I hope) is that the\n ;; compiler can decide /not/ to bother inlining if the type\n ;; is such that it cannot do any meaningful optimization.\n ((or #+(or cmucl sbcl) t)\n ;; Cf. sb-impl::string-dispatch.\n (with-unique-names ((fun type-dispatch-fun))\n `(flet ((,fun (,var)\n (with-read-only-vars (,var)\n ,@body)))\n (declare (inline ,fun))\n (etypecase ,var\n ,@(loop for type in types\n collect `(,type (,fun (truly-the ,type ,var))))))))\n ((or #+ccl t)\n `(with-type-declarations-trusted ()\n (etypecase ,var\n ,@(loop for type in types\n collect `(,type\n (locally (declare (type ,type ,var))\n (with-read-only-vars (,var)\n (with-vref ,type\n ,@body))))))))\n (t\n `(with-type-declarations-trusted ()\n (etypecase ,var\n ,@(loop for type in types\n collect `(,type\n (let ((,var ,var))\n (declare (type ,type ,var))\n (with-read-only-vars (,var)\n (with-vref ,type\n ,@body))))))))))))\n\n;; macroexpand:\n(locally\n (declare (sb-ext:muffle-conditions sb-ext:code-deletion-note))\n (locally nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(iter)\n\nWhat needs to change: Macro call that should be transformed by ITER\n\n(iter)"}, {"role": "assistant", "content": "(defmacro iter (&body body &environment env)\n \"Jonathan Amsterdam's powerful and extensible iteration facility,\nproviding multiple accumulation, generators, memory of previous\niterations, over 50 clauses to start with and a Lisp-like syntax.\nEvaluate (iterate:display-iterate-clauses) for an overview of clauses\"\n (let* ((*env* env)\n\t (*result-var* (genvar 'result))\n\t (*type-alist* nil)\n\t (*declare-variables* *always-declare-variables*)\n\t (*bindings* nil)\n\t (*internal-variables* nil)\n\t (*previous-vars-alist* nil)\n\t (*declarations* nil)\n\t (*loop-body-wrappers* nil)\n\t (*accum-var-alist* nil)\n\t (*shared-bindings-alist* nil)\n\t (*top-level?* t)\n\t (*binding-context?* nil)\n\t (*temps* nil)\n\t (*temps-in-use* nil)\n\t (*driver-info-alist* nil)\n\t (*loop-name* (if (symbolp (car body))\n\t\t\t (car body)\n\t\t\t (gensym \"ITERATE\")))\n\t (*block-name* (if (symbolp (car body))\n\t\t\t (pop body)\n\t\t\t nil))\n\t (*loop-top* (symbol-append 'loop-top- *block-name*))\n\t (*loop-step* (symbol-append 'loop-step- *block-name*))\n\t (*loop-end* (symbol-append 'loop-end- *block-name*))\n\t (*loop-step-used?* nil)\n\t (*loop-end-used?* nil))\n (process-top-level-decls body)\n (multiple-value-bind (body decls init-code steppers final-code final-prot)\n\t(walk-list body)\n (multiple-value-bind (init step)\n\t (insert-previous-code)\n\t(augment init-code init)\n\t(augment steppers step))\n (prepend (default-driver-code) body)\n (let* ((it-bod `(block ,*loop-name*\n\t\t\t(tagbody\n\t\t\t (progn ,.init-code)\n\t\t\t ,*loop-top*\n\t\t\t (progn ,.body)\n\t\t\t ,.(if *loop-step-used?* (list *loop-step*))\n\t\t\t (progn ,.steppers)\n\t\t\t (go ,*loop-top*)\n\t\t\t ,.(if *loop-end-used?* (list *loop-end*))\n\t\t\t (progn ,.final-code))\n\t\t\t,(if (member *result-var* *bindings* :key #'car)\n\t\t\t *result-var*\n\t\t\t nil)))\n\t (it-bod (if (eql *block-name* nil)\n\t\t\t `(block nil ,it-bod)\n\t\t\t it-bod)))\n\t(wrap-form *loop-body-wrappers*\n\t\t `(let* ,(nreverse *bindings*)\n\t\t ,.(if *declarations*\n\t\t\t `((declare .,*declarations*)))\n\t\t ,.decls\n\t\t ,(if final-prot\n\t\t\t `(unwind-protect ,it-bod .,final-prot)\n\t\t\t it-bod)))))))\n\n;; macroexpand:\n(let* ()\n (block nil\n (block nil\n (tagbody (progn) loop-top-nil (progn) (progn) (go loop-top-nil) (progn))\n nil)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(ematch 'some-name)\n\nPattern to recognize: Macro call that should be transformed by EMATCH\n\n(ematch 'some-name)"}, {"role": "assistant", "content": "(defmacro ematch (what &body clauses)\n #.+match-doc+\n (with-gensyms (otherwise)\n `(match2 ,what\n ,@clauses\n (,otherwise (error 'match-error :pattern ',clauses :values (list ,otherwise))))))\n\n;; macroexpand:\n(match2 'some-name\n (#:otherwise146\n (common-lisp:error 'match-error :pattern 'common-lisp:nil :values\n (common-lisp:list #:otherwise146))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(some-<>>)\n\nIssue: Macro call that should be transformed by SOME-<>>\n\n(some-<>>)"}, {"role": "assistant", "content": "(defmacro SOME-<>> ...)\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(export-always nil (progn))\n\nPattern to recognize: Macro call that should be transformed by EXPORT-ALWAYS\n\n(export-always nil (progn))"}, {"role": "assistant", "content": "(defmacro export-always (symbols &optional (package nil package-supplied?))\n \"Like `export', but also evaluated at compile time.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (export ,symbols ,@(and package-supplied? (list package)))))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute) (export nil (progn)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(compiler-macro-lambda nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by COMPILER-MACRO-LAMBDA\n\n(compiler-macro-lambda nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro compiler-macro-lambda (lambda-list &body body)\n (introspect-environment:parse-compiler-macro (gensym \"COMPILER-MACRO-LAMBDA\")\n lambda-list\n body))\n\n;; macroexpand:\n(sb-int:named-lambda (compiler-macro #:compiler-macro-lambda148)\n (#:expr #:env)\n (declare (sb-c::lambda-list nil))\n (declare (ignore #:env))\n (sb-int:named-ds-bind (:macro #:compiler-macro-lambda148\n . define-compiler-macro)\n nil\n (sb-c::compiler-macro-args #:expr)\n (declare (sb-c::constant-value)\n (sb-c::no-compiler-macro #:compiler-macro-lambda148))\n (block #:compiler-macro-lambda148 :key nil)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(options)\n\nProblem: Macro call that should be transformed by OPTIONS\n\n(options)"}, {"role": "assistant", "content": "(defmacro OPTIONS ...)\n\n;; macroexpand:\n#S(options :map nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(defloop nil\n (progn))\n\nProblem: Macro call that should be transformed by DEFLOOP\n\n(defloop nil\n (progn))"}, {"role": "assistant", "content": "(defmacro defloop (name args &body body)\n \"Define a function, ensuring proper tail recursion.\nThis is entirely equivalent to `defun' over `nlet'.\"\n (multiple-value-bind (body decls docstring)\n (parse-body body :documentation t)\n (let ((vars (lambda-list-vars args)))\n `(defun ,name ,args\n ,@(unsplice docstring)\n ,@decls\n (nlet ,name ,(mapcar #'list vars vars)\n (flet ((,name ,args (,name ,@vars)))\n (declare (inline ,name))\n ,@body))))))\n\n;; macroexpand:\n(defun nil (progn)\n (nlet nil\n ((progn progn))\n (flet ((nil (progn)\n (nil progn)))\n (declare (inline nil)))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(fm-collect nil)\n\nProblem: Macro call that should be transformed by FM-COLLECT\n\n(fm-collect nil)"}, {"role": "assistant", "content": "(defmacro fm-collect (md-name &key (must-find t))\n `(fm-find-all self ',md-name :must-find ,must-find))\n\n;; macroexpand:\n(fm-find-all self 'nil :must-find t)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-gensyms nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-GENSYMS\n\n(with-gensyms nil)"}, {"role": "assistant", "content": "(defmacro with-gensyms ((&rest names) &body body)\n \"Provide gensyms for given NAMES.\"\n `(let ,(loop :for n :in names :collect `(,n (gensym)))\n ,@body))\n\n;; macroexpand:\n(let ())"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with-interleaving\n 'some-name)\n\nIssue: Macro call that should be transformed by WITH-INTERLEAVING\n\n(with-interleaving\n 'some-name)"}, {"role": "assistant", "content": "(defmacro with-interleaving (&body body)\n (let* ((root (copy-list (pop body)))\n (current root))\n (dolist (form body root)\n (let ((form (copy-list form)))\n (when form\n (setf (cdr (last current)) (cons form NIL))\n (setf current form))))))\n\n;; macroexpand:\n'some-name"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(with-none-awake nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-NONE-AWAKE\n\n(with-none-awake nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-none-awake ((&key dbg diag) &body body)\n `(call-with-none-awake ,dbg (lambda () ,@body) ,diag))\n\n;; macroexpand:\n(call-with-none-awake nil (lambda () :key nil) nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(pccase nil (progn))\n\nWhat needs to change: Macro call that should be transformed by PCCASE\n\n(pccase nil (progn))"}, {"role": "assistant", "content": "(defmacro pccase (pred keyform &rest clauses)\n \"Like CCASE, but uses given PRED instead of EQL to select appropriate CLAUSE.\n\n Example usage:\n\n CL-USER> (pccase '< 1\n (0 (print \\\"Below zero\\\"))\n (2 (print \\\"OK\\\")))\n\"\n (expand-predicate-case pred keyform clauses 'ccase))\n\n;; macroexpand:\n(let ((#:keyform220 (progn)))\n (cond\n (t\n (cerror \"Return NIL from PCASE\" 'case-failure :datum #:keyform220\n :possibilities 'nil :name 'pccase))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-slots nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-SLOTS\n\n(with-slots nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro WITH-SLOTS ...)\n\n;; macroexpand:\n(let ((#:g180 :key))\n (declare (ignorable #:g180))\n (declare (sb-pcl::%variable-rebinding #:g180 :key))\n (symbol-macrolet ()\n nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(cond->> nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by COND->>\n\n(cond->> nil\n nil)"}, {"role": "assistant", "content": "(defmacro cond->> (init &body exps) (cond-arrow-macro init exps t))\n\n;; macroexpand:\n(-> nil\n (lambda (#:g121)\n (if nil\n (->> #:g121\n nil)\n #:g121)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(~> nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ~>\n\n(~> nil :key nil)"}, {"role": "assistant", "content": "(defmacro ~> (needle &rest holes)\n \"Threading macro from Clojure (by way of Racket).\n\nThread NEEDLE through HOLES, where each hole is either a\nsymbol (equivalent to `(hole needle)`) or a list (equivalent to `(hole\nneedle args...)`).\n\nAs an extension, an underscore in the argument list is replaced with\nthe needle, so you can pass the needle as an argument other than the\nfirst.\"\n (thread-aux '~> needle holes\n (lambda (needle hole)\n (list* (car hole) needle (cdr hole)))))\n\n;; macroexpand:\n(~> (:key nil) nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(atypecase 'some-name)\n\nIssue: Macro call that should be transformed by ATYPECASE\n\n(atypecase 'some-name)"}, {"role": "assistant", "content": "(defmacro atypecase (keyform &body cases)\n \"Like TYPECASE, except binds the result of the keyform to IT (via LET) for\nthe scope of the cases.\"\n `(anaphoric typecase ,keyform ,@cases))\n\n;; macroexpand:\n(anaphoric typecase\n 'some-name)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(defun-ematch* common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by DEFUN-EMATCH*\n\n(defun-ematch* common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro defun-ematch* (name args &body body)\n \"Equivalent to (defun (arg) [decl-and-docstring] (ematch arg (PATTERN BODY...))).\"\n (multiple-value-bind (preamble clauses) (parse-matcher-body body)\n `(defun ,name ,args\n ,@preamble\n (ematch* ,args\n ,@clauses))))\n\n;; macroexpand:\n(common-lisp:defun common-lisp:nil () (ematch* common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(def-unbound-dynenv-fun nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEF-UNBOUND-DYNENV-FUN\n\n(def-unbound-dynenv-fun nil)"}, {"role": "assistant", "content": "(defmacro DEF-UNBOUND-DYNENV-FUN ...)\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (defun nil (&rest #:args) (apply (dynenv-function nil) #:args))\n (defvar #:nil142)\n (setf (get 'nil 'dynenv-fun) '#:nil142))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(f-plusp nil (progn))\n\nWhat needs to change: Macro call that should be transformed by F-PLUSP\n\n(f-plusp nil (progn))"}, {"role": "assistant", "content": "(defmacro f-plusp (key &rest body)\n `(with-synapse ,key (prior-fire-value) \n (let ((new-basis (progn ,@body)))\n (values new-basis (if (xor prior-fire-value (plusp new-basis))\n (progn\n (setf prior-fire-value (plusp new-basis))\n :propagate)\n :no-propagate)))))\n\n;; macroexpand:\n(with-synapse nil\n (prior-fire-value)\n (let ((new-basis (progn (progn))))\n (values new-basis\n (if (xor prior-fire-value (plusp new-basis))\n (progn (setf prior-fire-value (plusp new-basis)) :propagate)\n :no-propagate))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(return 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by RETURN\n\n(return 'some-name)"}, {"role": "assistant", "content": "(defmacro RETURN ...)\n\n;; macroexpand:\n(return-from nil 'some-name)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(defjsmacro nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by DEFJSMACRO\n\n(defjsmacro nil :key nil)"}, {"role": "assistant", "content": "(defmacro DEFJSMACRO ...)\n\n;; macroexpand:\n(defpsmacro nil\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(for-effects\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by FOR-EFFECTS\n\n(for-effects\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro FOR-EFFECTS ...)\n\n;; macroexpand:\n(choice-point (progn nil (progn (progn) (fail))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(fdec nil)\n\nIssue: Macro call that should be transformed by FDEC\n\n(fdec nil)"}, {"role": "assistant", "content": "(defmacro fdec (place &optional (delta 1))\n \"DEPRECATED: use `shift-decf' instead.\"\n (simple-style-warning \"~s is deprecated, use ~s instead\"\n 'finc 'shift-incf)\n `(shift-decf ,place ,delta))\n\n;; macroexpand:\n(shift-decf nil 1)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(remove-from-plistf nil :key nil)\n\nProblem: Macro call that should be transformed by REMOVE-FROM-PLISTF\n\n(remove-from-plistf nil :key nil)"}, {"role": "assistant", "content": "(defmacro REMOVE-FROM-PLISTF ...)\n\n;; macroexpand:\n(setq nil (remove-from-plist nil :key nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(necessarily?\n nil)\n\nWhat needs to change: Macro call that should be transformed by NECESSARILY?\n\n(necessarily?\n nil)"}, {"role": "assistant", "content": "(defmacro NECESSARILY? ...)\n\n;; macroexpand:\n(let ((result t))\n (one-value\n (let ((value (progn nil)))\n (when value (setf result value) (fail))\n value)\n result))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(inext-or-error nil)\n\nWhat needs to change: Macro call that should be transformed by INEXT-OR-ERROR\n\n(inext-or-error nil)"}, {"role": "assistant", "content": "(defmacro INEXT-OR-ERROR ...)\n\n;; macroexpand:\n(let ((vals (multiple-value-list (funcall (i-coro nil) nil))))\n (if (not vals)\n (error 'stop-iteration)\n (values (car vals) t)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(isnt nil (progn))\n\nIssue: Macro call that should be transformed by ISNT\n\n(isnt nil (progn))"}, {"role": "assistant", "content": "(defmacro isnt (got expected &rest args)\n (with-gensyms (duration result new-args desc)\n (once-only (expected)\n `(let* ((,new-args (list ,@args))\n (,desc (parse-description-and-test ,new-args)))\n (with-catching-errors (:description ,desc :expected ,expected)\n (with-duration ((,duration ,result) ,got)\n (test ,result ,expected ,new-args\n :notp t\n :duration ,duration)))))))\n\n;; macroexpand:\n(let ((#:expected219 (progn)))\n (let* ((#:new-args217 (list))\n (#:desc218 (prove.test::parse-description-and-test #:new-args217)))\n (prove.test::with-catching-errors (:description #:desc218 :expected\n #:expected219)\n (prove.test::with-duration ((#:duration215 #:result216) nil)\n (prove.test::test #:result216 #:expected219 #:new-args217 :notp t\n :duration #:duration215)))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(prog* () :key nil)\n\nIssue: Macro call that should be transformed by PROG*\n\n(prog* () :key nil)"}, {"role": "assistant", "content": "(defmacro PROG* ...)\n\n;; macroexpand:\n(block nil\n (let* ()\n (tagbody :key nil)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(eval-and-compile\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by EVAL-AND-COMPILE\n\n(eval-and-compile\n nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro eval-and-compile (&body body)\n \"Emacs's `eval-and-compile'.\nAlias for `eval-always'.\"\n `(eval-always\n ,@body))\n\n;; macroexpand:\n(eval-always\n nil\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(possibly?\n 'some-name)\n\nIssue: Macro call that should be transformed by POSSIBLY?\n\n(possibly?\n 'some-name)"}, {"role": "assistant", "content": "(defmacro POSSIBLY? ...)\n\n;; macroexpand:\n(one-value\n (let ((value (progn 'some-name)))\n (unless value (fail))\n value)\n nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(cond->> nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by COND->>\n\n(cond->> nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro cond->> (init &body exps) (cond-arrow-macro init exps t))\n\n;; macroexpand:\n(-> nil\n (lambda (#:g123)\n (if :key\n (->> #:g123\n nil)\n #:g123)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(destructuring-ccase-of nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DESTRUCTURING-CCASE-OF\n\n(destructuring-ccase-of nil\n nil)"}, {"role": "assistant", "content": "(defmacro destructuring-ccase-of (type keyplace &body body)\n \"Like `destructuring-case-of', but providing a `store-value' restart\nto collect KEYPLACE and try again.\"\n (expand-destructuring-case-of type keyplace body 'ccase-of))\n\n;; macroexpand:\n(let ((#:key274 nil))\n (if (typep #:key274 'cons)\n (ccase-of nil\n (car #:key274))\n (error \"Invalid key to DESTRUCTURING-~S: ~S\" 'ccase-of #:key274)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(pprint-coalton-codegen\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PPRINT-COALTON-CODEGEN\n\n(pprint-coalton-codegen\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro PPRINT-COALTON-CODEGEN ...)\n\n;; macroexpand:\n(common-lisp:let ((#:package218\n (common-lisp:make-package '#:pprint-codegen-package :use\n '(#:cl))))\n (common-lisp:unwind-protect\n (common-lisp:progn\n (common-lisp:do-symbols\n (coalton-impl/reader::symb common-lisp:*package*)\n (common-lisp:unless\n (common-lisp:nth-value 1\n (common-lisp:find-symbol\n (common-lisp:symbol-name\n coalton-impl/reader::symb)\n #:package218))\n (common-lisp:import coalton-impl/reader::symb #:package218)))\n (common-lisp:let ((common-lisp:*package* #:package218))\n (common-lisp:pprint\n (coalton-codegen\n common-lisp:nil))\n (common-lisp:values)))\n (common-lisp:delete-package #:package218)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(drop-view nil)\n\nProblem: Macro call that should be transformed by DROP-VIEW\n\n(drop-view nil)"}, {"role": "assistant", "content": "(defmacro drop-view (view-name)\n `(make-statement :drop-view ,view-name))\n\n;; macroexpand:\n(make-statement :drop-view nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(fm^v 'some-name)\n\nProblem: Macro call that should be transformed by FM^V\n\n(fm^v 'some-name)"}, {"role": "assistant", "content": "(defmacro fm^v (id)\n `(value (fm^ ,id)))\n\n;; macroexpand:\n(value (fm^ 'some-name))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-cached-reader-conditionals\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-CACHED-READER-CONDITIONALS\n\n(with-cached-reader-conditionals\n nil\n nil)"}, {"role": "assistant", "content": "(defmacro WITH-CACHED-READER-CONDITIONALS ...)\n\n;; macroexpand:\n(call-with-cached-reader-conditionals (lambda () nil nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(define-global-var nil nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-GLOBAL-VAR\n\n(define-global-var nil nil)"}, {"role": "assistant", "content": "(defmacro DEFINE-GLOBAL-VAR ...)\n\n;; macroexpand:\n(sb-ext:defglobal nil nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-collectors nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-COLLECTORS\n\n(with-collectors nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-collectors ((&rest collectors) &body body)\n \"Like `with-collector', with multiple collectors.\nReturns the final value of each collector as multiple values.\n\n (with-collectors (x y z)\n (x 1)\n (y 2)\n (z 3))\n => '(1) '(2) '(3)\"\n ;; Warn if there are duplications in COLLECTORS.\n (when (> (length collectors)\n (length (remove-duplicates collectors)))\n (warn \"Duplicated collectors in with-collectors form: ~s\" collectors))\n (with-gensyms (outer)\n `(block ,outer\n ,(reduce (lambda (form collector)\n `(with-collector (,collector)\n ,form))\n collectors\n :initial-value\n `(progn\n ,@body\n (return-from ,outer\n (values ,@(mapcar #'list collectors))))))))\n\n;; macroexpand:\n(block #:outer348 (progn :key nil (return-from #:outer348 (values))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(c?dbg\n nil\n nil)\n\nIssue: Macro call that should be transformed by C?DBG\n\n(c?dbg\n nil\n nil)"}, {"role": "assistant", "content": "(defmacro c?dbg (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :debug t\n :rule (c-lambda ,@body)))\n\n;; macroexpand:\n(make-c-dependent :code '(nil nil) :value-state :unevaluated :debug t :rule\n (c-lambda\n nil\n nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(terminate-producing)\n\nPattern to recognize: Macro call that should be transformed by TERMINATE-PRODUCING\n\n(terminate-producing)"}, {"role": "assistant", "content": "(defmacro TERMINATE-PRODUCING ...)\n\n;; macroexpand:\n(go end)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(define-dispatch nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-DISPATCH\n\n(define-dispatch nil\n (progn))"}, {"role": "assistant", "content": "(defmacro define-dispatch (name lambda-list &body body)\n \"the lambda list should accept two arguments:\nthe list of arguments given by the current method call.\nthe specific hooks (as named or unamed functions) for the qualified method (that we will be dispatching from).\n\nyou should then use the arguments to dispatch the specific hooks as you wish in the body.\nif the body returns a result, by default the method will also return that result, this can be overriden with finalize-dispatch-method.\n\nSee finalize-dispatch-method\nSee dispatch\"\n `(let ((new-dispatch (make-dispatcher (lambda ,lambda-list ,@body))))\n (setf (gethash ',name *dispatch-table*)\n new-dispatch)))\n\n;; macroexpand:\n(let ((new-dispatch (make-dispatcher (lambda (progn)))))\n (setf (gethash 'nil *dispatch-table*) new-dispatch))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(cardinality-case 'some-name)\n\nProblem: Macro call that should be transformed by CARDINALITY-CASE\n\n(cardinality-case 'some-name)"}, {"role": "assistant", "content": "(defmacro CARDINALITY-CASE ...)\n\n;; macroexpand:\n(let ((#:cardinality131 'some-name))\n (typecase #:cardinality131))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(setf)\n\nWhat needs to change: Macro call that should be transformed by SETF\n\n(setf)"}, {"role": "assistant", "content": "(defmacro SETF ...)\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(sunless nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by SUNLESS\n\n(sunless nil\n (progn))"}, {"role": "assistant", "content": "(defmacro sunless (test &body body)\n \"Like UNLESS, except binds the test form to IT (via SYMBOL-MACROLET) for the\nscope of the body. IT can be set with SETF.\"\n `(symbolic unless ,test ,@body))\n\n;; macroexpand:\n(symbolic unless nil (progn))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-first nil (progn))\n\nWhat needs to change: Macro call that should be transformed by COLLECT-FIRST\n\n(collect-first nil (progn))"}, {"role": "assistant", "content": "(defmacro COLLECT-FIRST ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-632 (generator nil))\n #:items-626\n (#:item-628 (progn)))\n (declare (type generator #:generator-632)\n (type (null-or t) #:item-628))\n (tagbody\n #:ll-633\n (setq #:items-626 (next-in #:generator-632 (go end)))\n (setq #:item-628 #:items-626)\n end)\n #:item-628)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(define-test+run-interactively nil\n (progn))\n\nProblem: Macro call that should be transformed by DEFINE-TEST+RUN-INTERACTIVELY\n\n(define-test+run-interactively nil\n (progn))"}, {"role": "assistant", "content": "(defmacro define-test+run-interactively (name &body args-and-body)\n `(progn (define-test ,name ,@args-and-body)\n (eval-when (:execute)\n (values ',name (test ',name :report 'interactive)))))\n\n;; macroexpand:\n(progn\n (define-test nil\n (progn))\n (eval-when (:execute) (values 'nil (test 'nil :report 'interactive))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(ignoring nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IGNORING\n\n(ignoring nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro ignoring (type &body body)\n \"DEPRECATED: use `alexandria:ignore-some-conditions' instead.\"\n (simple-style-warning \"~s is deprecated, use ~s instead\"\n 'ignoring 'ignore-some-conditions)\n `(ignore-some-conditions (,type)\n ,@body))\n\n;; macroexpand:\n(ignore-some-conditions (nil)\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(etypecase-of nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by ETYPECASE-OF\n\n(etypecase-of nil\n (progn))"}, {"role": "assistant", "content": "(defmacro etypecase-of (type x &body body)\n \"Like `etypecase' but, at compile time, warn unless each clause in\nBODY is a subtype of TYPE, and the clauses in BODY form an exhaustive\npartition of TYPE.\"\n (once-only (x)\n `(typecase-of ,type ,x\n ,@body\n (otherwise\n (error 'type-error\n :datum ,x\n :expected-type ',type)))))\n\n;; macroexpand:\n(let ((#:x238 (progn)))\n (typecase-of nil\n #:x238\n (otherwise (error 'type-error :datum #:x238 :expected-type 'nil))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(rem-bops 'some-name)\n\nProblem: Macro call that should be transformed by REM-BOPS\n\n(rem-bops 'some-name)"}, {"role": "assistant", "content": "(defmacro REM-BOPS ...)\n\n;; macroexpand:\n(eval-when (:load-toplevel :compile-toplevel :execute)\n (progn (save-binfix) (mapc 'rmbop '('some-name)) (assign-properties)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defpackage nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPACKAGE\n\n(defpackage nil :key nil)"}, {"role": "assistant", "content": "(defmacro DEFPACKAGE ...)\n\n;; macroexpand:\n(common-lisp:defpackage nil\n (:use :adhoc :closer-mop :cl)\n (:shadowing-import-from :closer-mop\n #:defmethod\n #:standard-generic-function\n #:defgeneric\n #:standard-method\n #:standard-class)\n (:shadowing-import-from :adhoc #:defpackage #:variable #:the)\n :key\n ())"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(collect-plist nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECT-PLIST\n\n(collect-plist nil (progn))"}, {"role": "assistant", "content": "(defmacro COLLECT-PLIST ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-200 (generator (progn)))\n #:values-193\n (#:generator-198 (generator nil))\n #:indicators-192\n (#:plist-194 nil))\n (declare (type generator #:generator-200)\n (type generator #:generator-198)\n (type list #:plist-194))\n (tagbody\n #:ll-201\n (setq #:values-193 (next-in #:generator-200 (go end)))\n (setq #:indicators-192 (next-in #:generator-198 (go end)))\n (setq #:plist-194 (list* #:indicators-192 #:values-193 #:plist-194))\n (go #:ll-201)\n end)\n #:plist-194)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(drop-table 'some-name)\n\nIssue: Macro call that should be transformed by DROP-TABLE\n\n(drop-table 'some-name)"}, {"role": "assistant", "content": "(defmacro drop-table (table &key if-exists)\n `(make-statement :drop-table\n ,(expand-expression table) :if-exists ,if-exists))\n\n;; macroexpand:\n(make-statement :drop-table 'some-name :if-exists nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(xhtml nil :key nil)\n\nProblem: Macro call that should be transformed by XHTML\n\n(xhtml nil :key nil)"}, {"role": "assistant", "content": "(defmacro xhtml (&rest tags)\n `(with-doctype :xhtml\n (tag->string (cons :html ',tags))))\n\n;; macroexpand:\n(with-doctype :xhtml\n (tag->string (cons :html '(nil :key nil))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with-ps-gensyms 'some-name)\n\nIssue: Macro call that should be transformed by WITH-PS-GENSYMS\n\n(with-ps-gensyms 'some-name)"}, {"role": "assistant", "content": "(defmacro WITH-PS-GENSYMS ...)\n\n;; macroexpand:\n(let* ((quote (ps-gensym #A((5) base-char . \"QUOTE\")))\n (some-name (ps-gensym \"SOME-NAME\"))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(cond-<>>\n 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by COND-<>>\n\n(cond-<>>\n 'some-name)"}, {"role": "assistant", "content": "(defmacro COND-<>> ...)\n\n;; macroexpand:\n'some-name"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(fgather-next nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by FGATHER-NEXT\n\n(fgather-next nil (progn))"}, {"role": "assistant", "content": "(defmacro FGATHER-NEXT ...)\n\n;; macroexpand:\n(nil (progn) nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(some-<>> nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by SOME-<>>\n\n(some-<>> nil\n nil)"}, {"role": "assistant", "content": "(defmacro some-<>> (init &body exps) (diamond-wand init exps t t))\n\n;; macroexpand:\n(block #:g146 (nil (or nil (return-from #:g146 nil))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(-<> 'some-name)\n\nIssue: Macro call that should be transformed by -<>\n\n(-<> 'some-name)"}, {"role": "assistant", "content": "(defmacro -<> ...)\n\n;; macroexpand:\n'some-name"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-pointer-to-vector-data 'some-name)\n\nProblem: Macro call that should be transformed by WITH-POINTER-TO-VECTOR-DATA\n\n(with-pointer-to-vector-data 'some-name)"}, {"role": "assistant", "content": "(defmacro with-pointer-to-vector-data ((ptr-var vector) &body body)\n \"Bind 'ptr-var to a foreign pointer to the data in 'vector.\"\n (let ((vector-var (gensym (symbol-name '#:vector))))\n `(let ((,vector-var ,vector))\n (ext:with-pinned-object (,vector-var)\n (let ((,ptr-var (sys:vector-sap ,vector-var)))\n ,@body)))))\n\n;; macroexpand:\n(let ((#:vector142 some-name))\n (declare (type (sb-kernel:simple-unboxed-array (*)) #:vector142))\n (sb-sys:with-pinned-objects (#:vector142)\n (let ((quote (sb-sys:vector-sap #:vector142))))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(while nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WHILE\n\n(while nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro WHILE ...)\n\n;; macroexpand:\n(loop while nil\n do (progn :key nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(do-functions-in-lexenv 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DO-FUNCTIONS-IN-LEXENV\n\n(do-functions-in-lexenv 'some-name)"}, {"role": "assistant", "content": "(defmacro DO-FUNCTIONS-IN-LEXENV ...)\n\n;; macroexpand:\n(block nil\n (iterate-functions-in-lexenv\n (lambda (some-name &key ((:macro? #:g181)) ((:macro-function #:g182)))\n (declare (ignorable #:g181 #:g182)))\n quote :include-macros? nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(next-in 'some-name)\n\nPattern to recognize: Macro call that should be transformed by NEXT-IN\n\n(next-in 'some-name)"}, {"role": "assistant", "content": "(defmacro NEXT-IN ...)\n\n;; macroexpand:\n(do-next-in 'some-name #'(lambda ()))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(compile-$flavor-$methods nil (progn))\n\nProblem: Macro call that should be transformed by COMPILE-$FLAVOR-$METHODS\n\n(compile-$flavor-$methods nil (progn))"}, {"role": "assistant", "content": "(defmacro COMPILE-$FLAVOR-$METHODS ...)\n\n;; macroexpand:\n(eval-when (:load-toplevel) (combine-class-methods nil (progn)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-walker-handler-lexical-environment\n 'some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT\n\n(with-walker-handler-lexical-environment\n 'some-name)"}, {"role": "assistant", "content": "(defmacro WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT ...)\n\n;; macroexpand:\n(block nil\n (bind ((-form- (coerce-to-form -form-)))\n (macrolet ((-lookup- (type name &key (otherwise nil))\n `(walk-environment/find -environment- ,type ,name :otherwise\n ,otherwise))\n (-augment- (type name &optional datum)\n `(walk-environment/augment! -environment- ,type ,name ,datum)))\n (flet ((recurse\n (node &optional (parent -parent-) (environment -environment-))\n (walk-form node :parent parent :environment environment)))\n (declare (ignorable (function recurse)))\n (with-current-form -form-\n 'some-name)))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(do-iter-values nil)\n\nPattern to recognize: Macro call that should be transformed by DO-ITER-VALUES\n\n(do-iter-values nil)"}, {"role": "assistant", "content": "(defmacro do-iter-values ((&rest iters) &body forms)\n \"Iterate over the remaining elements of a sequence pointed to by static iterators.\n\n Evaluate FORMS at each iteration, for each remaining element, until\n one of the iterators reaches the end of the sequence.\n\n NOTE: May only be used inside a WITH-ITERATORS form.\n\n ITERS:\n\n List of bindings. Each element is of the form (PATTERN ITER),\n interpreted as if to WITH-ITER-VALUE, where PATTERN is a binding\n pattern, for the binding to the sequence element value, and ITER\n is a static iterator identifier symbol, introduced in a parent\n WITH-ITERATORS form.\n\n FORMS\n\n List of forms evaluated for each remaining element in the\n sequences pointed to by the static iterators.\n\n At each evaluation the next element of each sequence, pointed by\n each ITER in ITERS, is bound to the variable(s) specified by the\n corresponding PATTERN. After which the iterators are advanced to\n the next elements.\n\n If one of the iterators has reached the end of its sequence, a\n non-local jump outside the enclosing WITH-ITERATORS form is\n performed, i.e. any forms following this form, within the enclosing\n WITH-ITERATORS form, will not be evaluated.\"\n\n (with-gensyms (start)\n `(tagbody\n ,start\n (with-iter-values ,iters ,@forms)\n (go ,start))))\n\n;; macroexpand:\n(tagbody #:start211 (with-iter-values nil) (go #:start211))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(.< common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by .<\n\n(.< common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro .< (cl:&rest items)\n \"Right associative compose operator. Creates a new functions that will run the\nfunctions right to left when applied. This is the same as the `nest` macro without supplying\nthe value. The composition is thus the same order as `compose`.\n\n`(.< f g h)` creates the function `(fn (x) (f (g (h x))))`.\"\n (alexandria:with-gensyms (x)\n `(fn (,x)\n (nest ,@items ,x))))\n\n;; macroexpand:\n(fn (#:x212)\n (nest common-lisp:nil #:x212))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-rules nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-RULES\n\n(with-rules nil\n (progn))"}, {"role": "assistant", "content": "(defmacro WITH-RULES ...)\n\n;; macroexpand:\n(dolist (nil (alexandria:hash-table-keys cl-rules.core::*rules*)) (progn))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(def-kid-slots nil (progn))\n\nIssue: Macro call that should be transformed by DEF-KID-SLOTS\n\n(def-kid-slots nil (progn))"}, {"role": "assistant", "content": "(defmacro def-kid-slots (&rest slot-defs)\n `(lambda (self)\n (declare (ignorable self))\n (list ,@slot-defs)))\n\n;; macroexpand:\n(lambda (self) (declare (ignorable self)) (list nil (progn)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(local*\n nil\n nil)\n\nProblem: Macro call that should be transformed by LOCAL*\n\n(local*\n nil\n nil)"}, {"role": "assistant", "content": "(defmacro local* (&body body)\n \"Like `local', but leave the last form in BODY intact.\n\n (local*\n (defun aux-fn ...)\n (defun entry-point ...))\n =>\n (labels ((aux-fn ...))\n (defun entry-point ...))\"\n `(local\n ,@(butlast body)\n (without-internal-definitions ,@(last body))))\n\n;; macroexpand:\n(local\n nil\n (serapeum/internal-definitions::without-internal-definitions\n nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(without-dependency-capture\n nil\n (progn))\n\nProblem: Macro call that should be transformed by WITHOUT-DEPENDENCY-CAPTURE\n\n(without-dependency-capture\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro WITHOUT-DEPENDENCY-CAPTURE ...)\n\n;; macroexpand:\n(let ((%dependent% nil))\n nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(define-parse-tree-synonym nil nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-PARSE-TREE-SYNONYM\n\n(define-parse-tree-synonym nil nil)"}, {"role": "assistant", "content": "(defmacro define-parse-tree-synonym (name parse-tree)\n \"Defines the symbol NAME to be a synonym for the parse tree\nPARSE-TREE. Both arguments are quoted.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (parse-tree-synonym ',name) ',parse-tree)))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (parse-tree-synonym 'nil) 'nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(local-output\n 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by LOCAL-OUTPUT\n\n(local-output\n 'some-name)"}, {"role": "assistant", "content": "(defmacro LOCAL-OUTPUT ...)\n\n;; macroexpand:\n(progn\n (unless *iscream?*\n (error \"Cannot do LOCAL-OUTPUT unless Screamer is running under~%~\n ILisp/GNUEmacs with iscream.el loaded.\"))\n (trail #'(lambda () (emacs-eval '(pop-end-marker))))\n (emacs-eval '(push-end-marker))\n 'some-name)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(let+ 'some-name)\n\nProblem: Macro call that should be transformed by LET+\n\n(let+ 'some-name)"}, {"role": "assistant", "content": "(defmacro LET+ ...)\n\n;; macroexpand:\n(let ((quote))\n (let ((some-name))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(c-input nil)\n\nProblem: Macro call that should be transformed by C-INPUT\n\n(c-input nil)"}, {"role": "assistant", "content": "(defmacro c-input ((&rest keys) &optional (value nil valued-p))\n `(make-cell\n :inputp t\n :value-state ,(if valued-p :valid :unbound)\n :value ,value\n ,@keys))\n\n;; macroexpand:\n(make-cell :inputp t :value-state :unbound :value nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n;; Recursive factorial - stack overflow on large N in CL\n;; (CL does not guarantee tail-call optimization)\n(defun fact (n)\n (labels ((iter (n acc)\n (if (zerop n)\n acc\n (iter (- n 1) (* n acc)))))\n (iter n 1)))\n;; (fact 1000000) => stack overflow on most implementations\n\nPattern to recognize: Need guaranteed tail-call elimination for recursive algorithms \u2014 CL doesn't mandate TCO\n\n;; Recursive factorial - stack overflow on large N in CL\n;; (CL does not guarantee tail-call optimization)\n(defun fact (n)\n (labels ((iter (n acc)\n (if (zerop n)\n acc\n (iter (- n 1) (* n acc)))))\n (iter n 1)))\n;; (fact 1000000) => stack overflow on most implementations"}, {"role": "assistant", "content": "(defmacro! nlet-tail (n letargs &body body)\n (let ((gs (loop for i in letargs\n collect (gensym))))\n `(macrolet\n ((,n ,gs\n `(progn\n (psetq\n ,@(apply #'nconc\n (mapcar\n #'list\n ',(mapcar #'car letargs)\n (list ,@gs))))\n (go ,',g!n))))\n (block ,g!b\n (let ,letargs\n (tagbody\n ,g!n (return-from\n ,g!b (progn ,@body))))))))\n\n;; macroexpand:\n;; (defun fact (n)\n;; (nlet-tail fact ((n n) (acc 1))\n;; (if (zerop n)\n;; acc\n;; (fact (- n 1) (* acc n)))))\n;;\n;; \"Calling\" (fact ...) expands via macrolet to:\n;; (progn (psetq n (- n 1) acc (* acc n)) (go #:TAG))\n;; = a jump, not a function call. Zero stack consumption."}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(fn nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by FN\n\n(fn nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro FN ...)\n\n;; macroexpand:\n(labels ((nil :key\n nil))\n #'nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(def-suite nil)\n\nPattern to recognize: Macro call that should be transformed by DEF-SUITE\n\n(def-suite nil)"}, {"role": "assistant", "content": "(defmacro def-suite (name &key description in)\n \"Define a new test-suite named NAME.\n\nIN (a symbol), if provided, causes this suite te be nested in the\nsuite named by IN. NB: This macro is built on top of make-suite,\nas such it, like make-suite, will overrwrite any existing suite\nnamed NAME.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (make-suite ',name\n ,@(when description `(:description ,description))\n ,@(when in `(:in ',in)))\n ',name))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute) (make-suite 'nil) 'nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(finc nil)\n\nPattern to recognize: Macro call that should be transformed by FINC\n\n(finc nil)"}, {"role": "assistant", "content": "(defmacro finc (place &optional (delta 1))\n \"DEPRECATED: use `shift-incf' instead.\"\n (simple-style-warning \"~s is deprecated, use ~s instead\"\n 'finc 'shift-incf)\n `(shift-incf ,place ,delta))\n\n;; macroexpand:\n(shift-incf nil 1)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(defmethod* nil nil)\n\nIssue: Macro call that should be transformed by DEFMETHOD*\n\n(defmethod* nil nil)"}, {"role": "assistant", "content": "(defmacro DEFMETHOD* ...)\n\n;; macroexpand:\n(let* ((#:nil125 (ensure-generic*-function 'nil))\n (temp-method (defmethod #:nil124 nil))\n (actual-gf\n (ensure-generic*-function 'nil :lambda-list\n (sb-mop:generic-function-lambda-list\n (symbol-function '#:nil124))\n :special-variables 'nil))\n (actual-method\n (add-method* #:nil125\n (make-instance 'method* :special-variables (list)\n :qualifiers 'nil :specializers\n (sb-mop:method-specializers temp-method)\n :lambda-list\n (sb-mop:method-lambda-list temp-method)\n :documentation\n (documentation temp-method t) :function\n (sb-mop:method-function temp-method)))))\n (declare (ignorable #:nil125)\n (ignore actual-gf))\n (setf (documentation actual-method t) (documentation temp-method t))\n actual-method)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(sum-of nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by SUM-OF\n\n(sum-of nil\n (progn))"}, {"role": "assistant", "content": "(defmacro SUM-OF ...)\n\n;; macroexpand:\n(lc (nil (progn)) sum)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-foreign-strings nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-FOREIGN-STRINGS\n\n(with-foreign-strings nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-foreign-strings (bindings &body body)\n \"See WITH-FOREIGN-STRING's documentation.\"\n (if bindings\n `(with-foreign-string ,(first bindings)\n (with-foreign-strings ,(rest bindings)\n ,@body))\n `(progn ,@body)))\n\n;; macroexpand:\n(progn :key nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(builder nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by BUILDER\n\n(builder nil :key nil)"}, {"role": "assistant", "content": "(defmacro builder (&rest app-or-middlewares)\n (let ((middlewares (butlast app-or-middlewares)))\n `(reduce #'funcall\n (remove-if\n #'null\n (list\n ,@(loop for mw in middlewares\n when mw\n collect (convert-to-middleware-form mw))))\n :initial-value (to-app ,(car (last app-or-middlewares)))\n :from-end t)))\n\n;; macroexpand:\n(reduce #'funcall (remove-if #'null (list (lack/util:find-middleware :key)))\n :initial-value (lack/component:to-app nil) :from-end t)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(def-shadow-type-constructor nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEF-SHADOW-TYPE-CONSTRUCTOR\n\n(def-shadow-type-constructor nil (progn))"}, {"role": "assistant", "content": "(defmacro def-shadow-type-constructor (shadow-type function-identifier)\n (warn 'v-deprecated\n :old 'def-shadow-type-constructor\n :new 'define-shadow-type-constructor)\n `(define-shadow-type-constructor ,shadow-type ,function-identifier))\n\n;; macroexpand:\n(define-shadow-type-constructor nil (progn))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-html-string\n nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-HTML-STRING\n\n(with-html-string\n nil\n nil)"}, {"role": "assistant", "content": "(defmacro with-html-string (&body body)\n \"Like WITH-HTML, but capture the output as a string.\"\n `(with-output-to-string (*html*)\n (with-html ,@body)))\n\n;; macroexpand:\n(with-output-to-string (*html*)\n (with-html\n nil\n nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n;; Exporting closure variables requires building pandoric protocol manually\n(let ((a 0))\n (let ((b 1))\n (let (this self)\n (setq\n this (lambda (n) (incf a n) (setq b (* b n)))\n self (dlambda\n (:pandoric-get (sym)\n (case sym\n ((a) a)\n ((b) b)\n (t (error \"Unknown: ~a\" sym))))\n (:pandoric-set (sym val)\n (case sym\n ((a) (setq a val))\n ((b) (setq b val))))\n (t (&rest args) (apply this args)))))))\n\n;; Manual self construction for every closure is painful\n\nIssue: Need to export closure variables through pandoric protocol, but manually building the self dlambda for each set of variables is repetitive\n\n;; Exporting closure variables requires building pandoric protocol manually\n(let ((a 0))\n (let ((b 1))\n (let (this self)\n (setq\n this (lambda (n) (incf a n) (setq b (* b n)))\n self (dlambda\n (:pandoric-get (sym)\n (case sym\n ((a) a)\n ((b) b)\n (t (error \"Unknown: ~a\" sym))))\n (:pandoric-set (sym val)\n (case sym\n ((a) (setq a val))\n ((b) (setq b val))))\n (t (&rest args) (apply this args)))))))\n\n;; Manual self construction for every closure is painful"}, {"role": "assistant", "content": "(defmacro plambda (largs pargs &rest body)\n (let ((pargs (mapcar #'list pargs)))\n `(let (this self)\n (setq\n this (lambda ,largs ,@body)\n self (dlambda\n (:pandoric-get (sym)\n ,(pandoriclet-get pargs))\n (:pandoric-set (sym val)\n ,(pandoriclet-set pargs))\n (t (&rest args)\n (apply this args)))))))\n\n;; macroexpand:\n;; (let ((a 0))\n;; (let ((b 1))\n;; (plambda (n) (a b)\n;; (incf a n)\n;; (setq b (* b n)))))\n;;\n;; Now:\n;; (with-pandoric (a b) closure\n;; (format t \"a=~a b=~a~%\" a b))\n;; a and b are accessible through the pandoric protocol"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(compiler-macro-lambda 'some-name)\n\nWhat needs to change: Macro call that should be transformed by COMPILER-MACRO-LAMBDA\n\n(compiler-macro-lambda 'some-name)"}, {"role": "assistant", "content": "(defmacro compiler-macro-lambda (lambda-list &body body)\n (introspect-environment:parse-compiler-macro (gensym \"COMPILER-MACRO-LAMBDA\")\n lambda-list\n body))\n\n;; macroexpand:\n(sb-int:named-lambda (compiler-macro #:compiler-macro-lambda149)\n (#:expr #:env)\n (declare (sb-c::lambda-list (quote some-name)))\n (declare (ignore #:env))\n (sb-int:named-ds-bind (:macro #:compiler-macro-lambda149\n . define-compiler-macro)\n 'some-name\n (sb-c::compiler-macro-args #:expr)\n (declare (sb-c::constant-value quote some-name)\n (sb-c::no-compiler-macro #:compiler-macro-lambda149))\n (block #:compiler-macro-lambda149)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(collect-append nil)\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECT-APPEND\n\n(collect-append nil)"}, {"role": "assistant", "content": "(defmacro COLLECT-APPEND ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-207 (generator nil))\n #:items-202\n (#:lst-203 nil)\n (#:list-204 nil))\n (declare (type generator #:generator-207)\n (type list #:lst-203)\n (type list #:list-204))\n (tagbody\n #:ll-208\n (setq #:items-202 (next-in #:generator-207 (go end)))\n (when #:items-202\n (common-lisp:multiple-value-bind (copy lastcons)\n (copy-list-last #:items-202)\n (when #:list-204 (rplacd #:list-204 copy))\n (setq #:list-204 lastcons)\n (when (null #:lst-203) (setq #:lst-203 copy))))\n (go #:ll-208)\n end)\n #:lst-203)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(some-> nil (progn))\n\nProblem: Macro call that should be transformed by SOME->\n\n(some-> nil (progn))"}, {"role": "assistant", "content": "(defmacro SOME-> ...)\n\n;; macroexpand:\n(let* ((#:|some127| nil) (#:|some127| (when #:|some127| (progn #:|some127|))))\n #:|some127|)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(multiple-value-cmatch nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MULTIPLE-VALUE-CMATCH\n\n(multiple-value-cmatch nil\n nil)"}, {"role": "assistant", "content": "(defmacro multiple-value-cmatch (values-form &body clauses)\n \"Same as MULTIPLE-VALUE-MATCH, except a continuable MATCH-ERROR will\nbe raised if none of the clauses match.\"\n (let* ((values (gensym \"VALUES\"))\n (else `(cerror \"Continue.\"\n 'match-error\n :values ,values\n :patterns ',(mapcar #'car clauses))))\n ;; FIXME: remove allocations\n `(let ((,values (multiple-value-list ,values-form)))\n ,(compile-multiple-value-match `(values-list ,values) clauses else))))\n\n;; macroexpand:\n(let ((#:values128 (multiple-value-list nil)))\n (multiple-value-bind nil\n (values-list #:values128)\n (%or (%or nil (fail))\n (cerror \"Continue.\" 'match-error :values #:values128 :patterns\n '(nil)))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(fail nil (progn))\n\nIssue: Macro call that should be transformed by FAIL\n\n(fail nil (progn))"}, {"role": "assistant", "content": "(defmacro fail (form &optional (type 'error) description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(fail ,form ,type)\n :value-form '(capture-error ,form)\n :body (lambda () (capture-error ,form ,(maybe-unquote type)))\n :expected ',(maybe-unquote type)\n :comparison 'typep\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))\n\n;; macroexpand:\n(eval-in-context *context*\n (make-instance 'comparison-result :expression\n '(fail nil (progn)) :value-form\n '(capture-error nil) :body\n (lambda () (capture-error nil (progn)))\n :expected '(progn) :comparison 'typep))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n($slot 'some-name)\n\nProblem: Macro call that should be transformed by $SLOT\n\n($slot 'some-name)"}, {"role": "assistant", "content": "(defmacro $SLOT ...)\n\n;; macroexpand:\n(get-slot 'some-name)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-slots nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-SLOTS\n\n(with-slots nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro WITH-SLOTS ...)\n\n;; macroexpand:\n(let ((#:g243 :key))\n (declare (ignorable #:g243))\n (declare (sb-pcl::%variable-rebinding #:g243 :key))\n (symbol-macrolet ()\n nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(finally)\n\nPattern to recognize: Macro call that should be transformed by FINALLY\n\n(finally)"}, {"role": "assistant", "content": "(defmacro FINALLY ...)\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(who-ps-html)\n\nIssue: Macro call that should be transformed by WHO-PS-HTML\n\n(who-ps-html)"}, {"role": "assistant", "content": "(defmacro WHO-PS-HTML ...)\n\n;; macroexpand:\n(stringify)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(some-<> nil\n (progn))\n\nProblem: Macro call that should be transformed by SOME-<>\n\n(some-<> nil\n (progn))"}, {"role": "assistant", "content": "(defmacro some-<> (init &body exps) (diamond-wand init exps nil t))\n\n;; macroexpand:\n(block #:g127 (progn (or nil (return-from #:g127 nil))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(do-iterator 'some-name)\n\nPattern to recognize: Macro call that should be transformed by DO-ITERATOR\n\n(do-iterator 'some-name)"}, {"role": "assistant", "content": "(defmacro DO-ITERATOR ...)\n\n;; macroexpand:\n(block nil\n (let ((#:g407 (iterator some-name)))\n (unwind-protect\n (loop named #:g410\n for (#:g408 #:g409) = (multiple-value-list\n (iterator-next! #:g407))\n while #:g409\n for quote = #:g408\n do (progn))\n (iterator-finish! #:g407))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(enable-interpol-syntax)\n\nPattern to recognize: Macro call that should be transformed by ENABLE-INTERPOL-SYNTAX\n\n(enable-interpol-syntax)"}, {"role": "assistant", "content": "(defmacro enable-interpol-syntax (&rest %enable-interpol-syntax-args)\n \"Enable CL-INTERPOL reader syntax.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (%enable-interpol-syntax ,@%enable-interpol-syntax-args)))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (%enable-interpol-syntax))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(jand nil :key nil)\n\nIssue: Macro call that should be transformed by JAND\n\n(jand nil :key nil)"}, {"role": "assistant", "content": "(defmacro jand (&rest args)\n \"JSON-aware version of `cl:and'.\"\n `(and ,@(loop for arg in args\n collecting `(jwhen ,arg ,arg))))\n\n;; macroexpand:\n(and\n (jwhen nil\n nil)\n (jwhen :key\n :key)\n (jwhen nil\n nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(-<> nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by -<>\n\n(-<> nil nil)"}, {"role": "assistant", "content": "(defmacro -<> ...)\n\n;; macroexpand:\n(nil nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(defvar nil)\n\nProblem: Macro call that should be transformed by DEFVAR\n\n(defvar nil)"}, {"role": "assistant", "content": "(defmacro DEFVAR ...)\n\n;; macroexpand:\n(progn\n (eval-when (:compile-toplevel) (sb-impl::%compiler-defvar 'nil))\n (sb-impl::%defvar 'nil (sb-c:source-location)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(let-match* common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by LET-MATCH*\n\n(let-match* common-lisp:nil\n (common-lisp:progn))"}, {"role": "assistant", "content": "(defmacro let-match* (bindings &body body)\n \"Similar to LET-MATCH but matches sequentially.\"\n (reduce (lambda (binding form) `(let-match (,binding) ,form))\n bindings\n :from-end t\n :initial-value `(locally ,.body)))\n\n;; macroexpand:\n(common-lisp:locally (common-lisp:progn))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(iter)\n\nProblem: Macro call that should be transformed by ITER\n\n(iter)"}, {"role": "assistant", "content": "(defmacro iter (&body body &environment env)\n \"Jonathan Amsterdam's powerful and extensible iteration facility,\nproviding multiple accumulation, generators, memory of previous\niterations, over 50 clauses to start with and a Lisp-like syntax.\nEvaluate (iter:display-iter-clauses) for an overview of clauses.\"\n (let* ((*env* env)\n (*result-var* (genvar 'result))\n (*type-alist* nil)\n (*declare-variables* *always-declare-variables*)\n (*bindings* nil)\n (*internal-variables* nil)\n (*previous-vars-alist* nil)\n (*declarations* nil)\n (*loop-body-wrappers* nil)\n (*accum-var-alist* nil)\n (*shared-bindings-alist* nil)\n (*top-level?* t)\n (*declaration-context?* nil)\n (*temps* nil)\n (*temps-in-use* nil)\n (*driver-info-alist* nil)\n (*block-name* (when (symbolp (car body))\n (pop body)))\n (*loop-top* (ensure-symbol *block-name* :format \"loop-top-~a\"))\n (*loop-step* (ensure-symbol *block-name* :format \"loop-step-~a\"))\n (*loop-end* (ensure-symbol *block-name* :format \"loop-end-~a\"))\n (*loop-step-used?* nil)\n (*loop-end-used?* nil))\n (process-top-level-decls body)\n (multiple-value-bind (body decls init-code steppers final-code final-prot)\n (walk-list body)\n (multiple-value-bind (init step)\n (insert-previous-code)\n (augment init-code init)\n (augment steppers step)\n (prepend (default-driver-code) body)\n (let ((it-bod `(block ,*block-name*\n (tagbody\n ,.init-code\n ,*loop-top*\n ,.body\n ,.(when *loop-step-used?* (list *loop-step*))\n ,.steppers\n (go ,*loop-top*)\n ,.(when *loop-end-used?* (list *loop-end*))\n ,.final-code)\n ,(if (member *result-var* *bindings* :key #'car)\n *result-var*\n nil))))\n (wrap-form *loop-body-wrappers*\n `(let* ,(nreverse *bindings*)\n ,.(if *declarations*\n `((declare .,*declarations*)))\n ,.decls\n ,(if final-prot\n `(unwind-protect ,it-bod .,final-prot)\n it-bod))))))))\n\n;; macroexpand:\n(let* ()\n (block nil (tagbody loop-top-nil (go loop-top-nil)) nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(defmd nil (progn))\n\nIssue: Macro call that should be transformed by DEFMD\n\n(defmd nil (progn))"}, {"role": "assistant", "content": "(defmacro defmd (class superclasses &rest mdspec)\n `(defmodel ,class (,@superclasses model)\n ,@(let (definitargs class-options slots)\n (loop with skip\n for (spec next) on mdspec\n if skip\n do (setf skip nil)\n else do (etypecase spec\n (cons\n (cond\n ((keywordp (car spec))\n (assert (find (car spec) '(:documentation :metaclass)))\n (push spec class-options))\n ((find (cadr spec) '(:initarg :type :ps :persistable :cell :initform :allocation :reader :writer :accessor :documentation))\n (push (apply 'defmd-canonicalize-slot spec) slots))\n (t ;; shortform (slotname initform &rest slotdef-key-values)\n (push (apply 'defmd-canonicalize-slot\n (list* (car spec) :initform (cadr spec) (cddr spec))) slots))))\n (keyword\n (setf definitargs (append definitargs (list spec next)))\n (setf skip t))\n (symbol (push (list spec :initform nil\n :initarg (intern (symbol-name spec) :keyword)\n :accessor spec) slots)))\n finally\n (return (list* (nreverse slots)\n (delete nil\n (list* `(:default-initargs ,@definitargs)\n (nreverse class-options)))))))))\n\n;; macroexpand:\n(defmodel nil (progn model) nil (:default-initargs))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(define-simple-type-map nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-SIMPLE-TYPE-MAP\n\n(define-simple-type-map nil (progn))"}, {"role": "assistant", "content": "(defmacro define-simple-type-map (class type)\n `(defmethod type ((,class ,class))\n ',type))\n\n;; macroexpand:\n(defmethod type ((nil nil)) '(progn))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(aif nil (progn))\n\nIssue: Macro call that should be transformed by AIF\n\n(aif nil (progn))"}, {"role": "assistant", "content": "(defmacro AIF ...)\n\n;; macroexpand:\n(let ((it nil))\n (if it\n (progn)\n nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(c?n-dbg\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by C?N-DBG\n\n(c?n-dbg\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro c?n-dbg (&body body)\n `(make-c-dependent\n :code '(without-c-dependency ,@body)\n :inputp t\n :debug t\n :value-state :unevaluated\n :rule (c-lambda (without-c-dependency ,@body))))\n\n;; macroexpand:\n(make-c-dependent :code\n '(without-c-dependency\n nil\n (progn))\n :inputp t :debug t :value-state :unevaluated :rule\n (c-lambda\n (without-c-dependency\n nil\n (progn))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(when nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WHEN\n\n(when nil :key nil)"}, {"role": "assistant", "content": "(defmacro WHEN ...)\n\n;; macroexpand:\n(if nil\n (progn :key nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(when-match common-lisp:nil\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by WHEN-MATCH\n\n(when-match common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro when-match (pattern arg &body body)\n \"Equivalent to (match ARG (PATTERN BODY...)).\"\n `(match ,arg (,pattern ,.body)))\n\n;; macroexpand:\n(match common-lisp:nil\n (common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(is-values nil nil)\n\nPattern to recognize: Macro call that should be transformed by IS-VALUES\n\n(is-values nil nil)"}, {"role": "assistant", "content": "(defmacro is-values (got expected &rest args)\n `(is (multiple-value-list ,got) ,expected ,@args))\n\n;; macroexpand:\n(is (multiple-value-list nil) nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(dynamic-extent common-lisp:nil)\n\nIssue: Macro call that should be transformed by DYNAMIC-EXTENT\n\n(dynamic-extent common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro DYNAMIC-EXTENT ...)\n\n;; macroexpand:\n'(common-lisp:declare (common-lisp:dynamic-extent))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(cmatch* common-lisp:nil)\n\nProblem: Macro call that should be transformed by CMATCH*\n\n(cmatch* common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro cmatch* (whats &body clauses)\n #.+match*-doc+ \n (let ((temps (make-gensyms whats \"OTHERWISE\")))\n `(match2* ,whats\n ,@clauses\n (,temps\n (cerror \"continue\" 'match-error :pattern ',clauses :values (list ,@temps))))))\n\n;; macroexpand:\n(match2* common-lisp:nil\n (common-lisp:nil\n (common-lisp:cerror \"continue\" 'match-error :pattern 'common-lisp:nil\n :values (common-lisp:list))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(char-case 'some-name)\n\nIssue: Macro call that should be transformed by CHAR-CASE\n\n(char-case 'some-name)"}, {"role": "assistant", "content": "(defmacro char-case (keyform &body clauses)\n \"Like `case', but specifically for characters.\nExpands into `tree-case'.\n\nAs an extension to the generalized `case' syntax, the keys of a clause\ncan be specified as a literal string.\n\n (defun vowel? (c)\n (char-case c\n (\\\"aeiouy\\\" t)))\n\nSignals an error if KEYFORM does not evaluate to a character.\"\n `(char-case-1 ,keyform\n ,@(expand-char-case-keys clauses)))\n\n;; macroexpand:\n(char-case-1 'some-name)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-hash-table-iterator 'some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-HASH-TABLE-ITERATOR\n\n(with-hash-table-iterator 'some-name)"}, {"role": "assistant", "content": "(defmacro WITH-HASH-TABLE-ITERATOR ...)\n\n;; macroexpand:\n(let* ((#:kvv (sb-impl::hash-table-pairs some-name))\n (#:limit\n (common-lisp:1+\n (common-lisp:* 2 (sb-impl::kv-vector-high-water-mark #:kvv))))\n (#:index 3))\n (declare (fixnum #:index))\n (sb-int:dx-flet ((#:thunk ()\n (loop\n (when (common-lisp:> #:index #:limit)\n (return (values t nil nil)))\n (let ((sb-impl::i #:index))\n (common-lisp:incf\n (sb-ext:truly-the sb-int:index #:index) 2)\n (let ((sb-impl::k\n (sb-kernel:data-vector-ref #:kvv\n (common-lisp:1-\n sb-impl::i)))\n (sb-impl::v\n (sb-kernel:data-vector-ref #:kvv sb-impl::i)))\n (unless\n (or (sb-impl::empty-ht-slot-p sb-impl::k)\n (sb-impl::empty-ht-slot-p sb-impl::v))\n (return (values nil sb-impl::k sb-impl::v))))))))\n (macrolet ((quote nil\n '(multiple-value-bind (common-lisp:endp sb-impl::k sb-impl::v)\n (#:thunk)\n (unless common-lisp:endp\n (values t sb-impl::k sb-impl::v))))))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(define-type-dispatch nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-TYPE-DISPATCH\n\n(define-type-dispatch nil\n nil)"}, {"role": "assistant", "content": "(defmacro DEFINE-TYPE-DISPATCH ...)\n\n;; macroexpand:\n(progn\n (defun nil ()\n (declare (optimize speed (debug 1) (safety 1) (compilation-speed 0)))\n (etypecase nil))\n (sb-c:defknown nil\n nil\n (or)\n (sb-c:any)\n :overwrite-fndb-silently\n t))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(lambda-cmatch*)\n\nIssue: Macro call that should be transformed by LAMBDA-CMATCH*\n\n(lambda-cmatch*)"}, {"role": "assistant", "content": "(defmacro lambda-cmatch* (&body body)\n \"Equivalent to (lambda (args...) (cmatch* (args...) BODY...)).\"\n (multiple-value-bind (preamble clauses) (parse-matcher-body body)\n (let ((gensyms (make-gensyms (caar clauses))))\n `(lambda ,gensyms\n ,@preamble\n (cmatch* ,gensyms\n ,@clauses)))))\n\n;; macroexpand:\n(common-lisp:lambda () (cmatch* common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(do-instance-combinations nil)\n\nWhat needs to change: Macro call that should be transformed by DO-INSTANCE-COMBINATIONS\n\n(do-instance-combinations nil)"}, {"role": "assistant", "content": "(defmacro DO-INSTANCE-COMBINATIONS ...)\n\n;; macroexpand:\n(do-combinations nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(alet 'some-name)\n\nIssue: Macro call that should be transformed by ALET\n\n(alet 'some-name)"}, {"role": "assistant", "content": "(defmacro alet (form &body body)\n \"Binds the FORM to IT (via LET) in the scope of the BODY.\"\n `(anaphoric ignore-first ,form (progn ,@body)))\n\n;; macroexpand:\n(anaphoric ignore-first\n 'some-name\n (progn))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(with-synapse nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-SYNAPSE\n\n(with-synapse nil\n nil)"}, {"role": "assistant", "content": "(defmacro with-synapse (synapse-id (&rest closure-vars) &body body)\n (let ((syn-id (gensym)))\n `(let* ((,syn-id ,synapse-id)\n (synapse (or (find ,syn-id (cd-useds *depender*) :key 'c-slot-name)\n (let ((new-syn\n (let (,@closure-vars)\n (make-c-dependent\n :model (c-model *depender*)\n :slot-name ,syn-id\n :code ',body\n :synaptic t\n :rule (c-lambda ,@body)))))\n (record-caller new-syn)\n new-syn))))\n (prog1\n (multiple-value-bind (v p)\n (with-integrity ()\n (ensure-value-is-current synapse :synapse *depender*))\n (values v p))\n (record-caller synapse)))))\n\n;; macroexpand:\n(let* ((#:g175 nil)\n (synapse\n (or (find #:g175 (cd-useds *depender*) :key 'c-slot-name)\n (let ((new-syn\n (let ()\n (make-c-dependent :model (c-model *depender*) :slot-name\n #:g175 :code 'nil :synaptic t :rule\n (c-lambda)))))\n (record-caller new-syn)\n new-syn))))\n (prog1\n (multiple-value-bind (v p)\n (with-integrity nil\n (ensure-value-is-current synapse :synapse\n *depender*))\n (values v p))\n (record-caller synapse)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(eval-always\n 'some-name)\n\nPattern to recognize: Macro call that should be transformed by EVAL-ALWAYS\n\n(eval-always\n 'some-name)"}, {"role": "assistant", "content": "(defmacro eval-always (&body body)\n \"Wrap BODY in eval-when with all keys (compile, load and execute) mentioned.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n ,@body))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute) 'some-name)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(special common-lisp:nil\n (common-lisp:progn))\n\nPattern to recognize: Macro call that should be transformed by SPECIAL\n\n(special common-lisp:nil\n (common-lisp:progn))"}, {"role": "assistant", "content": "(defmacro SPECIAL ...)\n\n;; macroexpand:\n(cl-annot-revisit-at-macro::add-declaration (common-lisp:special)\n (common-lisp:progn))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(remove-from-plistf nil nil)\n\nIssue: Macro call that should be transformed by REMOVE-FROM-PLISTF\n\n(remove-from-plistf nil nil)"}, {"role": "assistant", "content": "(defmacro REMOVE-FROM-PLISTF ...)\n\n;; macroexpand:\n(setq nil (remove-from-plist nil nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(match-of nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by MATCH-OF\n\n(match-of nil\n (progn))"}, {"role": "assistant", "content": "(defmacro match-of (union expr &body clauses &environment env)\n \"Do pattern matching on an algebraic data type.\n\nUNION should be an algebraic data type.\n\nEach clause in CLAUSES has a pattern as its first element.\n\nIf the pattern is a symbol, it matches a unit type.\n\nIf the pattern is a list, it matches a constructor.\n\nIf the pattern is an underscore, it introduces a default or\nfallthrough clause.\n\nIf the pattern is a list that starts with `or', it is a disjunction of\nother patterns.\"\n (check-match-exhaustive union clauses env)\n `(ematch ,expr\n ,@(loop for (pattern . body) in clauses\n collect `(,(nth-value 1 (pattern-type pattern union))\n ,@body))))\n\n;; macroexpand:\n(ematch (progn))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(c-in-lazy\n 'some-name)\n\nWhat needs to change: Macro call that should be transformed by C-IN-LAZY\n\n(c-in-lazy\n 'some-name)"}, {"role": "assistant", "content": "(defmacro c-in-lazy (&body body)\n `(c-input (:lazy :once-asked) (progn ,@body)))\n\n;; macroexpand:\n(c-input (:lazy :once-asked) (progn 'some-name))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-string-dispatch nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-STRING-DISPATCH\n\n(with-string-dispatch nil\n nil)"}, {"role": "assistant", "content": "(defmacro with-string-dispatch ((&rest types) var &body body)\n \"Like `with-subtype-dispatch' with an overall type of `string'.\"\n `(with-subtype-dispatch string\n ;; Always specialize for (simple-array character (*)).\n ((simple-array character (*))\n (simple-array base-char (*))\n ,@types)\n ,var\n ,@body))\n\n;; macroexpand:\n(with-subtype-dispatch string\n ((simple-array character (*)) (simple-array base-char (*)))\n nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(match2 common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by MATCH2\n\n(match2 common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro match2 (what &body clauses)\n \"In match2/match2*, the last clause is not enclosed in a block.\nTherefore, using `next' in the last clause results in jumping to the next innermost matching construct,\nor results in a compilation error when this is the outermost matching construct.\"\n `(match2+ ,what t ,@clauses))\n\n;; macroexpand:\n(match2+ common-lisp:nil\n common-lisp:t\n common-lisp:nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(ftype 'some-name)\n\nWhat needs to change: Macro call that should be transformed by FTYPE\n\n(ftype 'some-name)"}, {"role": "assistant", "content": "(defmacro FTYPE ...)\n\n;; macroexpand:\n(common-lisp:progn\n (common-lisp:declaim (common-lisp:ftype (common-lisp:quote some-name)))\n '(common-lisp:declare (common-lisp:ftype (common-lisp:quote some-name))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(cond-it)\n\nWrite a macro that addresses: Macro call that should be transformed by COND-IT\n\n(cond-it)"}, {"role": "assistant", "content": "(defmacro cond-it (&body body)\n \"Like COND. IT is bound to the passed COND test.\"\n `(let (it)\n (cond\n ,@(mapcar (lambda (clause)\n `((setf it ,(car clause)) ,@(cdr clause)))\n ;; uses the fact, that SETF returns the value set\n body))))\n\n;; macroexpand:\n(let (it)\n (cond))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(let-match1 common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by LET-MATCH1\n\n(let-match1 common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro let-match1 (pattern arg &body body)\n \"Equivalent to (let-match ((PATTERN ARG)) BODY...).\"\n `(let-match ((,pattern ,arg)) ,.body))\n\n;; macroexpand:\n(let-match ((common-lisp:nil common-lisp:nil)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(define-language nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-LANGUAGE\n\n(define-language nil (progn))"}, {"role": "assistant", "content": "(defmacro DEFINE-LANGUAGE ...)\n\n;; macroexpand:\n(progn\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (defclass nil ((progn)) nil))\n (define-language-macro nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(unless 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by UNLESS\n\n(unless 'some-name)"}, {"role": "assistant", "content": "(defmacro UNLESS ...)\n\n;; macroexpand:\n(if 'some-name\n nil\n nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(once-on nil\n (progn))\n\nProblem: Macro call that should be transformed by ONCE-ON\n\n(once-on nil\n (progn))"}, {"role": "assistant", "content": "(defmacro once-on (hook args &body body)\n \"Attach a handler with ARGS and BODY to the HOOK.\n\nRemove the handler after it fires the first time.\n\nSee `on'.\"\n (let ((handler-name (gensym \"once-on-hook-handler\"))\n (args (alexandria:ensure-list args)))\n (alexandria:once-only (hook)\n `(add-hook\n ,hook (make-instance 'handler\n :fn (lambda ,args\n (declare (ignorable ,@args))\n (remove-hook ,hook (quote ,handler-name))\n ,@body)\n :name (quote ,handler-name))))))\n\n;; macroexpand:\n(let ((#:hook183 nil))\n (add-hook #:hook183\n (make-instance 'handler :fn\n (lambda (progn)\n (declare (ignorable progn))\n (remove-hook #:hook183\n '#:|once-on-hook-handler182|))\n :name '#:|once-on-hook-handler182|)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(all-values\n 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ALL-VALUES\n\n(all-values\n 'some-name)"}, {"role": "assistant", "content": "(defmacro ALL-VALUES ...)\n\n;; macroexpand:\n(let ((#:values150 'nil) (#:last-value-cons151 nil))\n (for-effects\n (let ((value (progn 'some-name)))\n (global\n (if (null #:values150)\n (setf #:last-value-cons151 (list value)\n #:values150 #:last-value-cons151)\n (setf (rest #:last-value-cons151) (list value)\n #:last-value-cons151 (rest #:last-value-cons151))))))\n #:values150)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(true 'some-name)\n\nIssue: Macro call that should be transformed by TRUE\n\n(true 'some-name)"}, {"role": "assistant", "content": "(defmacro true (form &optional description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(true ,form)\n :value-form ',form\n :body (lambda () ,form)\n :expected 'T\n :comparison 'geq\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))\n\n;; macroexpand:\n(eval-in-context *context*\n (make-instance 'comparison-result :expression\n '(true 'some-name) :value-form ''some-name\n :body (lambda () 'some-name) :expected 't\n :comparison 'geq))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(is-values 'some-name)\n\nIssue: Macro call that should be transformed by IS-VALUES\n\n(is-values 'some-name)"}, {"role": "assistant", "content": "(defmacro is-values (form &body body)\n (multiple-value-bind (comp-expected expected comparison description format-args)\n (destructure-is-values-body body)\n `(eval-in-context\n *context*\n (make-instance 'multiple-value-comparison-result\n :expression '(is-values ,form ,@comp-expected)\n :value-form ',form\n :body (lambda () ,form)\n :expected (list ,@expected)\n :comparison (list ,@comparison)\n ,@(when description\n `(:description (format NIL ,description ,@format-args)))))))\n\n;; macroexpand:\n(eval-in-context *context*\n (make-instance 'multiple-value-comparison-result :expression\n '(is-values 'some-name) :value-form ''some-name\n :body (lambda () 'some-name) :expected (list)\n :comparison (list)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(aecase nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by AECASE\n\n(aecase nil\n (progn))"}, {"role": "assistant", "content": "(defmacro aecase (keyform &body cases)\n \"Like ECASE, except binds the result of the keyform to IT (via LET) for the\nscope of the cases.\"\n `(anaphoric ecase ,keyform ,@cases))\n\n;; macroexpand:\n(anaphoric ecase\n nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(lambda-ematch1 common-lisp:nil\n :key\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-EMATCH1\n\n(lambda-ematch1 common-lisp:nil\n :key\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro lambda-ematch1 (pattern &body body)\n \"Equivalent to (lambda (arg) (ematch arg (PATTERN BODY...))).\"\n `(lambda-ematch (,pattern ,@body)))\n\n;; macroexpand:\n(lambda-ematch\n (common-lisp:nil :key common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(make-dispatcher nil)\n\nPattern to recognize: Macro call that should be transformed by MAKE-DISPATCHER\n\n(make-dispatcher nil)"}, {"role": "assistant", "content": "(defmacro make-dispatcher (function-constructor)\n `(make-instance 'dispatcher :dispatch-function-constructor ',function-constructor\n :dispatch-function ,function-constructor))\n\n;; macroexpand:\n(make-instance 'dispatcher :dispatch-function-constructor 'nil\n :dispatch-function nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(of-type nil :key nil)\n\nProblem: Macro call that should be transformed by OF-TYPE\n\n(of-type nil :key nil)"}, {"role": "assistant", "content": "(defmacro of-type (type form &optional description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(of-type ,type ,form)\n :value-form ',form\n :body (lambda () ,form)\n :expected ',(maybe-unquote type)\n :comparison 'typep\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))\n\n;; macroexpand:\n(eval-in-context *context*\n (make-instance 'comparison-result :expression\n '(of-type nil :key) :value-form ':key :body\n (lambda () :key) :expected 'nil :comparison\n 'typep))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(vref nil (progn))\n\nProblem: Macro call that should be transformed by VREF\n\n(vref nil (progn))"}, {"role": "assistant", "content": "(defmacro vref (vec index &environment env)\n \"When used globally, same as `aref'.\n\nInside of a with-type-dispatch form, calls to `vref' may be bound to\ndifferent accessors, such as `char' or `schar', or `bit' or `sbit',\ndepending on the type being specialized on.\"\n (if (symbolp vec)\n (let* ((type (variable-type vec env))\n (vref (type-vref type)))\n `(,vref ,vec ,index))\n `(aref ,vec ,index)))\n\n;; macroexpand:\n(aref nil (progn))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(ematch common-lisp:nil\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EMATCH\n\n(ematch common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro ematch (what &body clauses)\n #.+match-doc+\n (with-gensyms (otherwise)\n `(match2 ,what\n ,@clauses\n (,otherwise (error 'match-error :pattern ',clauses :values (list ,otherwise))))))\n\n;; macroexpand:\n(match2 common-lisp:nil\n common-lisp:nil\n (#:otherwise143\n (common-lisp:error 'match-error :pattern '(common-lisp:nil) :values\n (common-lisp:list #:otherwise143))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(fail nil :key nil)\n\nProblem: Macro call that should be transformed by FAIL\n\n(fail nil :key nil)"}, {"role": "assistant", "content": "(defmacro fail (form &optional (type 'error) description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(fail ,form ,type)\n :value-form '(capture-error ,form)\n :body (lambda () (capture-error ,form ,(maybe-unquote type)))\n :expected ',(maybe-unquote type)\n :comparison 'typep\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))\n\n;; macroexpand:\n(eval-in-context *context*\n (make-instance 'comparison-result :expression '(fail nil :key)\n :value-form '(capture-error nil) :body\n (lambda () (capture-error nil :key)) :expected\n ':key :comparison 'typep))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(nand nil (progn))\n\nPattern to recognize: Macro call that should be transformed by NAND\n\n(nand nil (progn))"}, {"role": "assistant", "content": "(defmacro nand (&rest forms)\n \"Equivalent to (not (and ...)).\"\n (if (null forms) nil\n (if (null (rest forms))\n `(not ,(first forms))\n `(if ,(first forms)\n (nand ,@(rest forms))\n t))))\n\n;; macroexpand:\n(if nil\n (nand (progn))\n t)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-contracts-disabled nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-CONTRACTS-DISABLED\n\n(with-contracts-disabled nil\n nil)"}, {"role": "assistant", "content": "(defmacro with-contracts-disabled (() &body body)\n \"A shorthand for disabling all contracts for the extent of this form.\"\n (let ((enabled-contracts (gensym \"ENABLED-CONTRACTS-\")))\n `(let ((,enabled-contracts (enabled-contracts)))\n (unwind-protect\n (progn (disable-contracts)\n ,@body)\n (apply #'enable-contracts ,enabled-contracts)))))\n\n;; macroexpand:\n(let ((#:enabled-contracts-166 (enabled-contracts)))\n (unwind-protect (progn (disable-contracts) nil)\n (apply #'enable-contracts #:enabled-contracts-166)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(finishes\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by FINISHES\n\n(finishes\n nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro finishes (&body body)\n \"Generates a pass if BODY executes to normal completion. In\nother words if body does signal, return-from or throw this test\nfails.\"\n `(unwind-protect-case () (progn ,@body)\n (:normal (add-result 'test-passed :test-expr ',body))\n (:abort (process-failure ',body \"Test didn't finish\"))))\n\n;; macroexpand:\n(unwind-protect-case nil\n (progn nil :key nil)\n (:normal (add-result 'test-passed :test-expr '(nil :key nil)))\n (:abort (process-failure '(nil :key nil) \"Test didn't finish\")))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(some-> nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by SOME->\n\n(some-> nil :key nil)"}, {"role": "assistant", "content": "(defmacro SOME-> ...)\n\n;; macroexpand:\n(let* ((#:|some128| nil)\n (#:|some128| (when #:|some128| (:key #:|some128|)))\n (#:|some128| (when #:|some128| (nil #:|some128|))))\n #:|some128|)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(vref nil nil)\n\nPattern to recognize: Macro call that should be transformed by VREF\n\n(vref nil nil)"}, {"role": "assistant", "content": "(defmacro vref (vec index &environment env)\n \"When used globally, same as `aref'.\n\nInside of a with-type-dispatch form, calls to `vref' may be bound to\ndifferent accessors, such as `char' or `schar', or `bit' or `sbit',\ndepending on the type being specialized on.\"\n (if (symbolp vec)\n (let* ((type (variable-type vec env))\n (vref (type-vref type)))\n `(,vref ,vec ,index))\n `(aref ,vec ,index)))\n\n;; macroexpand:\n(aref nil nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(gatherlet nil\n (progn))\n\nIssue: Macro call that should be transformed by GATHERLET\n\n(gatherlet nil\n (progn))"}, {"role": "assistant", "content": "(defmacro GATHERLET ...)\n\n;; macroexpand:\n(common-lisp:let ()\n (progn))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(gen-lambda nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by GEN-LAMBDA\n\n(gen-lambda nil\n (progn))"}, {"role": "assistant", "content": "(defmacro gen-lambda (params &body rest)\n \"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.\"\n `(let ((values-handler (create-values-handler)))\n (declare (ignorable values-handler))\n (make-instance \n 'basic-generator \n :function (lambda ,params ,@rest))))\n\n;; macroexpand:\n(let ((values-handler (create-values-handler)))\n (declare (ignorable values-handler))\n (make-instance 'basic-generator :function (lambda () (progn))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(is-true nil nil)\n\nWhat needs to change: Macro call that should be transformed by IS-TRUE\n\n(is-true nil nil)"}, {"role": "assistant", "content": "(defmacro is-true (condition &rest reason-args)\n \"Like IS this check generates a pass if CONDITION returns true\n and a failure if CONDITION returns false. Unlike IS this check\n does not inspect CONDITION to determine how to report the\n failure.\"\n `(if ,condition\n (add-result 'test-passed :test-expr ',condition)\n (process-failure ',condition\n ,@(or reason-args\n `(\"~S did not return a true value\" ',condition)))))\n\n;; macroexpand:\n(if nil\n (add-result 'test-passed :test-expr 'nil)\n (process-failure 'nil nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(enable-infix-reader)\n\nWrite a macro that addresses: Macro call that should be transformed by ENABLE-INFIX-READER\n\n(enable-infix-reader)"}, {"role": "assistant", "content": "(defmacro ENABLE-INFIX-READER ...)\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (push *readtable* *readtables*)\n (setq *readtable* (copy-readtable))\n (set-macro-character #\\LEFT_CURLY_BRACKET #'infix-reader nil)\n (set-macro-character #\\RIGHT_CURLY_BRACKET #'infix-end nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-destructured-lambda-form nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-DESTRUCTURED-LAMBDA-FORM\n\n(with-destructured-lambda-form nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro WITH-DESTRUCTURED-LAMBDA-FORM ...)\n\n;; macroexpand:\n(destructuring-bind\n (#:function135 #:name136 #:qualifiers137 #:lambda-list138 #:docstring139\n #:declarations140 #:forms141)\n (split-lambda-form :key)\n (declare\n (ignore #:function135 #:name136 #:qualifiers137 #:lambda-list138\n #:docstring139 #:declarations140 #:forms141))\n nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(lambda-ematch\n common-lisp:nil\n (common-lisp:progn))\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-EMATCH\n\n(lambda-ematch\n common-lisp:nil\n (common-lisp:progn))"}, {"role": "assistant", "content": "(defmacro lambda-ematch (&body body)\n \"Equivalent to (lambda (arg) (ematch arg BODY...)).\"\n (multiple-value-bind (preamble clauses) (parse-matcher-body body)\n (with-gensyms (clause)\n `(lambda (,clause)\n ,@preamble\n (ematch ,clause\n ,@clauses)))))\n\n;; macroexpand:\n(common-lisp:lambda (#:clause171)\n (ematch #:clause171\n common-lisp:nil\n (common-lisp:progn)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(any-of nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by ANY-OF\n\n(any-of nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro ANY-OF ...)\n\n;; macroexpand:\n(lc (nil :key nil) thereis)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-standard-readtable\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-STANDARD-READTABLE\n\n(with-standard-readtable\n nil\n nil)"}, {"role": "assistant", "content": "(defmacro WITH-STANDARD-READTABLE ...)\n\n;; macroexpand:\n(bind ((*readtable* (with-standard-io-syntax (copy-readtable *readtable*))))\n nil\n nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(ecase-of nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by ECASE-OF\n\n(ecase-of nil\n (progn))"}, {"role": "assistant", "content": "(defmacro ecase-of (type x &body body)\n \"Like `ecase' but, given a TYPE (which should be defined as `(member\n...)'), warn, at compile time, unless the keys in BODY are all of TYPE\nand, taken together, they form an exhaustive partition of TYPE.\"\n (once-only (x)\n `(case-of ,type ,x\n ,@body\n (otherwise\n (error 'type-error\n :datum ,x\n :expected-type ',type)))))\n\n;; macroexpand:\n(let ((#:x241 (progn)))\n (case-of nil\n #:x241\n (otherwise (error 'type-error :datum #:x241 :expected-type 'nil))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(wait-on nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WAIT-ON\n\n(wait-on nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro wait-on (hook args &body body)\n \"Wait until HOOK is run.\nNote that it does not necessarily wait until hook has finished running all\nhandlers.\nReturn the BODY return value.\"\n (alexandria:with-gensyms (promise)\n (let ((handler-name (gensym \"wait-on-handler\"))\n (args (alexandria:ensure-list args)))\n (alexandria:once-only (hook)\n `(let ((,promise (make-promise)))\n (add-hook\n ,hook (make-instance 'handler\n :fn (lambda ,args\n (declare (ignorable ,@args))\n (remove-hook ,hook (quote ,handler-name))\n (fulfill ,promise (progn ,@body)))\n :name (quote ,handler-name)))\n (force ,promise))))))\n\n;; macroexpand:\n(let ((#:hook194 nil))\n (let ((#:promise192 (make-promise)))\n (add-hook #:hook194\n (make-instance 'handler :fn\n (lambda (:key)\n (declare (ignorable :key))\n (remove-hook #:hook194 '#:|wait-on-handler193|)\n (fulfill #:promise192 (progn nil)))\n :name '#:|wait-on-handler193|))\n (force #:promise192)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(nest nil (progn))\n\nProblem: Macro call that should be transformed by NEST\n\n(nest nil (progn))"}, {"role": "assistant", "content": "(defmacro nest (&rest things)\n \"Like ~>>, but backward.\n\nThis is useful when layering `with-x' macros where the order is not\nimportant, and extra indentation would be misleading.\n\nFor example:\n\n (nest\n (with-open-file (in file1 :direction input))\n (with-open-file (in file2 :direction output))\n ...)\n\nIs equivalent to:\n\n (with-open-file (in file1 :direction input)\n (with-open-file (in file2 :direction output)\n ...))\n\n\\(But see `with-open-files').\n\nIf the outer macro has no arguments, you may omit the parentheses.\n\n (nest\n with-standard-io-syntax\n ...)\n \u2261 (with-standard-io-syntax\n ...)\n\nFrom UIOP, based on a suggestion by Marco Baringer.\"\n (expand-nest things))\n\n;; macroexpand:\n((progn))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(use-foreign-library 'some-name)\n\nWhat needs to change: Macro call that should be transformed by USE-FOREIGN-LIBRARY\n\n(use-foreign-library 'some-name)"}, {"role": "assistant", "content": "(defmacro use-foreign-library (name)\n `(load-foreign-library ',name))\n\n;; macroexpand:\n(load-foreign-library ''some-name)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(modf-eval)\n\nProblem: Macro call that should be transformed by MODF-EVAL\n\n(modf-eval)"}, {"role": "assistant", "content": "(defmacro modf-eval (&rest args)\n `(progn ,@args))\n\n;; macroexpand:\n(progn)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(pprint-coalton-codegen-types\n common-lisp:nil\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-TYPES\n\n(pprint-coalton-codegen-types\n common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro PPRINT-COALTON-CODEGEN-TYPES ...)\n\n;; macroexpand:\n(common-lisp:let ((#:package227\n (common-lisp:make-package '#:pprint-codegen-package :use\n '(#:cl))))\n (common-lisp:unwind-protect\n (common-lisp:progn\n (common-lisp:do-symbols\n (coalton-impl/reader::symb common-lisp:*package*)\n (common-lisp:unless\n (common-lisp:nth-value 1\n (common-lisp:find-symbol\n (common-lisp:symbol-name\n coalton-impl/reader::symb)\n #:package227))\n (common-lisp:import coalton-impl/reader::symb #:package227)))\n (common-lisp:let ((common-lisp:*package* #:package227))\n (common-lisp:pprint\n (coalton-codegen-types\n common-lisp:nil\n common-lisp:nil))\n (common-lisp:values)))\n (common-lisp:delete-package #:package227)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(define-print-object/std nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-PRINT-OBJECT/STD\n\n(define-print-object/std nil)"}, {"role": "assistant", "content": "(defmacro define-print-object/std (class)\n \"Define a print-object method for objects of class CLASS.\n\n Print all slots with their values. Prints \\\"UNBOUND\\\", as a string, when slots are unbound.\n\n Usage:\n\n (defclass/std test () ((a b)))\n\n (print-object/std test)\n\n The macro expands to:\n\n (DEFMETHOD PRINT-OBJECT ((OBJ TEST) STREAM)\n (PRINT-UNREADABLE-OBJECT (OBJ STREAM :TYPE T :IDENTITY T)\n (FORMAT STREAM \\\"~{~a~^ ~}\\\" (COLLECT-OBJECT-SLOTS OBJ))))\n\"\n `(defmethod print-object ((obj ,class) stream)\n (print-unreadable-object (obj stream :type t :identity t)\n (format stream \"~{~a~^ ~}\"\n (collect-object-slots obj)))))\n\n;; macroexpand:\n(defmethod print-object ((obj nil) stream)\n (print-unreadable-object (obj stream :type t :identity t)\n (format stream \"~{~a~^ ~}\" (collect-object-slots obj))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(export\n 'some-name)\n\nWhat needs to change: Macro call that should be transformed by EXPORT\n\n(export\n 'some-name)"}, {"role": "assistant", "content": "(defmacro EXPORT ...)\n\n;; macroexpand:\n'some-name"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(gen-lambda-with-sticky-stop)\n\nPattern to recognize: Macro call that should be transformed by GEN-LAMBDA-WITH-STICKY-STOP\n\n(gen-lambda-with-sticky-stop)"}, {"role": "assistant", "content": "(defmacro gen-lambda-with-sticky-stop (&rest rest)\n `(make-instance \n 'basic-generator \n :function (sticky-stop-lambda ,@rest)))\n\n;; macroexpand:\n(make-instance 'basic-generator :function (sticky-stop-lambda))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(select nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SELECT\n\n(select nil)"}, {"role": "assistant", "content": "(defmacro select (fields &body clauses)\n `(make-statement :select\n ,(match fields\n ((or (list* (type keyword) _)\n (list* (list* (type keyword) _) _))\n `(make-clause :fields\n ,@(mapcar #'expand-op fields)))\n ((type keyword) `(fields ,fields))\n ((or (type symbol)\n (list* (type symbol) _))\n `(convert-if-fields-clause ,fields))\n (otherwise fields))\n ,@clauses))\n\n;; macroexpand:\n(make-statement :select (convert-if-fields-clause nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(define-screamer-package nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-SCREAMER-PACKAGE\n\n(define-screamer-package nil)"}, {"role": "assistant", "content": "(defmacro define-screamer-package (defined-package-name &body options)\n \"Convenience wrapper around DEFPACKAGE. Passes its argument directly\nto DEFPACKAGE, and automatically injects two additional options:\n\n \\(:shadowing-import-from :screamer :defun :multiple-value-bind :y-or-n-p)\n \\(:use :cl :screamer)\"\n `(defpackage ,defined-package-name\n ,@options\n (:shadowing-import-from :screamer :defun :multiple-value-bind :y-or-n-p)\n (:use :cl :screamer)))\n\n;; macroexpand:\n(defpackage nil\n (:shadowing-import-from :screamer :defun :multiple-value-bind :y-or-n-p)\n (:use :cl :screamer))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(\u03c8 nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by \u03a8\n\n(\u03c8 nil :key nil)"}, {"role": "assistant", "content": "(defmacro \u03a8 ...)\n\n;; macroexpand:\n(mapcar (\u03bb :key nil) nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(aif nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AIF\n\n(aif nil nil)"}, {"role": "assistant", "content": "(defmacro aif (test then &optional else)\n \"Like IF, except binds the result of the test to IT (via LET) for\nthe scope of the then and else expressions.\" \n `(anaphoric if ,test ,then ,else))\n\n;; macroexpand:\n(anaphoric if\n nil\n nil\n nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(^fm-next-sib nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ^FM-NEXT-SIB\n\n(^fm-next-sib nil)"}, {"role": "assistant", "content": "(defmacro ^fm-next-sib (&optional (self 'self))\n (let ((s (gensym)))\n `(let ((,s ,self))\n (car (cdr (member ,s (kids (fm-parent ,s))))))))\n\n;; macroexpand:\n(let ((#:g143 nil))\n (car (cdr (member #:g143 (kids (fm-parent #:g143))))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n;; Conditional logic with different variable bindings per branch\n;; requires deeply nested lets inside each cond clause\n(cond ((> x 0)\n (let ((order :ascending)\n (bound (sqrt x)))\n (process order bound)))\n ((< x 0)\n (let ((order :descending)\n (bound (sqrt (- x))))\n (process order bound)))\n (t\n (let ((order :zero)\n (bound 0))\n (process order bound))))\n\n;; Repetitive: same body structure, different bindings per branch\n\nIssue: Cond with per-branch variable bindings leads to duplicated body code \u2014 want shared body with branch-specific bindings\n\n;; Conditional logic with different variable bindings per branch\n;; requires deeply nested lets inside each cond clause\n(cond ((> x 0)\n (let ((order :ascending)\n (bound (sqrt x)))\n (process order bound)))\n ((< x 0)\n (let ((order :descending)\n (bound (sqrt (- x))))\n (process order bound)))\n (t\n (let ((order :zero)\n (bound 0))\n (process order bound))))\n\n;; Repetitive: same body structure, different bindings per branch"}, {"role": "assistant", "content": "(defmacro condlet (clauses &body body)\n (let ((bodfn (gensym))\n (vars (mapcar #'(lambda (v) (cons v (gensym)))\n (remove-duplicates\n (mapcar #'car\n (mappend #'cdr clauses))))))\n `(labels ((,bodfn ,(mapcar #'car vars)\n ,@body))\n (cond ,@(mapcar #'(lambda (cl)\n (condlet-clause vars cl bodfn))\n clauses)))))\n\n;; macroexpand:\n;; (condlet (((= x 0) (order :zero) (bound 0))\n;; ((> x 0) (order :ascending) (bound (sqrt x)))\n;; ((< x 0) (order :descending) (bound (sqrt (- x)))))\n;; (process order bound))\n;;\n;; Each cond clause specifies test + bindings.\n;; The body (process order bound) is shared across all clauses.\n;; Variables from ALL clauses are recognized and gensym'd."}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-standard-readtable)\n\nPattern to recognize: Macro call that should be transformed by WITH-STANDARD-READTABLE\n\n(with-standard-readtable)"}, {"role": "assistant", "content": "(defmacro WITH-STANDARD-READTABLE ...)\n\n;; macroexpand:\n(bind ((*readtable* (with-standard-io-syntax (copy-readtable *readtable*)))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(skip-on nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SKIP-ON\n\n(skip-on nil\n nil)"}, {"role": "assistant", "content": "(defmacro skip-on (features desc &body tests)\n (let ((thunk (gensym \"THUNK\")))\n `(flet ((,thunk ()\n ,@tests))\n (if (featurep '(or ,@features))\n (with-forced-status (:skipped ,@(if (listp desc) desc (list desc)))\n (,thunk))\n (,thunk)))))\n\n;; macroexpand:\n(flet ((#:thunk127 ()\n ))\n (if (featurep '(or))\n (with-forced-status (:skipped)\n (#:thunk127))\n (#:thunk127)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(with-cached-reader-conditionals\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-CACHED-READER-CONDITIONALS\n\n(with-cached-reader-conditionals\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro WITH-CACHED-READER-CONDITIONALS ...)\n\n;; macroexpand:\n(call-with-cached-reader-conditionals (lambda () nil (progn)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(walk-environment\n 'some-name)\n\nIssue: Macro call that should be transformed by WALK-ENVIRONMENT\n\n(walk-environment\n 'some-name)"}, {"role": "assistant", "content": "(defmacro WALK-ENVIRONMENT ...)\n\n;; macroexpand:\n(progn 'some-name)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(rem-arg-list-key-value! nil (progn))\n\nIssue: Macro call that should be transformed by REM-ARG-LIST-KEY-VALUE!\n\n(rem-arg-list-key-value! nil (progn))"}, {"role": "assistant", "content": "(defmacro rem-arg-list-key-value! (ids place &key (test '#'equalper) (key '#'identity))\n `(progn\n (iter (for id in (ensure-list ,ids))\n (setf ,place (rem-arg-list-key-value id ,place :test ,test :key ,key)))\n ,place))\n\n;; macroexpand:\n(progn\n (iter\n (for id in (ensure-list nil))\n (setf (progn)\n (rem-arg-list-key-value id (progn) :test #'equalper :key\n #'identity)))\n (progn))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(c?+n\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by C?+N\n\n(c?+n\n nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro c?+n (&body body)\n `(make-c-dependent\n :inputp t\n :code ',body\n :value-state :unevaluated\n :rule (c-lambda ,@body)))\n\n;; macroexpand:\n(make-c-dependent :inputp t :code '(nil :key nil) :value-state :unevaluated\n :rule\n (c-lambda\n nil\n :key\n nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-foreign-pointer-as-string 'some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-FOREIGN-POINTER-AS-STRING\n\n(with-foreign-pointer-as-string 'some-name)"}, {"role": "assistant", "content": "(defmacro with-foreign-pointer-as-string\n ((var-or-vars size &rest args) &body body)\n \"VAR-OR-VARS is not evaluated and should be a list of the form\n\\(VAR &OPTIONAL SIZE-VAR) or just a VAR symbol. VAR is bound to\na foreign buffer of size SIZE within BODY. The return value is\nconstructed by calling FOREIGN-STRING-TO-LISP on the foreign\nbuffer along with ARGS.\" ; fix wording, sigh\n (destructuring-bind (var &optional size-var)\n (ensure-list var-or-vars)\n `(with-foreign-pointer (,var ,size ,size-var)\n (progn\n ,@body\n (values (foreign-string-to-lisp ,var ,@args))))))\n\n;; macroexpand:\n(with-foreign-pointer (quote some-name nil)\n (progn (values (foreign-string-to-lisp quote))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n($send nil :key nil)\n\nProblem: Macro call that should be transformed by $SEND\n\n($send nil :key nil)"}, {"role": "assistant", "content": "(defmacro $SEND ...)\n\n;; macroexpand:\n(send-message nil :key nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(~>> 'some-name)\n\nIssue: Macro call that should be transformed by ~>>\n\n(~>> 'some-name)"}, {"role": "assistant", "content": "(defmacro ~>> (needle &rest holes)\n \"Like `~>' but, by default, thread NEEDLE as the last argument\ninstead of the first.\"\n (thread-aux '~>> needle holes\n (lambda (needle hole)\n (append hole (list needle)))))\n\n;; macroexpand:\n'some-name"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(the-kids nil (progn))\n\nProblem: Macro call that should be transformed by THE-KIDS\n\n(the-kids nil (progn))"}, {"role": "assistant", "content": "(defmacro the-kids (&rest kids)\n `(let ((*parent* self))\n (packed-flat! ,@kids)))\n\n;; macroexpand:\n(let ((*parent* self))\n (packed-flat! nil (progn)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(callback nil)\n\nProblem: Macro call that should be transformed by CALLBACK\n\n(callback nil)"}, {"role": "assistant", "content": "(defmacro callback (name)\n `(%callback ',name))\n\n;; macroexpand:\n(%callback 'nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(->> nil nil)\n\nProblem: Macro call that should be transformed by ->>\n\n(->> nil nil)"}, {"role": "assistant", "content": "(defmacro ->> ...)\n\n;; macroexpand:\n(nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(decide nil)\n\nIssue: Macro call that should be transformed by DECIDE\n\n(decide nil)"}, {"role": "assistant", "content": "(defmacro DECIDE ...)\n\n;; macroexpand:\n(let ((#:argument-126 nil))\n (either\n (progn (assert!-true #:argument-126) t)\n (progn (assert!-false #:argument-126) nil)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(match2* 'some-name)\n\nProblem: Macro call that should be transformed by MATCH2*\n\n(match2* 'some-name)"}, {"role": "assistant", "content": "(defmacro match2* (whats &body clauses)\n \"In match2/match2*, the last clause is not enclosed in a block.\nTherefore, using `next' in the last clause results in jumping to the next innermost matching construct,\nor results in a compilation error when this is the outermost matching construct.\"\n `(match2*+ ,whats\n ,(make-list (length whats) :initial-element t)\n ;; ,(mapcar #'form-type whats)\n ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^ TODO: use Bike/compiler-macro\n ,@clauses))\n\n;; macroexpand:\n(match2*+ 'some-name\n (common-lisp:t common-lisp:t))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(optimize)\n\nProblem: Macro call that should be transformed by OPTIMIZE\n\n(optimize)"}, {"role": "assistant", "content": "(defmacro OPTIMIZE ...)\n\n;; macroexpand:\n(common-lisp:progn\n (common-lisp:declaim (common-lisp:optimize))\n '(common-lisp:declare (common-lisp:optimize)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda+ nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA+\n\n(lambda+ nil\n nil)"}, {"role": "assistant", "content": "(defmacro LAMBDA+ ...)\n\n;; macroexpand:\n(lambda ()\n (let+ nil\n nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(shift-incf nil nil)\n\nProblem: Macro call that should be transformed by SHIFT-INCF\n\n(shift-incf nil nil)"}, {"role": "assistant", "content": "(defmacro SHIFT-INCF ...)\n\n;; macroexpand:\n(let* ((#:temp255 nil) (#:new254 (+ #:temp255 nil)))\n (setq nil #:new254)\n #:temp255)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(define nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE\n\n(define nil)"}, {"role": "assistant", "content": "(defmacro DEFINE ...)\n\n;; macroexpand:\n(eval-when (:load-toplevel :execute)\n (check-if-bound 'nil)\n (setf (get 'nil 'read-macro)\n (lambda (#:stream145) (let ((*standard-input* #:stream145)))))\n 'nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(define-dispatch nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-DISPATCH\n\n(define-dispatch nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro define-dispatch (name lambda-list &body body)\n \"the lambda list should accept two arguments:\nthe list of arguments given by the current method call.\nthe specific hooks (as named or unamed functions) for the qualified method (that we will be dispatching from).\n\nyou should then use the arguments to dispatch the specific hooks as you wish in the body.\nif the body returns a result, by default the method will also return that result, this can be overriden with finalize-dispatch-method.\n\nSee finalize-dispatch-method\nSee dispatch\"\n `(let ((new-dispatch (make-dispatcher (lambda ,lambda-list ,@body))))\n (setf (gethash ',name *dispatch-table*)\n new-dispatch)))\n\n;; macroexpand:\n(let ((new-dispatch (make-dispatcher (lambda :key nil))))\n (setf (gethash 'nil *dispatch-table*) new-dispatch))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(mvlet* nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MVLET*\n\n(mvlet* nil\n nil)"}, {"role": "assistant", "content": "(defmacro mvlet* ((&rest bindings) &body body &environment env)\n \"Expand a series of nested `multiple-value-bind' forms.\n\n`mvlet*' is similar in intent to Scheme\u2019s `let-values', but with a\ndifferent and less parenthesis-intensive syntax. Each binding is a\nlist of\n\n (var var*... expr)\n\nA simple example should suffice to show both the implementation and\nthe motivation:\n\n (defun uptime (seconds)\n (mvlet* ((minutes seconds (truncate seconds 60))\n (hours minutes (truncate minutes 60))\n (days hours (truncate hours 24)))\n (declare ((integer 0 *) days hours minutes seconds))\n (fmt \\\"~d day~:p, ~d hour~:p, ~d minute~:p, ~d second~:p\\\"\n days hours minutes seconds)))\n\nNote that declarations work just like `let*'.\"\n (cond ((null bindings)\n `(locally ,@body))\n ((every #'simple-binding-p bindings)\n `(let* ,bindings ,@body))\n (t (multiple-value-bind (body decls)\n (parse-body body)\n (let* ((bindings (canonicalize-bindings bindings))\n (mvbinds (member-if-not #'simple-binding-p bindings))\n (simple-binds (ldiff bindings mvbinds)))\n (if simple-binds\n (multiple-value-bind (local other)\n (partition-declarations (mapcar #'car simple-binds) decls env)\n `(let* ,simple-binds\n ,@local\n (mvlet* ,mvbinds\n ,@other\n ,@body)))\n (let* ((vars (butlast (car bindings)))\n (expr (lastcar (car bindings))))\n (multiple-value-bind (local other)\n (partition-declarations vars decls env)\n `(multiple-value-bind ,vars\n ,expr\n ,@local\n (mvlet* ,(cdr bindings)\n ,@other\n ,@body))))))))))\n\n;; macroexpand:\n(locally nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(alt nil nil)\n\nIssue: Macro call that should be transformed by ALT\n\n(alt nil nil)"}, {"role": "assistant", "content": "(defmacro alt (parser &rest parsers)\n \"Accept the results of the first parser from a group to succeed.\"\n (let ((offset (gensym \"ALT-OFFSET\")))\n `(lambda (,offset)\n ,(labels ((recurse (ps furthest)\n (if (null ps)\n `(fail ,furthest)\n (let ((res (gensym \"ALT-RES\"))\n (next (gensym \"ALT-NEXT\")))\n `(multiple-value-bind (,res ,next) (funcall ,(car ps) ,offset)\n (if (ok? ,res)\n (values ,res ,next)\n ,(recurse (cdr ps) `(max ,next ,furthest))))))))\n (recurse (cons parser parsers) offset)))))\n\n;; macroexpand:\n(lambda (#:alt-offset194)\n (multiple-value-bind (#:alt-res195 #:alt-next196)\n (funcall nil #:alt-offset194)\n (if (ok? #:alt-res195)\n (values #:alt-res195 #:alt-next196)\n (multiple-value-bind (#:alt-res197 #:alt-next198)\n (funcall nil #:alt-offset194)\n (if (ok? #:alt-res197)\n (values #:alt-res197 #:alt-next198)\n (fail\n (max #:alt-next198 (max #:alt-next196 #:alt-offset194))))))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(defpackage nil)\n\nPattern to recognize: Macro call that should be transformed by DEFPACKAGE\n\n(defpackage nil)"}, {"role": "assistant", "content": "(defmacro DEFPACKAGE ...)\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (sb-impl::%defpackage #A((3) base-char . \"NIL\") 'nil 'nil 'nil 'nil ':default\n 'nil 'nil 'nil '(#A((3) base-char . \"NIL\")) 'nil 'nil\n (sb-c:source-location)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-reducer 'some-name)\n\nProblem: Macro call that should be transformed by WITH-REDUCER\n\n(with-reducer 'some-name)"}, {"role": "assistant", "content": "(defmacro WITH-REDUCER ...)\n\n;; macroexpand:\n(let ((#:reducer128\n (make-reducer some-name :initial-value (or nil nil) :place-setter nil)))\n (flet ((quote (&rest items) (apply #:reducer128 items)))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(fm! nil (progn))\n\nProblem: Macro call that should be transformed by FM!\n\n(fm! nil (progn))"}, {"role": "assistant", "content": "(defmacro fm! (md-name &optional (starting 'self))\n `(without-c-dependency \n (fm-find-one ,starting ,(if (consp md-name)\n `(list ',(car md-name) ,(cadr md-name))\n `',md-name)\n :must-find t\n :global-search nil)))\n\n;; macroexpand:\n(without-c-dependency\n (fm-find-one (progn) 'nil :must-find t :global-search nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(sccase 'some-name)\n\nWhat needs to change: Macro call that should be transformed by SCCASE\n\n(sccase 'some-name)"}, {"role": "assistant", "content": "(defmacro sccase (keyform &body cases)\n \"Like CCASE, except binds the keyform to IT (via SYMBOL-MACROLET) for the\nscope of the cases. IT can be set with SETF.\"\n `(symbolic ccase ,keyform ,@cases))\n\n;; macroexpand:\n(symbolic ccase 'some-name)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(type common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by TYPE\n\n(type common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro TYPE ...)\n\n;; macroexpand:\n(common-lisp:progn\n (common-lisp:declaim (common-lisp:type common-lisp:nil))\n '(common-lisp:declare (common-lisp:type common-lisp:nil)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(defun* nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFUN*\n\n(defun* nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro DEFUN* ...)\n\n;; macroexpand:\n(defun nil :key\n (with-yield\n nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(when-failing nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WHEN-FAILING\n\n(when-failing nil\n nil)"}, {"role": "assistant", "content": "(defmacro WHEN-FAILING ...)\n\n;; macroexpand:\n(let* ((#:fail153 *fail*) (*fail* (lambda () (funcall #:fail153))))\n nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-sum 'some-name)\n\nWhat needs to change: Macro call that should be transformed by COLLECT-SUM\n\n(collect-sum 'some-name)"}, {"role": "assistant", "content": "(defmacro COLLECT-SUM ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-242 (generator 'some-name))\n #:numbers-238\n (#:sum-239 0))\n (declare (type generator #:generator-242)\n (type number #:sum-239))\n (tagbody\n #:ll-243\n (setq #:numbers-238 (next-in #:generator-242 (go end)))\n (setq #:sum-239 (+ #:sum-239 #:numbers-238))\n (go #:ll-243)\n end)\n #:sum-239)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(multiple-value-cmatch nil)\n\nProblem: Macro call that should be transformed by MULTIPLE-VALUE-CMATCH\n\n(multiple-value-cmatch nil)"}, {"role": "assistant", "content": "(defmacro multiple-value-cmatch (values-form &body clauses)\n \"Same as MULTIPLE-VALUE-MATCH, except a continuable MATCH-ERROR will\nbe raised if none of the clauses match.\"\n (let* ((values (gensym \"VALUES\"))\n (else `(cerror \"Continue.\"\n 'match-error\n :values ,values\n :patterns ',(mapcar #'car clauses))))\n ;; FIXME: remove allocations\n `(let ((,values (multiple-value-list ,values-form)))\n ,(compile-multiple-value-match `(values-list ,values) clauses else))))\n\n;; macroexpand:\n(let ((#:values127 (multiple-value-list nil)))\n (multiple-value-bind nil\n (values-list #:values127)\n (cerror \"Continue.\" 'match-error :values #:values127 :patterns 'nil)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(dlet nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DLET\n\n(dlet nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro DLET ...)\n\n;; macroexpand:\n(dynamic-let nil\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(c_?dbg\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by C_?DBG\n\n(c_?dbg\n nil)"}, {"role": "assistant", "content": "(defmacro c_?dbg (&body body)\n \"Lazy until asked, then eagerly propagating\"\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :lazy :until-asked\n :rule (c-lambda ,@body)\n :debug t))\n\n;; macroexpand:\n(make-c-dependent :code '(nil) :value-state :unevaluated :lazy :until-asked\n :rule\n (c-lambda\n nil)\n :debug t)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(defjsmacro nil nil)\n\nProblem: Macro call that should be transformed by DEFJSMACRO\n\n(defjsmacro nil nil)"}, {"role": "assistant", "content": "(defmacro DEFJSMACRO ...)\n\n;; macroexpand:\n(defpsmacro nil\n nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(defunion nil)\n\nWhat needs to change: Macro call that should be transformed by DEFUNION\n\n(defunion nil)"}, {"role": "assistant", "content": "(defmacro defunion (union &body variants)\n \"Define an algebraic data type.\n\nEach expression in VARIANTS is either a symbol \\(in which case it\ndefines a unit type, as with `defunit') or a list \\(in which case it\ndefines a read-only structure, as with `defconstructor').\n\nUNION is defined as a type equivalent to the disjunction of all the\nmember types. A class is also defined, with the same name, but with\nangle brackets around it.\"\n (let* ((docstring (and (stringp (first variants))\n (pop variants)))\n (ctors (remove-if-not #'listp variants))\n (units (remove-if-not #'atom variants))\n (types (append units (mapcar #'first ctors)))\n (super (symbolicate '< union '>)))\n ;; CCL (and maybe other lisps) evaluates `(:include)' options at\n ;; macroexpansion time and does some environment augmenting and checking\n ;; that fails to account for our `env-super' trick.\n ;; So define the abstract base struct via a `progn' at the toplevel.\n `(progn\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (defstruct (,super\n (:constructor nil)\n (:copier nil)\n (:predicate nil)\n (:include %read-only-struct))\n ,@(unsplice docstring)))\n ;; NB The declarations are not currently used, due to an SBCL bug.\n (locally (declare #+sbcl (sb-ext:disable-package-locks %union))\n (symbol-macrolet ((serapeum/unlocked:%union ,super))\n (declare #+sbcl (sb-ext:enable-package-locks %union))\n (deftype ,union ()\n ,@(unsplice docstring)\n '(or ,@types))\n ,@(loop for type in units\n collect `(defunit ,type))\n ,@(loop for (type . slots) in ctors\n collect `(defconstructor ,type ,@slots))\n (declaim-freeze-type ,super)\n ',union)))))\n\n;; macroexpand:\n(progn\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (defstruct\n ( (:constructor nil) (:copier nil) (:predicate nil)\n (:include serapeum/defining-types::%read-only-struct))))\n (locally\n (declare (sb-ext:disable-package-locks serapeum/defining-types::%union))\n (symbol-macrolet ((%union ))\n (declare (sb-ext:enable-package-locks serapeum/defining-types::%union))\n (deftype nil () '(or))\n (declaim-freeze-type )\n 'nil)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(the-kids nil)\n\nProblem: Macro call that should be transformed by THE-KIDS\n\n(the-kids nil)"}, {"role": "assistant", "content": "(defmacro the-kids (&rest kids)\n `(let ((*parent* self))\n (packed-flat! ,@kids)))\n\n;; macroexpand:\n(let ((*parent* self))\n (packed-flat! nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(defrule nil\n (progn))\n\nProblem: Macro call that should be transformed by DEFRULE\n\n(defrule nil\n (progn))"}, {"role": "assistant", "content": "(defmacro DEFRULE ...)\n\n;; macroexpand:\n(setf (gethash #A((3) base-char . \"NIL\") cl-rules.core::*rules*)\n '#S(cl-rules.core::rule\n :name #A((3) base-char . \"NIL\")\n :conditions (#S(cl-rules.core::condn\n :name #A((5) base-char . \"PROGN\")\n :args nil))\n :actions nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(nix nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by NIX\n\n(nix nil :key nil)"}, {"role": "assistant", "content": "(defmacro nix (&rest places)\n \"Set PLACES to nil and return the old value(s) of PLACES.\n\nIf there is more than one PLACE, return their old values as multiple values.\n\nThis may be more efficient than (shiftf place nil), because it only\nsets PLACE when it is not already null.\"\n `(values\n ,@(loop for place in places\n collect `(nix-1 ,place))))\n\n;; macroexpand:\n(values (serapeum/control-flow::nix-1 nil) (serapeum/control-flow::nix-1 :key)\n (serapeum/control-flow::nix-1 nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(c?1\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by C?1\n\n(c?1\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro c?1 (&body body)\n `(c?once ,@body))\n\n;; macroexpand:\n(c?once\n nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(pprint-coalton-codegen\n common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by PPRINT-COALTON-CODEGEN\n\n(pprint-coalton-codegen\n common-lisp:nil\n :key\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro PPRINT-COALTON-CODEGEN ...)\n\n;; macroexpand:\n(common-lisp:let ((#:package221\n (common-lisp:make-package '#:pprint-codegen-package :use\n '(#:cl))))\n (common-lisp:unwind-protect\n (common-lisp:progn\n (common-lisp:do-symbols\n (coalton-impl/reader::symb common-lisp:*package*)\n (common-lisp:unless\n (common-lisp:nth-value 1\n (common-lisp:find-symbol\n (common-lisp:symbol-name\n coalton-impl/reader::symb)\n #:package221))\n (common-lisp:import coalton-impl/reader::symb #:package221)))\n (common-lisp:let ((common-lisp:*package* #:package221))\n (common-lisp:pprint\n (coalton-codegen\n common-lisp:nil\n :key\n common-lisp:nil))\n (common-lisp:values)))\n (common-lisp:delete-package #:package221)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(make-$instance 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-$INSTANCE\n\n(make-$instance 'some-name)"}, {"role": "assistant", "content": "(defmacro MAKE-$INSTANCE ...)\n\n;; macroexpand:\n(let ((class (symbol-value 'some-name)))\n (funcall (mcs-slot-value class (index-of-basicnew-fn)) class))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(make-name-transformer nil)\n\nPattern to recognize: Macro call that should be transformed by MAKE-NAME-TRANSFORMER\n\n(make-name-transformer nil)"}, {"role": "assistant", "content": "(defmacro make-name-transformer (&rest elements)\n \"Return an accessor name transformer.\nThe unquoted `name' symbol argument is substituted for the slot name.\nClass option examples:\n\n :accessor-name-transformer (make-name-transformer \\\"FOO-\\\" name \\\"-BAR\\\")\n\nUse the slot name directly:\n\n :accessor-name-transformer (make-name-transformer name)\"\n `(lambda (name definition)\n (declare (ignorable definition))\n (concatenate-symbol ,@(mapcar (lambda (el)\n (if (and (symbolp el)\n (string= (symbol-name el) \"NAME\"))\n 'name\n el))\n elements))))\n\n;; macroexpand:\n(lambda (name definition)\n (declare (ignorable definition))\n (concatenate-symbol nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(custom-decoder nil)\n\nProblem: Macro call that should be transformed by CUSTOM-DECODER\n\n(custom-decoder nil)"}, {"role": "assistant", "content": "(defmacro custom-decoder (&rest customizations)\n \"Return a function which is like DECODE-JSON called in a dynamic\nenvironment with the given CUSTOMIZATIONS.\"\n `(lambda (&optional (stream *json-input*))\n (bind-custom-vars ,customizations\n (decode-json stream))))\n\n;; macroexpand:\n(lambda (&optional (stream *json-input*))\n (bind-custom-vars (nil)\n (decode-json stream)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(fn* nil)\n\nProblem: Macro call that should be transformed by FN*\n\n(fn* nil)"}, {"role": "assistant", "content": "(defmacro fn* (form &environment env)\n (fn*-internals form env))\n\n;; macroexpand:\n(lambda () nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda-match*)\n\nWrite a macro that addresses: Macro call that should be transformed by LAMBDA-MATCH*\n\n(lambda-match*)"}, {"role": "assistant", "content": "(defmacro lambda-match* (&body body)\n \"Equivalent to (lambda (args...) (match* (args...) BODY...)).\"\n (multiple-value-bind (preamble clauses) (parse-matcher-body body)\n (let ((gensyms (make-gensyms (caar clauses))))\n `(lambda ,gensyms\n ,@preamble\n (match* ,gensyms\n ,@clauses)))))\n\n;; macroexpand:\n(common-lisp:lambda () (match* common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(local*\n 'some-name)\n\nPattern to recognize: Macro call that should be transformed by LOCAL*\n\n(local*\n 'some-name)"}, {"role": "assistant", "content": "(defmacro local* (&body body)\n \"Like `local', but leave the last form in BODY intact.\n\n (local*\n (defun aux-fn ...)\n (defun entry-point ...))\n =>\n (labels ((aux-fn ...))\n (defun entry-point ...))\"\n `(local\n ,@(butlast body)\n (without-internal-definitions ,@(last body))))\n\n;; macroexpand:\n(local\n (serapeum/internal-definitions::without-internal-definitions\n 'some-name))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(deftype nil (progn))\n\nProblem: Macro call that should be transformed by DEFTYPE\n\n(deftype nil (progn))"}, {"role": "assistant", "content": "(defmacro DEFTYPE ...)\n\n;; macroexpand:\n(progn\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (sb-impl::%deftype 'nil\n (sb-int:named-lambda (sb-impl::type-expander nil)\n (#:expr)\n (declare (sb-c::lambda-list (progn)))\n (sb-int:named-ds-bind (:macro nil . deftype)\n (progn)\n (cdr #:expr)\n (declare (sb-c::constant-value progn))))\n nil)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(2nd nil)\n\nProblem: Macro call that should be transformed by 2ND\n\n(2nd nil)"}, {"role": "assistant", "content": "(defmacro 2nd (form)\n \"(NTH-VALUE 1 FORM)\"\n `(nth-value 1 ,form))\n\n;; macroexpand:\n(nth-value 1 nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(one-value nil)\n\nProblem: Macro call that should be transformed by ONE-VALUE\n\n(one-value nil)"}, {"role": "assistant", "content": "(defmacro ONE-VALUE ...)\n\n;; macroexpand:\n(block one-value\n (for-effects\n (return-from one-value nil))\n (fail))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(isnt-values nil)\n\nPattern to recognize: Macro call that should be transformed by ISNT-VALUES\n\n(isnt-values nil)"}, {"role": "assistant", "content": "(defmacro isnt-values (form &body body)\n (multiple-value-bind (comp-expected expected comparison description format-args)\n (destructure-is-values-body body)\n `(eval-in-context\n *context*\n (make-instance 'multiple-value-comparison-result\n :expression '(isnt-values ,form ,@comp-expected)\n :value-form ',form\n :body (lambda () ,form)\n :expected (list ,@expected)\n :comparison (list ,@comparison)\n :comparison-geq NIL\n ,@(when description\n `(:description (format NIL ,description ,@format-args)))))))\n\n;; macroexpand:\n(eval-in-context *context*\n (make-instance 'multiple-value-comparison-result :expression\n '(isnt-values nil) :value-form 'nil :body\n (lambda () nil) :expected (list) :comparison\n (list) :comparison-geq nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(fbind* nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by FBIND*\n\n(fbind* nil\n (progn))"}, {"role": "assistant", "content": "(defmacro fbind* (bindings &body body &environment env)\n \"Like `fbind', but creates bindings sequentially.\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbind* `(locally ,@body)))\n (mvlet* ((fn (caar bindings))\n (body decls (parse-body body))\n (local others (partition-declarations `((function ,fn))\n decls\n env)))\n `(fbind (,(first bindings))\n ,@local\n (fbind* ,(rest bindings)\n ,@others\n ,@body))))\n\n;; macroexpand:\n(locally (progn))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(the-kids 'some-name)\n\nIssue: Macro call that should be transformed by THE-KIDS\n\n(the-kids 'some-name)"}, {"role": "assistant", "content": "(defmacro the-kids (&rest kids)\n `(let ((*parent* self))\n (packed-flat! ,@kids)))\n\n;; macroexpand:\n(let ((*parent* self))\n (packed-flat! 'some-name))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(fail nil nil)\n\nIssue: Macro call that should be transformed by FAIL\n\n(fail nil nil)"}, {"role": "assistant", "content": "(defmacro fail (form &optional (type 'error) description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(fail ,form ,type)\n :value-form '(capture-error ,form)\n :body (lambda () (capture-error ,form ,(maybe-unquote type)))\n :expected ',(maybe-unquote type)\n :comparison 'typep\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))\n\n;; macroexpand:\n(eval-in-context *context*\n (make-instance 'comparison-result :expression '(fail nil nil)\n :value-form '(capture-error nil) :body\n (lambda () (capture-error nil nil)) :expected\n 'nil :comparison 'typep))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(awhen nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by AWHEN\n\n(awhen nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro awhen (test &body body)\n \"Like WHEN, except binds the result of the test to IT (via LET) for the scope\nof the body.\"\n `(anaphoric when ,test ,@body))\n\n;; macroexpand:\n(anaphoric when\n nil\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(implies nil nil)\n\nWhat needs to change: Macro call that should be transformed by IMPLIES\n\n(implies nil nil)"}, {"role": "assistant", "content": "(defmacro implies (condition consequent)\n \"A boolean operator that evaluates to the value of CONSEQUENT if CONDITION is\n true, and otherwise evaluates to T. This isn't particularly specific to Quid\n Pro Quo, but it is a useful logical operator for contracts.\"\n `(if ,condition ,consequent t))\n\n;; macroexpand:\n(if nil\n nil\n t)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(export-only-always 'some-name)\n\nProblem: Macro call that should be transformed by EXPORT-ONLY-ALWAYS\n\n(export-only-always 'some-name)"}, {"role": "assistant", "content": "(defmacro export-only-always (symbols &optional (package nil package-supplied?))\n \"Like `export-only', but also evaluated at compile time.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (export-only ,symbols ,@(and package-supplied? (list package)))))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute) (export-only 'some-name))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(ensure-gethash nil nil)\n\nIssue: Macro call that should be transformed by ENSURE-GETHASH\n\n(ensure-gethash nil nil)"}, {"role": "assistant", "content": "(defmacro ensure-gethash (key hash-table &optional default)\n \"Like GETHASH, but if KEY is not found in the HASH-TABLE saves the DEFAULT\nunder key before returning it. Secondary return value is true if key was\nalready in the table.\"\n (once-only (key hash-table)\n (with-unique-names (value presentp)\n `(multiple-value-bind (,value ,presentp) (gethash ,key ,hash-table)\n (if ,presentp\n (values ,value ,presentp)\n (values (setf (gethash ,key ,hash-table) ,default) nil))))))\n\n;; macroexpand:\n(let ((#:key165 nil) (#:hash-table166 nil))\n (multiple-value-bind (#:value167 #:presentp168)\n (gethash #:key165 #:hash-table166)\n (if #:presentp168\n (values #:value167 #:presentp168)\n (values (setf (gethash #:key165 #:hash-table166) nil) nil))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(make-simple-appender-to-place nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-SIMPLE-APPENDER-TO-PLACE\n\n(make-simple-appender-to-place nil)"}, {"role": "assistant", "content": "(defmacro MAKE-SIMPLE-APPENDER-TO-PLACE ...)\n\n;; macroexpand:\n(progn\n (setf nil (alexandria:ensure-list nil))\n (let ((#:tail131 (last nil)))\n (lambda (&rest values) (append-at-end nil #:tail131 values) nil)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(collect-last 'some-name)\n\nProblem: Macro call that should be transformed by COLLECT-LAST\n\n(collect-last 'some-name)"}, {"role": "assistant", "content": "(defmacro COLLECT-LAST ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-533 (generator 'some-name))\n #:items-527\n (#:item-529 nil))\n (declare (type generator #:generator-533)\n (type (null-or t) #:item-529))\n (tagbody\n #:ll-534\n (setq #:items-527 (next-in #:generator-533 (go end)))\n (setq #:item-529 #:items-527)\n (go #:ll-534)\n end)\n #:item-529)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(ok nil nil)\n\nPattern to recognize: Macro call that should be transformed by OK\n\n(ok nil nil)"}, {"role": "assistant", "content": "(defmacro ok (offset value)\n \"Parsing was successful.\"\n `(values ,value ,offset))\n\n;; macroexpand:\n(values nil nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(do-generators nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DO-GENERATORS\n\n(do-generators nil\n (progn))"}, {"role": "assistant", "content": "(defmacro do-generators (genspecs &body body)\n \"Simultaneously iterate through multiple generators at once. By default \ndo-generators terminates when the shortest generator ends, but individual \ngenerators can be padded out with the :fill-value keyword. Do-generators can \nalso iterate over lists in parallel with generators. To use lists, start the genspec with the :list keyword. Eg:\n (do-generators ((a (repeat 2))\n\t\t\t (:list b '(4 5 6))\n\t\t\t (c (list->generator '(8 9)) :fill-value 30))\n\t (print (* a (+ b c))))\n24 \n28 \n72 \nNIL\"\n (let ((genspecs (mapcar #'proc-list-spec genspecs))\n\t(genr (gensym))\n\t(data (gensym))\n\t(sig (gensym)))\n (multiple-value-bind (varnames specs)\n\t(process-genspecs genspecs)\n \n `(let ((,genr (multi-gen ,@specs)))\n\t (loop do\n\t (destructuring-bind (,sig . ,data) \n\t (multiple-value-list (next-generator-value ,genr))\n\t (unless ,sig\n\t (return))\n\t ,(bind-clause data varnames body)))))))\n\n;; macroexpand:\n(let ((#:g146 (multi-gen)))\n (loop do (destructuring-bind\n (#:g148 . #:g147)\n (multiple-value-list (next-generator-value #:g146))\n (unless #:g148 (return))\n (let ()\n (progn)))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(c?dbg\n nil\n (progn))\n\nProblem: Macro call that should be transformed by C?DBG\n\n(c?dbg\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro c?dbg (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :debug t\n :rule (c-lambda ,@body)))\n\n;; macroexpand:\n(make-c-dependent :code '(nil (progn)) :value-state :unevaluated :debug t :rule\n (c-lambda\n nil\n (progn)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(removef nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by REMOVEF\n\n(removef nil (progn))"}, {"role": "assistant", "content": "(defmacro REMOVEF ...)\n\n;; macroexpand:\n(setq nil (remove/swapped-arguments nil (progn)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(define-definition-resolver nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-DEFINITION-RESOLVER\n\n(define-definition-resolver nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro define-definition-resolver (name args &body body)\n `(progn (setf (definition-resolver ',name)\n (lambda ,args ,@body))\n ',name))\n\n;; macroexpand:\n(progn (setf (definition-resolver 'nil) (lambda :key nil)) 'nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(collect-max nil nil)\n\nProblem: Macro call that should be transformed by COLLECT-MAX\n\n(collect-max nil nil)"}, {"role": "assistant", "content": "(defmacro COLLECT-MAX ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-353 (generator nil))\n #:items-343\n (#:generator-351 (generator nil))\n #:numbers-342\n (#:number-345 nil)\n #:result-346)\n (declare (type generator #:generator-353)\n (type generator #:generator-351)\n (type (null-or t) #:result-346))\n (tagbody\n #:ll-354\n (setq #:items-343 (next-in #:generator-353 (go end)))\n (setq #:numbers-342 (next-in #:generator-351 (go end)))\n (if (or (null #:number-345) (< #:number-345 #:numbers-342))\n (setq #:number-345 #:numbers-342\n #:result-346 #:items-343))\n (go #:ll-354)\n end)\n (if (null #:number-345)\n (setq #:result-346 nil))\n #:result-346)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(finc 'some-name)\n\nProblem: Macro call that should be transformed by FINC\n\n(finc 'some-name)"}, {"role": "assistant", "content": "(defmacro finc (place &optional (delta 1))\n \"DEPRECATED: use `shift-incf' instead.\"\n (simple-style-warning \"~s is deprecated, use ~s instead\"\n 'finc 'shift-incf)\n `(shift-incf ,place ,delta))\n\n;; macroexpand:\n(shift-incf 'some-name 1)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(-<>> nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by -<>>\n\n(-<>> nil\n (progn))"}, {"role": "assistant", "content": "(defmacro -<>> (init &body exps) (diamond-wand init exps t))\n\n;; macroexpand:\n(progn nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(js-inline nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by JS-INLINE\n\n(js-inline nil nil)"}, {"role": "assistant", "content": "(defmacro JS-INLINE ...)\n\n;; macroexpand:\n(js-inline* '(progn nil nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(fgatherlet nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FGATHERLET\n\n(fgatherlet nil)"}, {"role": "assistant", "content": "(defmacro FGATHERLET ...)\n\n;; macroexpand:\n(flet nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(with-shuffling\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-SHUFFLING\n\n(with-shuffling\n nil)"}, {"role": "assistant", "content": "(defmacro with-shuffling (&body body)\n (let ((thunk (gensym \"THUNK\")))\n `(dolist (,thunk (shuffle\n (list ,@(loop for form in body\n collect `(lambda () ,form)))))\n (funcall ,thunk))))\n\n;; macroexpand:\n(dolist (#:thunk122 (shuffle (list (lambda () nil)))) (funcall #:thunk122))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(enable-readtime-wrapper-syntax)\n\nPattern to recognize: Macro call that should be transformed by ENABLE-READTIME-WRAPPER-SYNTAX\n\n(enable-readtime-wrapper-syntax)"}, {"role": "assistant", "content": "(defmacro ENABLE-READTIME-WRAPPER-SYNTAX ...)\n\n;; macroexpand:\n(eval-when (:compile-toplevel :execute)\n (setf *readtable* (copy-readtable *readtable*))\n (set-readtime-wrapper-syntax-in-readtable #\\LEFT_CURLY_BRACKET\n #\\RIGHT_CURLY_BRACKET)\n (values))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-custom-decoder-level 'some-name)\n\nProblem: Macro call that should be transformed by WITH-CUSTOM-DECODER-LEVEL\n\n(with-custom-decoder-level 'some-name)"}, {"role": "assistant", "content": "(defmacro with-custom-decoder-level ((&rest customizations) &body body)\n \"Execute BODY in a dynamic environment such that, when nested\nstructures are decoded, the outermost level is decoded with the given\ncustom handlers (CUSTOMIZATIONS) whereas inner levels are decoded in\nthe usual way.\"\n `(let ((current-decoder\n (current-decoder\n ,@(loop for (key value) on customizations by #'cddr\n if (eq key :internal-decoder)\n do (error \"~S ~S customization is meaningless in ~\n the context of WITH-CUSTOM-DECODER-LEVEL.\"\n key value)\n else collect key))))\n (bind-custom-vars (:internal-decoder current-decoder ,@customizations)\n ,@body)))\n\n;; macroexpand:\n(let ((current-decoder (current-decoder quote)))\n (bind-custom-vars (:internal-decoder current-decoder quote some-name)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(defiter nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFITER\n\n(defiter nil\n (progn))"}, {"role": "assistant", "content": "(defmacro DEFITER ...)\n\n;; macroexpand:\n(defun nil (progn) (make-instance 'iterator :coro (lambda-coro)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(dynamic-extent common-lisp:nil\n :key\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by DYNAMIC-EXTENT\n\n(dynamic-extent common-lisp:nil\n :key\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro DYNAMIC-EXTENT ...)\n\n;; macroexpand:\n(cl-annot-revisit-at-macro::add-declaration (common-lisp:dynamic-extent)\n :key\n common-lisp:nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(cmatch 'some-name)\n\nProblem: Macro call that should be transformed by CMATCH\n\n(cmatch 'some-name)"}, {"role": "assistant", "content": "(defmacro cmatch (arg &body clauses)\n \"Same as MATCH, except a continuable MATCH-ERROR will be raised if none of the\nclauses match.\"\n (once-only (arg)\n (let ((else `(cerror \"Continue.\"\n 'match-error\n :values (list ,arg)\n :patterns ',(mapcar (lambda (c) (list (car c))) clauses))))\n (compile-match-1 arg clauses else))))\n\n;; macroexpand:\n(let ((#:arg126 'some-name))\n (cerror \"Continue.\" 'match-error :values (list #:arg126) :patterns 'nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(cond->> 'some-name)\n\nWhat needs to change: Macro call that should be transformed by COND->>\n\n(cond->> 'some-name)"}, {"role": "assistant", "content": "(defmacro cond->> (init &body exps) (cond-arrow-macro init exps t))\n\n;; macroexpand:\n(-> 'some-name)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(prog2 nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by PROG2\n\n(prog2 nil :key nil)"}, {"role": "assistant", "content": "(defmacro PROG2 ...)\n\n;; macroexpand:\n(prog1 (progn nil :key) nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(fmv 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by FMV\n\n(fmv 'some-name)"}, {"role": "assistant", "content": "(defmacro fmv (name)\n `(value (fm-other ,name)))\n\n;; macroexpand:\n(value (fm-other 'some-name))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(etypecase nil (progn))\n\nPattern to recognize: Macro call that should be transformed by ETYPECASE\n\n(etypecase nil (progn))"}, {"role": "assistant", "content": "(defmacro ETYPECASE ...)\n\n;; macroexpand:\n(let ((#:nil nil))\n (declare (ignorable #:nil))\n (cond ((typep #:nil 'progn) nil)\n (t (sb-kernel:etypecase-failure #:nil '(progn)))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(eval-when-load\n 'some-name)\n\nWhat needs to change: Macro call that should be transformed by EVAL-WHEN-LOAD\n\n(eval-when-load\n 'some-name)"}, {"role": "assistant", "content": "(defmacro EVAL-WHEN-LOAD ...)\n\n;; macroexpand:\n(common-lisp:eval-when (:load-toplevel) 'some-name)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(defproxymethod nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFPROXYMETHOD\n\n(defproxymethod nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro defproxymethod (qualifier class proxy-node &body body)\n \"define a method for a proxy node\"\n (if (eql :self qualifier)\n `(progn \n\t (setf (gethash (find-class ',(gethash proxy-node *proxy-node*))\n\t\t\t*ignore-node*) t)\n\t (defmethod traverser\n\t (,class\n\t (item ,(gethash proxy-node *proxy-node*)) level)\n\t (declare (ignorable level))\n\t (with-slots (values subnodes parent) item ,@body)\n\t (call-next-method)))\n `(defmethod traverser ,qualifier\n\t (,class\n\t (item ,(gethash proxy-node *proxy-node*)) level)\n\t (declare (ignorable level))\n\t (with-slots (values subnodes parent) item ,@body))))\n\n;; macroexpand:\n(defmethod traverser nil (:key (item nil) level)\n (declare (ignorable level))\n (with-slots (values subnodes parent)\n item))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(dynamic-extent common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by DYNAMIC-EXTENT\n\n(dynamic-extent common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro DYNAMIC-EXTENT ...)\n\n;; macroexpand:\n(cl-annot-revisit-at-macro::add-declaration (common-lisp:dynamic-extent)\n common-lisp:nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(c?_\n nil)\n\nPattern to recognize: Macro call that should be transformed by C?_\n\n(c?_\n nil)"}, {"role": "assistant", "content": "(defmacro c?_ (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :lazy t\n :rule (c-lambda ,@body)))\n\n;; macroexpand:\n(make-c-dependent :code '(nil) :value-state :unevaluated :lazy t :rule\n (c-lambda\n nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(producing)\n\nPattern to recognize: Macro call that should be transformed by PRODUCING\n\n(producing)"}, {"role": "assistant", "content": "(defmacro PRODUCING ...)\n\n;; macroexpand:\n(non-opt-producing)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defpsmacro nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPSMACRO\n\n(defpsmacro nil\n (progn))"}, {"role": "assistant", "content": "(defmacro DEFPSMACRO ...)\n\n;; macroexpand:\n(progn\n nil\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (gethash 'nil *macro-toplevel*)\n (lambda (#:|ps-macro-form-arg-195|)\n (destructuring-bind (progn) (cdr #:|ps-macro-form-arg-195|))))\n (setf (gethash 'nil *macro-toplevel-lambda-list*) '(progn))\n 'nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(html nil (progn))\n\nProblem: Macro call that should be transformed by HTML\n\n(html nil (progn))"}, {"role": "assistant", "content": "(defmacro html (&rest tags)\n `(with-doctype :html\n (tag->string (cons :html ',tags))))\n\n;; macroexpand:\n(with-doctype :html\n (tag->string (cons :html '(nil (progn)))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(->> 'some-name)\n\nProblem: Macro call that should be transformed by ->>\n\n(->> 'some-name)"}, {"role": "assistant", "content": "(defmacro ->> (init &body exps) (arrow-macro init exps t))\n\n;; macroexpand:\n'some-name"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(rotatef nil)\n\nIssue: Macro call that should be transformed by ROTATEF\n\n(rotatef nil)"}, {"role": "assistant", "content": "(defmacro ROTATEF ...)\n\n;; macroexpand:\n(let* ()\n (multiple-value-bind (#:new268) nil (setq nil #:new268) nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(with-synapse nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-SYNAPSE\n\n(with-synapse nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-synapse (synapse-id (&rest closure-vars) &body body)\n (let ((syn-id (gensym)))\n `(let* ((,syn-id ,synapse-id)\n (synapse (or (find ,syn-id (cd-useds *depender*) :key 'c-slot-name)\n (let ((new-syn\n (let (,@closure-vars)\n (make-c-dependent\n :model (c-model *depender*)\n :slot-name ,syn-id\n :code ',body\n :synaptic t\n :rule (c-lambda ,@body)))))\n (record-caller new-syn)\n new-syn))))\n (prog1\n (multiple-value-bind (v p)\n (with-integrity ()\n (ensure-value-is-current synapse :synapse *depender*))\n (values v p))\n (record-caller synapse)))))\n\n;; macroexpand:\n(let* ((#:g177 nil)\n (synapse\n (or (find #:g177 (cd-useds *depender*) :key 'c-slot-name)\n (let ((new-syn\n (let :key\n (make-c-dependent :model (c-model *depender*) :slot-name\n #:g177 :code '(nil) :synaptic t :rule\n (c-lambda\n nil)))))\n (record-caller new-syn)\n new-syn))))\n (prog1\n (multiple-value-bind (v p)\n (with-integrity nil\n (ensure-value-is-current synapse :synapse\n *depender*))\n (values v p))\n (record-caller synapse)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(defmethod* nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by DEFMETHOD*\n\n(defmethod* nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro DEFMETHOD* ...)\n\n;; macroexpand:\n(defmethod :key nil (the t ()))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(defreply nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFREPLY\n\n(defreply nil\n nil)"}, {"role": "assistant", "content": "(defmacro DEFREPLY ...)\n\n;; macroexpand:\n(progn\n (eval-when (:compile-toplevel)\n (unless (fboundp 'nil)\n (warn 'automatic-message-creation :message-name 'nil)\n (ensure-message 'nil :lambda-list 'nil)))\n (ensure-reply 'nil :qualifiers 'nil :lambda-list 'nil :participants (list)\n :documentation nil :function\n (lambda (#:args136 #:next-replies137 &rest #:more-args139)\n (declare\n (ignorable #:args136 #:next-replies137 #:more-args139))\n (flet ((next-reply-p ()\n (not (null #:next-replies137)))\n (call-next-reply (&rest args)\n (if (null #:next-replies137)\n (apply 'no-next-reply\n (getf #:more-args139 :message)\n (getf #:more-args139 :reply)\n (or args #:args136))\n (apply (reply-function (car #:next-replies137))\n (or args #:args136)\n (cdr #:next-replies137) #:more-args139))))\n (declare\n (ignorable (function next-reply-p)\n (function call-next-reply)))\n (flet ((#:reply-function138 ()\n (declare (ignorable))\n (block nil)))\n (declare (inline #:reply-function138))\n (apply #'#:reply-function138 #:args136))))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(lambda-match\n common-lisp:nil\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-MATCH\n\n(lambda-match\n common-lisp:nil\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro lambda-match (&body body)\n \"Equivalent to (lambda (arg) (match arg BODY...)).\"\n (multiple-value-bind (preamble clauses) (parse-matcher-body body)\n (with-gensyms (clause)\n `(lambda (,clause)\n ,@preamble\n (match ,clause\n ,@clauses)))))\n\n;; macroexpand:\n(common-lisp:lambda (#:clause176)\n (match #:clause176\n common-lisp:nil\n common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(c_?dbg\n 'some-name)\n\nProblem: Macro call that should be transformed by C_?DBG\n\n(c_?dbg\n 'some-name)"}, {"role": "assistant", "content": "(defmacro c_?dbg (&body body)\n \"Lazy until asked, then eagerly propagating\"\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :lazy :until-asked\n :rule (c-lambda ,@body)\n :debug t))\n\n;; macroexpand:\n(make-c-dependent :code '('some-name) :value-state :unevaluated :lazy\n :until-asked :rule\n (c-lambda\n 'some-name)\n :debug t)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-read-only-vars nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-READ-ONLY-VARS\n\n(with-read-only-vars nil\n (progn))"}, {"role": "assistant", "content": "(defmacro with-read-only-vars ((&rest vars) &body body &environment env)\n \"Make VARS read-only within BODY.\n\nThat is, within BODY, each var in VARS is bound as a symbol macro,\nwhich expands into a macro whose setf expander, in turn, is defined to\nsignal a warning at compile time, and an error at run time.\n\nDepending on your Lisp implementation this may or may not do anything,\nand may or may not have an effect when used on special variables.\"\n (declare (ignorable env))\n (case uiop:*implementation-type*\n ((:ccl :sbcl :cmu :acl)\n ;; The use of temps here, while it is ugly and annoying when\n ;; debugging, is necessary to prevent symbol-macrolet from going\n ;; into an infinite loop.\n (let* ((vars (loop for var in vars\n unless (variable-special? var env)\n collect var))\n (temps\n (loop for var in vars\n collect (gensym (string var)))))\n `(let ,(mapcar #'list temps vars)\n (declare (ignorable ,@temps))\n (symbol-macrolet ,(loop for var in vars\n for temp in temps\n collect `(,var (read-only-var ,temp ,var)))\n ,@body))))\n (t\n `(locally ,@body))))\n\n;; macroexpand:\n(let ()\n (declare (ignorable))\n (symbol-macrolet ()\n (progn)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(batch\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by BATCH\n\n(batch\n nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro batch (&body forms)\n \"Batch assignments to the values of mutable cells.\n\nThe forms in FORMS are evaluated, in an implicit PROGN, with mutable\ncell assignment batching in effect. This means that when the value of\na mutable cell is set by SETF within the dynamic extent of the BATCH\nform, the observers of the cell are only notified after the last form\nin FORMS is evaluated, or the BATCH form is exited by a non-local exit\nsuch as by RETURN-FROM. The effect of this is that the cells appear to\nhave their values changed simultaneously.\n\n.. note::\n\n When a BATCH form is nested in the dynamic extent of another BATCH\n form, the nested BATCH form has no effect other than to evaluate\n FORMS. The observers of the cells are only notified when exiting\n the outermost BATCH form.\n\nReturns the value of the last form in FORMS.\"\n\n `(if *batch-in-effect-p*\n (progn ,@forms)\n\n (let ((*batch-in-effect-p* t)\n (*batch-list* nil))\n\n (unwind-protect (progn ,@forms)\n (end-batch)))))\n\n;; macroexpand:\n(if *batch-in-effect-p*\n (progn nil :key nil)\n (let ((*batch-in-effect-p* t) (*batch-list* nil))\n (unwind-protect (progn nil :key nil) (end-batch))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(with-context-variables nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-CONTEXT-VARIABLES\n\n(with-context-variables nil\n nil)"}, {"role": "assistant", "content": "(defmacro with-context-variables ((&rest vars) &body body)\n `(symbol-macrolet\n ,(loop for var in vars\n for form = `(context ,(intern (string var) :keyword))\n collect `(,var ,form))\n ,@body))\n\n;; macroexpand:\n(symbol-macrolet ()\n nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(is-condition nil nil)\n\nIssue: Macro call that should be transformed by IS-CONDITION\n\n(is-condition nil nil)"}, {"role": "assistant", "content": "(defmacro is-condition (form condition &optional desc)\n (with-gensyms (error duration)\n `(with-duration ((,duration ,error) (handler-case ,form\n (condition (,error) ,error)))\n (test ,error\n ,(if (and (listp condition) (eq 'quote (car condition)))\n condition\n `(quote ,condition))\n ,desc\n :duration ,duration\n :got-form ',form\n :test-fn #'typep\n :report-expected-label \"raise a condition\"))))\n\n;; macroexpand:\n(prove.test::with-duration ((#:duration241 #:error240)\n (handler-case nil\n (condition (#:error240) #:error240)))\n (prove.test::test #:error240 'nil nil :duration #:duration241 :got-form 'nil\n :test-fn #'typep :report-expected-label\n \"raise a condition\"))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-logical-transaction nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-LOGICAL-TRANSACTION\n\n(with-logical-transaction nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-logical-transaction ((&optional (name nil name-p)\n (isolation-level *isolation-level*\n isolation-level-p))\n &body body)\n \"Executes body within a with-transaction form if no transaction is currently\nin progress, otherwise simulates a nested transaction by executing it\nwithin a with-savepoint form. The transaction or savepoint is bound to name\nif one is supplied. The isolation-level will set the isolation-level used by\nthe transaction.\n\nYou can specify the following isolation levels in postmodern transactions:\n\n- :read-committed-rw (read committed with read and write)\n- :read-committed-ro (read committed with read only)\n- :repeatable-read-rw (repeatable read with read and write)\n- :repeatable-read-ro (repeatable read with read only)\n- :serializable (serializable with reand and write)\n\nSample usage where george is just the name given to the transaction (not\nquoted or a string) and ... simply indicates other statements would be\nexpected here:\n\n\n (with-logical-transaction ()\n (execute (:insert-into 'test-data :set 'value 77))\n ...)\n\n (with-logical-transaction (george)\n (execute (:insert-into 'test-data :set 'value 22))\n ...)\n\n (with-logical-transaction (george :read-committed-rw)\n (execute (:insert-into 'test-data :set 'value 33))\n ...)\n\n (with-logical-transaction (:serializable)\n (execute (:insert-into 'test-data :set 'value 44))\n ...)\"\n (let* ((effective-name (if (and name-p (not (isolation-level-p name)))\n name\n (gensym)))\n (effective-body (if (and name-p (not (isolation-level-p name)))\n `(lambda (,name) ,@body)\n `(lambda (,effective-name)\n (declare (ignore ,effective-name))\n ,@body)))\n (effective-isolation-level (cond ((and isolation-level-p\n (isolation-level-p isolation-level))\n isolation-level)\n ((and name-p (isolation-level-p name))\n name)\n (t isolation-level))))\n `(call-with-logical-transaction ',effective-name ,effective-body\n ,effective-isolation-level)))\n\n;; macroexpand:\n(call-with-logical-transaction '#:g232\n (lambda (#:g232)\n (declare (ignore #:g232))\n :key\n nil)\n :read-committed-rw)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(known? nil)\n\nWrite a macro that addresses: Macro call that should be transformed by KNOWN?\n\n(known? nil)"}, {"role": "assistant", "content": "(defmacro KNOWN? ...)\n\n;; macroexpand:\n(known?-true nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(define-script-symbol-macro nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-SCRIPT-SYMBOL-MACRO\n\n(define-script-symbol-macro nil\n nil)"}, {"role": "assistant", "content": "(defmacro DEFINE-SCRIPT-SYMBOL-MACRO ...)\n\n;; macroexpand:\n(define-ps-symbol-macro nil nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with-object nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITH-OBJECT\n\n(with-object nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-object ((&optional (stream '*json-output*)) &body body)\n \"Open a JSON Object, run BODY, then close the Object. Inside the BODY,\nAS-OBJECT-MEMBER or ENCODE-OBJECT-MEMBER should be called to encode\nMembers of the Object.\"\n `(with-aggregate (object #\\{ #\\} ,stream) ,@body))\n\n;; macroexpand:\n(with-aggregate (object #\\LEFT_CURLY_BRACKET #\\RIGHT_CURLY_BRACKET\n *json-output*)\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(named-lambda nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by NAMED-LAMBDA\n\n(named-lambda nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro named-lambda (name lambda-list &body body)\n \"Expands into a lambda-expression within whose BODY NAME denotes the\n corresponding function.\"\n `(labels ((,name ,lambda-list ,@body))\n #',name))\n\n;; macroexpand:\n(labels ((nil :key\n nil))\n #'nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(validate-superclass*)\n\nWhat needs to change: Macro call that should be transformed by VALIDATE-SUPERCLASS*\n\n(validate-superclass*)"}, {"role": "assistant", "content": "(defmacro VALIDATE-SUPERCLASS* ...)\n\n;; macroexpand:\n(progn)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(nest nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by NEST\n\n(nest nil :key nil)"}, {"role": "assistant", "content": "(defmacro nest (&rest things)\n \"Like ~>>, but backward.\n\nThis is useful when layering `with-x' macros where the order is not\nimportant, and extra indentation would be misleading.\n\nFor example:\n\n (nest\n (with-open-file (in file1 :direction input))\n (with-open-file (in file2 :direction output))\n ...)\n\nIs equivalent to:\n\n (with-open-file (in file1 :direction input)\n (with-open-file (in file2 :direction output)\n ...))\n\n\\(But see `with-open-files').\n\nIf the outer macro has no arguments, you may omit the parentheses.\n\n (nest\n with-standard-io-syntax\n ...)\n \u2261 (with-standard-io-syntax\n ...)\n\nFrom UIOP, based on a suggestion by Marco Baringer.\"\n (expand-nest things))\n\n;; macroexpand:\n((:key nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(make-name-transformer nil (progn))\n\nIssue: Macro call that should be transformed by MAKE-NAME-TRANSFORMER\n\n(make-name-transformer nil (progn))"}, {"role": "assistant", "content": "(defmacro MAKE-NAME-TRANSFORMER ...)\n\n;; macroexpand:\n(lambda (name definition)\n (declare (ignorable definition))\n (concatenate-symbol nil (progn)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(distinct-on nil :key nil)\n\nIssue: Macro call that should be transformed by DISTINCT-ON\n\n(distinct-on nil :key nil)"}, {"role": "assistant", "content": "(defmacro distinct-on (columns &rest fields)\n `(make-clause :distinct-on (list ,@columns) ,@(mapcar #'expand-op fields)))\n\n;; macroexpand:\n(make-clause :distinct-on (list) :key nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(fgathering nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by FGATHERING\n\n(fgathering nil\n (progn))"}, {"role": "assistant", "content": "(defmacro FGATHERING ...)\n\n;; macroexpand:\n(flet ()\n (progn)\n (values))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(accase nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by ACCASE\n\n(accase nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro accase (keyform &body cases)\n \"Like CCASE, except binds the result of the keyform to IT (via LET) for the\nscope of the cases. Unlike CCASE, the keyform/place doesn't receive new values\npossibly stored with STORE-VALUE restart; the new value is received by IT.\"\n `(anaphoric ccase ,keyform ,@cases))\n\n;; macroexpand:\n(anaphoric ccase\n nil\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(do-all-symbols (quote some-name))\n\nWhat needs to change: Macro call that should be transformed by DO-ALL-SYMBOLS\n\n(do-all-symbols (quote some-name))"}, {"role": "assistant", "content": "(defmacro DO-ALL-SYMBOLS ...)\n\n;; macroexpand:\n(block nil\n (with-package-iterator\n (#:iterator179 (list-all-packages) :internal :external)\n (tagbody\n #:next181\n (multiple-value-bind (#:winp180 quote)\n (#:iterator179)\n (declare (ignorable quote))\n (if #:winp180\n (tagbody (go #:next181))\n (return some-name))))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(c_?\n 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by C_?\n\n(c_?\n 'some-name)"}, {"role": "assistant", "content": "(defmacro c_? (&body body)\n \"Lazy until asked, then eagerly propagating\"\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :lazy :until-asked\n :rule (c-lambda ,@body)))\n\n;; macroexpand:\n(make-c-dependent :code '('some-name) :value-state :unevaluated :lazy\n :until-asked :rule\n (c-lambda\n 'some-name))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(c?n\n nil)\n\nPattern to recognize: Macro call that should be transformed by C?N\n\n(c?n\n nil)"}, {"role": "assistant", "content": "(defmacro c?n (&body body)\n `(make-c-dependent\n :code '(without-c-dependency ,@body)\n :inputp t\n :value-state :unevaluated\n :rule (c-lambda (without-c-dependency ,@body))))\n\n;; macroexpand:\n(make-c-dependent :code\n '(without-c-dependency\n nil)\n :inputp t :value-state :unevaluated :rule\n (c-lambda\n (without-c-dependency\n nil)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(c_?\n nil)\n\nIssue: Macro call that should be transformed by C_?\n\n(c_?\n nil)"}, {"role": "assistant", "content": "(defmacro c_? (&body body)\n \"Lazy until asked, then eagerly propagating\"\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :lazy :until-asked\n :rule (c-lambda ,@body)))\n\n;; macroexpand:\n(make-c-dependent :code '(nil) :value-state :unevaluated :lazy :until-asked\n :rule\n (c-lambda\n nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(with-took-usec nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-TOOK-USEC\n\n(with-took-usec nil\n (progn))"}, {"role": "assistant", "content": "(defmacro with-took-usec (var &body body)\n (let ((before (gensym \"BEFORE\")))\n `(let ((,before (get-internal-real-time)))\n (multiple-value-prog1 (progn ,@body)\n (setf ,var (ceiling\n (* (- (get-internal-real-time) ,before)\n #.(/ 1000000 internal-time-units-per-second))))))))\n\n;; macroexpand:\n(multiple-value-bind (#:before-unixtime171 #:before-usec172)\n (sb-ext:get-time-of-day)\n (multiple-value-prog1 (progn (progn))\n (multiple-value-bind (#:after-unixtime173 #:after-usec174)\n (sb-ext:get-time-of-day)\n (setf nil\n (+ (* (- #:after-unixtime173 #:before-unixtime171) 1000000)\n (- #:after-usec174 #:before-usec172))))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(nand nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by NAND\n\n(nand nil :key nil)"}, {"role": "assistant", "content": "(defmacro nand (&rest forms)\n \"Equivalent to (not (and ...)).\"\n (if (null forms) nil\n (if (null (rest forms))\n `(not ,(first forms))\n `(if ,(first forms)\n (nand ,@(rest forms))\n t))))\n\n;; macroexpand:\n(if nil\n (nand :key nil)\n t)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(collect-nth nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECT-NTH\n\n(collect-nth nil :key nil)"}, {"role": "assistant", "content": "(defmacro COLLECT-NTH ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-420 (generator :key))\n #:items-412\n (#:counter-414 nil)\n (#:item-415 nil))\n (declare (type generator #:generator-420)\n (type (null-or fixnum) #:counter-414)\n (type (null-or t) #:item-415))\n (tagbody\n #:ll-421\n (setq #:items-412 (next-in #:generator-420 (go end)))\n (when (zerop #:counter-414) (setq #:item-415 #:items-412) (go end))\n (decf #:counter-414)\n (go #:ll-421)\n end)\n #:item-415)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(matrix-case nil)\n\nWhat needs to change: Macro call that should be transformed by MATRIX-CASE\n\n(matrix-case nil)"}, {"role": "assistant", "content": "(defmacro MATRIX-CASE ...)\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-stemcell-infer-hook 'some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-STEMCELL-INFER-HOOK\n\n(with-stemcell-infer-hook 'some-name)"}, {"role": "assistant", "content": "(defmacro with-stemcell-infer-hook (func &body body)\n (let ((func-name (gensym \"hook\")))\n `(let* ((,func-name ,func)\n (*stemcell-infer-hook* ,func-name))\n ,@body)))\n\n;; macroexpand:\n(let* ((#:|hook180| 'some-name)\n (varjo.internals::*stemcell-infer-hook* #:|hook180|)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(<*> nil (progn))\n\nPattern to recognize: Macro call that should be transformed by <*>\n\n(<*> nil (progn))"}, {"role": "assistant", "content": "(defmacro <*> (parser &rest parsers)\n \"Combination of parsers yielding all results as a list.\"\n (let ((offset (gensym \"<*>-OFFSET\")))\n `(lambda (,offset)\n ,(labels ((recurse (ps i)\n (if (null ps)\n `(ok ,i nil)\n (let ((res (gensym \"<*>-RES\"))\n (next (gensym \"<*>-NEXT\")))\n `(multiple-value-bind (,res ,next) (funcall ,(car ps) ,i)\n (if (failure? ,res)\n (fail ,next)\n (fmap (lambda (xs) (cons ,res xs))\n ,(recurse (cdr ps) `,next))))))))\n (recurse (cons parser parsers) offset)))))\n\n;; macroexpand:\n(lambda (#:<*>-offset163)\n (multiple-value-bind (#:<*>-res164 #:<*>-next165)\n (funcall nil #:<*>-offset163)\n (if (failure? #:<*>-res164)\n (fail #:<*>-next165)\n (fmap (lambda (xs) (cons #:<*>-res164 xs))\n (multiple-value-bind (#:<*>-res166 #:<*>-next167)\n (funcall (progn) #:<*>-next165)\n (if (failure? #:<*>-res166)\n (fail #:<*>-next167)\n (fmap (lambda (xs) (cons #:<*>-res166 xs))\n (ok #:<*>-next167 nil))))))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(product-of 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by PRODUCT-OF\n\n(product-of 'some-name)"}, {"role": "assistant", "content": "(defmacro PRODUCT-OF ...)\n\n;; macroexpand:\n(lc ('some-name) multiply)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(some-<>> nil\n (progn))\n\nIssue: Macro call that should be transformed by SOME-<>>\n\n(some-<>> nil\n (progn))"}, {"role": "assistant", "content": "(defmacro some-<>> (init &body exps) (diamond-wand init exps t t))\n\n;; macroexpand:\n(block #:g147 (progn (or nil (return-from #:g147 nil))))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(let+ nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LET+\n\n(let+ nil\n nil)"}, {"role": "assistant", "content": "(defmacro LET+ ...)\n\n;; macroexpand:\n(locally nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(wtrc nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WTRC\n\n(wtrc nil\n (progn))"}, {"role": "assistant", "content": "(defmacro wtrc ((&optional (min 1) (max 50) &rest banner) &body body )\n `(let ((*trcdepth* (if *trcdepth*\n (1+ *trcdepth*)\n 0)))\n ,(when banner `(when (>= *trcdepth* ,min)\n (if (< *trcdepth* ,max)\n (trc ,@banner)\n (progn\n (break \"excess trace notttt!!! ~d\" *trcdepth*) ;; ,@banner)\n nil))))\n (when (< *trcdepth* ,max)\n ,@body)))\n\n;; macroexpand:\n(let ((*trcdepth*\n (if *trcdepth*\n (1+ *trcdepth*)\n 0)))\n nil\n (when (< *trcdepth* 50) (progn)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(eval-always\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EVAL-ALWAYS\n\n(eval-always\n nil)"}, {"role": "assistant", "content": "(defmacro eval-always (&body body)\n \"Shorthand for\n (eval-when (:compile-toplevel :load-toplevel :execute) ...)\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n ,@body))\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute) nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(|^K2|)\n\nProblem: Macro call that should be transformed by ^K2\n\n(|^K2|)"}, {"role": "assistant", "content": "(defmacro ^k2 () `(kid2 self))\n\n;; macroexpand:\n(kid2 self)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(is-condition nil :key nil)\n\nIssue: Macro call that should be transformed by IS-CONDITION\n\n(is-condition nil :key nil)"}, {"role": "assistant", "content": "(defmacro is-condition (form condition &optional desc)\n (with-gensyms (error duration)\n `(with-duration ((,duration ,error) (handler-case ,form\n (condition (,error) ,error)))\n (test ,error\n ,(if (and (listp condition) (eq 'quote (car condition)))\n condition\n `(quote ,condition))\n ,desc\n :duration ,duration\n :got-form ',form\n :test-fn #'typep\n :report-expected-label \"raise a condition\"))))\n\n;; macroexpand:\n(prove.test::with-duration ((#:duration245 #:error244)\n (handler-case nil\n (condition (#:error244) #:error244)))\n (prove.test::test #:error244 ':key nil :duration #:duration245 :got-form 'nil\n :test-fn #'typep :report-expected-label\n \"raise a condition\"))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda* nil)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA*\n\n(lambda* nil)"}, {"role": "assistant", "content": "(defmacro LAMBDA* ...)\n\n;; macroexpand:\n(lambda () (with-yield))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(some-<>> 'some-name)\n\nPattern to recognize: Macro call that should be transformed by SOME-<>>\n\n(some-<>> 'some-name)"}, {"role": "assistant", "content": "(defmacro SOME-<>> ...)\n\n;; macroexpand:\n(let* ((#:g134 'some-name))\n #:g134)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(aprog1 nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by APROG1\n\n(aprog1 nil\n nil)"}, {"role": "assistant", "content": "(defmacro aprog1 (first &body rest)\n \"Binds IT to the first form so that it can be used in the rest of the\nforms. The whole thing returns IT.\"\n `(anaphoric prog1 ,first ,@rest))\n\n;; macroexpand:\n(anaphoric prog1\n nil\n nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(decf nil)\n\nWhat needs to change: Macro call that should be transformed by DECF\n\n(decf nil)"}, {"role": "assistant", "content": "(defmacro DECF ...)\n\n;; macroexpand:\n(setq nil (subtract nil 1))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(~> nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ~>\n\n(~> nil)"}, {"role": "assistant", "content": "(defmacro ~> (needle &rest holes)\n \"Threading macro from Clojure (by way of Racket).\n\nThread NEEDLE through HOLES, where each hole is either a\nsymbol (equivalent to `(hole needle)`) or a list (equivalent to `(hole\nneedle args...)`).\n\nAs an extension, an underscore in the argument list is replaced with\nthe needle, so you can pass the needle as an argument other than the\nfirst.\"\n (thread-aux '~> needle holes\n (lambda (needle hole)\n (list* (car hole) needle (cdr hole)))))\n\n;; macroexpand:\nnil"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(match nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by MATCH\n\n(match nil\n (progn))"}, {"role": "assistant", "content": "(defmacro match (adt obj &body clauses)\n \"Perform pattern matching on OBJ with (adt-type) ADT.\n\nEach clause must have the following syntax:\n\n := | '_'\n := '_'\n | ( *)\n := ( )\n\nThe symbol '_' denotes a wildcard, as well as a fallthough.\n\nNote that pattern matching is only shallow (patterns are one-level\ndeep).\n\"\n (assert (symbolp adt)\n (adt)\n \"MATCH requires a symbol for the first argument. Given ~S.\"\n adt)\n\n (let ((ctors (mapcar #'car (get-constructors adt)))\n (types (mapcar (lambda (clause)\n (ensure-car (car clause)))\n clauses))\n (once (gensym \"OBJ-\")))\n\n ;; Check for duplicate matches.\n (let ((dupes (duplicates types)))\n (when dupes\n (warn \"Duplicate matching clauses exist. Duplicate pattern ~\n constructors:~{ ~S~}\"\n dupes)))\n\n ;; Check for match exhaustiveness.\n (unless (some #'wild? types)\n (let ((diff (set-difference ctors types)))\n (when diff\n (warn \"Non-exhaustive match on ~A data ~\n type. Missing cases:~{ ~S~}\" adt diff))))\n\n ;; Generate the matching code.\n `(let ((,once ,obj))\n (check-type ,once ,adt)\n (etypecase ,once\n ,@(loop :for (bindings . body) :in clauses\n :collect (let ((type (ensure-car bindings)))\n (if (wild? type)\n `(t ,@body)\n `(,type\n (with-data ,(ensure-list bindings)\n ,once\n ,@body)))))))))\n\n;; macroexpand:\n(let ((#:obj-135 (progn)))\n (check-type #:obj-135 nil)\n (etypecase #:obj-135))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(dreletf* 'some-name)\n\nIssue: Macro call that should be transformed by DRELETF*\n\n(dreletf* 'some-name)"}, {"role": "assistant", "content": "(defmacro DRELETF* ...)\n\n;; macroexpand:\n(dreletf ('nil)\n (dreletf ((some-name nil))\n (progn)))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-hook-restart\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-HOOK-RESTART\n\n(with-hook-restart\n nil\n (progn))"}, {"role": "assistant", "content": "(defmacro with-hook-restart (&body body)\n `(with-simple-restart (continue \"Call next function in hook ~s\" *hook*)\n ,@body))\n\n;; macroexpand:\n(with-simple-restart (continue \"Call next function in hook ~s\" *hook*)\n nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(case-using nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by CASE-USING\n\n(case-using nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro case-using (pred keyform &body clauses)\n \"ISLISP's case-using.\n\n (case-using #'eql x ...)\n \u2261 (case x ...).\n\nNote that, no matter the predicate, the keys are not evaluated. (But\nsee `selector'.)\n\nThe PRED form is evaluated.\n\nWhen PRED is invoked, KEYFORM is its first argument. You can use\n`flip' if you want the arguments passed the other way around. For\nexample, to dispatch on potential elements of a list:\n\n (case-using list (flip #'member)\n (:item1 ...))\n\nThis version supports both single-item clauses (x ...) and\nmultiple-item clauses ((x y) ...), as well as (t ...) or (otherwise\n...) for the default clause.\"\n (case (extract-function-name pred)\n (eql\n `(case ,keyform\n ,@clauses))\n ;; TODO Check that this isn't rebound in the environment. (Not a\n ;; concern on SBCL as the package is locked there.)\n (string=\n `(string-case ,keyform\n ,@clauses))\n (t `(case-using-aux ,pred ,keyform\n ,@clauses))))\n\n;; macroexpand:\n(serapeum/control-flow::case-using-aux nil\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(jbind nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by JBIND\n\n(jbind nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro jbind (destructuring-pattern form &body body)\n \"Match the FORM against DESTRUCTURING-PATTERN.\nThe pattern might be:\n- A symbol, in which case the current chosen form is bound to it. If\n the symbol is _, simply skip the form.\n- A literal form:\n - String or number: compare with `equal'.\n - Keywords :TRUE, :FALSE, and :NULL, matching T, NIL, and :NULL\n respectively.\n- If the pattern is a property list of string+pattern pairs, match the\n string+pattern pairs inside it to the provided JSON object and\n resolve them recursively.\n- If the pattern is a list of symbols (VAR &optional VAR-P), these are\n bound to the respective values of `jget'. It is a good way to make\n `jbind' to be more lenient to missing keys, because the default\n behavior is to error on missing data.\n- If the pattern is an inline vector, match it against a JSON array\n with at least as many elements as provided in the vector. Match\n every form in the vector against the element with the same index.\n\nIf the DESTRUCTURING-PATTERN doesn't match the object, throw\n`value-mismatch'.\n\nUnderlying `jget' can throw errors for the exceptionally malformed\ninputs. See `jget' documentation for the types of errors it throws.\n\nExample:\n\\(\\\"hello\\\" hello \\\"a\\\" _ \\\"b\\\" b\n \\\"array\\\" #(first second third _))\n\nmatches a JSON object\n{\\\"hello\\\": 3, \\\"a\\\": 8, \\\"b\\\": 3, \\\"c\\\": null, \\\"array\\\": [1, 2, 3, 4]}\n\nand binds\n- HELLO to 3\n- B to 3\n- FIRST to 1\n- SECOND to 2\n- THIRD to 3\n\nIt also checks that \\\"a\\\" key is present in the object and there's a\nfourth element in the nested array.\n\nSee more examples in njson tests.\"\n (let ((form-sym (gensym \"BIND-FORM\"))\n (bindings (list)))\n (labels ((parse-pattern (pattern &optional (current-path (list)))\n (etypecase pattern\n ((or (member :true :false :null) string real)\n (push (cons pattern (copy-list current-path))\n bindings))\n ((cons symbol *)\n (push (cons pattern (copy-list current-path))\n bindings))\n (list\n (loop for (key subpattern) on pattern by #'cddr\n do (parse-pattern subpattern (append current-path (list key))))\n (push (cons nil (copy-list current-path))\n bindings))\n ((and symbol (not keyword))\n (push (cons (if (equal \"_\" (symbol-name pattern))\n (gensym \"_PATTERN\")\n pattern)\n (copy-list current-path))\n bindings))\n (array\n\t\t (loop for elem across pattern\n for index from 0\n do (parse-pattern elem (append current-path (list index))))\n\t\t (push (cons #() (copy-list current-path))\n\t\t\tbindings)))))\n (check-type destructuring-pattern (or list (and array (not string))\n (and symbol (not keyword)))\n \"proper jbind destructuring pattern: list, array, or symbol\")\n (parse-pattern destructuring-pattern)\n (let ((let-forms (loop for (binding . key) in bindings\n do (check-type binding (or array real symbol\n ;; For (VAR VAR-P) forms\n (cons symbol (or (cons symbol null)\n null))))\n if (typep binding '(or array real null\n (member :true :false :null)))\n collect `(,(gensym) (check-value ,binding (vector ,@key) ,form-sym))\n else if (and (symbolp binding)\n (uiop:emptyp key))\n collect `(,binding ,form-sym)\n else if (listp binding)\n append (destructuring-bind (var &optional (var-p nil var-p-provided))\n binding\n (append\n `((,var (jget (vector ,@key) ,form-sym)))\n (when var-p-provided\n `((,var-p (nth-value 1 (jget (vector ,@key) ,form-sym)))))))\n else\n collect `(,binding (check-value t (vector ,@key) ,form-sym)))))\n `(let* ((,form-sym ,form)\n ,@let-forms)\n (declare (ignorable ,form-sym ,@(mapcar #'first let-forms)))\n ,@body))))\n\n;; macroexpand:\n(let* ((#:bind-form133 :key) (#:g134 (check-value nil (vector) #:bind-form133)))\n (declare (ignorable #:bind-form133 #:g134))\n nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(atypecase nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by ATYPECASE\n\n(atypecase nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro atypecase (keyform &body cases)\n \"Like TYPECASE, except binds the result of the keyform to IT (via LET) for\nthe scope of the cases.\"\n `(anaphoric typecase ,keyform ,@cases))\n\n;; macroexpand:\n(anaphoric typecase\n nil\n :key\n nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(multiple-value-prog2 nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by MULTIPLE-VALUE-PROG2\n\n(multiple-value-prog2 nil\n nil)"}, {"role": "assistant", "content": "(defmacro multiple-value-prog2 (first-form second-form &body forms)\n \"Evaluates FIRST-FORM, then SECOND-FORM, and then FORMS. Yields as its value\nall the value returned by SECOND-FORM.\"\n `(progn ,first-form (multiple-value-prog1 ,second-form ,@forms)))\n\n;; macroexpand:\n(progn nil (multiple-value-prog1 nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(some->> nil)\n\nIssue: Macro call that should be transformed by SOME->>\n\n(some->> nil)"}, {"role": "assistant", "content": "(defmacro SOME->> ...)\n\n;; macroexpand:\n(let* ((#:g125 nil))\n #:g125)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(collect nil)\n\nWhat needs to change: Macro call that should be transformed by COLLECT\n\n(collect nil)"}, {"role": "assistant", "content": "(defmacro COLLECT ...)\n\n;; macroexpand:\n(common-lisp:let* ((#:generator-581 (generator nil))\n #:items-576\n (#:lastcons-577 (list nil))\n (#:lst-578 #:lastcons-577))\n (declare (type generator #:generator-581)\n (type cons #:lastcons-577)\n (type list #:lst-578))\n (tagbody\n #:ll-582\n (setq #:items-576 (next-in #:generator-581 (go end)))\n (setq #:lastcons-577 (setf (cdr #:lastcons-577) (cons #:items-576 nil)))\n (go #:ll-582)\n end)\n (cdr #:lst-578))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(destructuring-case nil)\n\nIssue: Macro call that should be transformed by DESTRUCTURING-CASE\n\n(destructuring-case nil)"}, {"role": "assistant", "content": "(defmacro DESTRUCTURING-CASE ...)\n\n;; macroexpand:\n(destructuring-case-alt nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(defun-ematch* common-lisp:nil\n :key\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by DEFUN-EMATCH*\n\n(defun-ematch* common-lisp:nil\n :key\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro defun-ematch* (name args &body body)\n \"Equivalent to (defun (arg) [decl-and-docstring] (ematch arg (PATTERN BODY...))).\"\n (multiple-value-bind (preamble clauses) (parse-matcher-body body)\n `(defun ,name ,args\n ,@preamble\n (ematch* ,args\n ,@clauses))))\n\n;; macroexpand:\n(common-lisp:defun common-lisp:nil :key\n (ematch* :key\n common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(sunless nil)\n\nIssue: Macro call that should be transformed by SUNLESS\n\n(sunless nil)"}, {"role": "assistant", "content": "(defmacro sunless (test &body body)\n \"Like UNLESS, except binds the test form to IT (via SYMBOL-MACROLET) for the\nscope of the body. IT can be set with SETF.\"\n `(symbolic unless ,test ,@body))\n\n;; macroexpand:\n(symbolic unless nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-keys nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-KEYS\n\n(with-keys nil\n (progn))"}, {"role": "assistant", "content": "(defmacro with-keys ((&rest kv-pairs) ht &body body)\n \"Like WITH-ACCESSORS but for pairs in hash-table HT.\"\n (once-only (ht)\n `(let (,@(mapcar #`(list (car %) `(gethash ,(second %) ,ht))\n kv-pairs))\n ,@body)))\n\n;; macroexpand:\n(let ((#:ht179 (progn)))\n (let ()))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(finding nil (progn))\n\nPattern to recognize: Macro call that should be transformed by FINDING\n\n(finding nil (progn))"}, {"role": "assistant", "content": "(defmacro FINDING ...)\n\n;; macroexpand:\n(for nil (progn))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(with-custom-decoder-level nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-CUSTOM-DECODER-LEVEL\n\n(with-custom-decoder-level nil\n (progn))"}, {"role": "assistant", "content": "(defmacro with-custom-decoder-level ((&rest customizations) &body body)\n \"Execute BODY in a dynamic environment such that, when nested\nstructures are decoded, the outermost level is decoded with the given\ncustom handlers (CUSTOMIZATIONS) whereas inner levels are decoded in\nthe usual way.\"\n `(let ((current-decoder\n (current-decoder\n ,@(loop for (key value) on customizations by #'cddr\n if (eq key :internal-decoder)\n do (error \"~S ~S customization is meaningless in ~\n the context of WITH-CUSTOM-DECODER-LEVEL.\"\n key value)\n else collect key))))\n (bind-custom-vars (:internal-decoder current-decoder ,@customizations)\n ,@body)))\n\n;; macroexpand:\n(let ((current-decoder (current-decoder)))\n (bind-custom-vars (:internal-decoder current-decoder)\n (progn)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(mvlet 'some-name)\n\nProblem: Macro call that should be transformed by MVLET\n\n(mvlet 'some-name)"}, {"role": "assistant", "content": "(defmacro mvlet ((&rest bindings) &body body)\n \"Parallel (`let'-like) version of `mvlet*'.\"\n (cond ((null bindings)\n `(locally ,@body))\n ((null (rest bindings))\n (let* ((bindings (canonicalize-bindings bindings))\n (b (first bindings)))\n `(multiple-value-bind ,(butlast b) ,(lastcar b)\n ,@body)))\n ((every #'simple-binding-p bindings)\n `(let ,bindings\n ,@body))\n (t (let* ((bindings (canonicalize-bindings bindings))\n (binds\n (mapcar #'butlast bindings))\n (exprs\n (mapcar #'lastcar bindings))\n (temp-binds\n (loop for vars in binds\n collect (mapcar #'string-gensym vars)))\n (temp-bindings\n (loop for temp-bind in temp-binds\n for expr in exprs\n collect (append temp-bind (list expr))))\n (rebindings\n (loop for vars in binds\n for temp-vars in temp-binds\n append (loop for var in vars\n for temp-var in temp-vars\n collect (list var temp-var)))))\n `(mvlet* ,temp-bindings\n (let ,rebindings\n ,@body))))))\n\n;; macroexpand:\n(let (quote some-name))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(filterf nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by FILTERF\n\n(filterf nil (progn))"}, {"role": "assistant", "content": "(defmacro FILTERF ...)\n\n;; macroexpand:\n(setq nil (filter/swapped-arguments nil (progn)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(eval-when-execute\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by EVAL-WHEN-EXECUTE\n\n(eval-when-execute\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro EVAL-WHEN-EXECUTE ...)\n\n;; macroexpand:\n(common-lisp:eval-when (:execute) common-lisp:nil)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(define-symbol-macro nil nil)\n\nIssue: Macro call that should be transformed by DEFINE-SYMBOL-MACRO\n\n(define-symbol-macro nil nil)"}, {"role": "assistant", "content": "(defmacro DEFINE-SYMBOL-MACRO ...)\n\n;; macroexpand:\n(eval-when (:compile-toplevel :load-toplevel :execute)\n (sb-c::%define-symbol-macro 'nil 'nil (sb-c:source-location)))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with-simple-restart 'some-name)\n\nIssue: Macro call that should be transformed by WITH-SIMPLE-RESTART\n\n(with-simple-restart 'some-name)"}, {"role": "assistant", "content": "(defmacro WITH-SIMPLE-RESTART ...)\n\n;; macroexpand:\n(restart-case (progn)\n (quote nil :report\n (lambda (#:stream200)\n (declare (type stream #:stream200)\n (optimize (speed 1) (space 3)))\n (format #:stream200 some-name))\n (values nil t)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(m nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by M\n\n(m nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro M ...)\n\n;; macroexpand:\n(lambda (&rest #:|macro-lambda-list123|)\n (destructuring-bind () #:|macro-lambda-list123| :key nil))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(let-match common-lisp:nil\n :key\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by LET-MATCH\n\n(let-match common-lisp:nil\n :key\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro let-match (bindings &body body)\n \"Similar to LET, except not only a variable but also a pattern can\nbe used in BINDINGS.\"\n `(ematch* ,(mapcar #'cadr bindings)\n (,(mapcar #'car bindings) ,.body)))\n\n;; macroexpand:\n(ematch* common-lisp:nil\n (common-lisp:nil :key common-lisp:nil))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(to-boolean 'some-name)\n\nProblem: Macro call that should be transformed by TO-BOOLEAN\n\n(to-boolean 'some-name)"}, {"role": "assistant", "content": "(defmacro TO-BOOLEAN ...)\n\n;; macroexpand:\n(common-lisp:and 'some-name common-lisp:t)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(defoptimizer common-lisp:nil\n :key\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by DEFOPTIMIZER\n\n(defoptimizer common-lisp:nil\n :key\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro defoptimizer (name args &body body)\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (symbol-optimizer ',name)\n #+sbcl\n (sb-int:named-lambda ',name ,args ,@body)\n #-sbcl\n (lambda ,args ,@body))\n ,@(when (stringp (first body))\n ;; lisp-namespace\n `((setf (documentation ',name 'optimizer)\n ,(let ((*print-pretty* t))\n #-clisp\n (format nil \"~~\n ~:>\"\n (list args (list (first body))))\n #+clisp\n (format nil \"Lambda-List: ~s~%~a\"\n args (first body))))))))\n\n;; macroexpand:\n(common-lisp:eval-when (:compile-toplevel :load-toplevel :execute)\n (common-lisp:setf (symbol-optimizer 'common-lisp:nil)\n (sb-int:named-lambda 'common-lisp:nil\n :key\n common-lisp:nil)))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(special-symbol-progv nil\n nil)\n\nProblem: Macro call that should be transformed by SPECIAL-SYMBOL-PROGV\n\n(special-symbol-progv nil\n nil)"}, {"role": "assistant", "content": "(defmacro SPECIAL-SYMBOL-PROGV ...)\n\n;; macroexpand:\n(let (#:symbol-list176)\n (tagbody\n #:retry177\n (setq #:symbol-list176 nil)\n (unless (every #'special-symbol-p #:symbol-list176)\n (cerror \"Retry to rebind the place(s).\"\n \"Attempt at rebinding one or more non-special places: ~S\" 'nil)\n (go #:retry177)))\n (dynamic-progv #:symbol-list176\n nil))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(some->> nil)\n\nWhat needs to change: Macro call that should be transformed by SOME->>\n\n(some->> nil)"}, {"role": "assistant", "content": "(defmacro SOME->> ...)\n\n;; macroexpand:\n(let* ((#:|some120| nil))\n #:|some120|)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with-cc nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-CC\n\n(with-cc nil\n nil)"}, {"role": "assistant", "content": "(defmacro with-cc (id &body body)\n `(with-integrity (:change ,id)\n ,@body))\n\n;; macroexpand:\n(with-integrity (:change nil) nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(ntrcx)\n\nPattern to recognize: Macro call that should be transformed by NTRCX\n\n(ntrcx)"}, {"role": "assistant", "content": "(defmacro ntrcx (&rest os)\n (declare (ignore os))\n '(progn))\n\n;; macroexpand:\n(progn)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(as->* nil (progn))\n\nPattern to recognize: Macro call that should be transformed by AS->*\n\n(as->* nil (progn))"}, {"role": "assistant", "content": "(defmacro AS->* ...)\n\n;; macroexpand:\n(as-> (progn) nil)"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(list-of nil)\n\nWhat needs to change: Macro call that should be transformed by LIST-OF\n\n(list-of nil)"}, {"role": "assistant", "content": "(defmacro LIST-OF ...)\n\n;; macroexpand:\n(lc (nil) collect)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(mapping nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAPPING\n\n(mapping nil nil)"}, {"role": "assistant", "content": "(defmacro MAPPING ...)\n\n;; macroexpand:\n(mapping-mac nil\n nil)"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(lambda-cmatch1 common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by LAMBDA-CMATCH1\n\n(lambda-cmatch1 common-lisp:nil\n (common-lisp:progn))"}, {"role": "assistant", "content": "(defmacro lambda-cmatch1 (pattern &body body)\n \"Equivalent to (lambda (arg) (cmatch arg (PATTERN BODY...))).\"\n `(lambda-cmatch (,pattern ,@body)))\n\n;; macroexpand:\n(lambda-cmatch\n (common-lisp:nil (common-lisp:progn)))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(eval-when-execute)\n\nWhat needs to change: Macro call that should be transformed by EVAL-WHEN-EXECUTE\n\n(eval-when-execute)"}, {"role": "assistant", "content": "(defmacro EVAL-WHEN-EXECUTE ...)\n\n;; macroexpand:\n(common-lisp:eval-when (:execute))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(quasiquote 'some-name)\n\nWhat needs to change: Macro call that should be transformed by QUASIQUOTE\n\n(quasiquote 'some-name)"}, {"role": "assistant", "content": "(defmacro quasiquote (x) (quasiquote-expand x))\n\n;; macroexpand:\n(quote 'some-name)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(cmatch nil)\n\nIssue: Macro call that should be transformed by CMATCH\n\n(cmatch nil)"}, {"role": "assistant", "content": "(defmacro cmatch (arg &body clauses)\n \"Same as MATCH, except a continuable MATCH-ERROR will be raised if none of the\nclauses match.\"\n (once-only (arg)\n (let ((else `(cerror \"Continue.\"\n 'match-error\n :values (list ,arg)\n :patterns ',(mapcar (lambda (c) (list (car c))) clauses))))\n (compile-match-1 arg clauses else))))\n\n;; macroexpand:\n(let ((#:arg122 nil))\n (cerror \"Continue.\" 'match-error :values (list #:arg122) :patterns 'nil))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(rotatef nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ROTATEF\n\n(rotatef nil :key nil)"}, {"role": "assistant", "content": "(defmacro ROTATEF ...)\n\n;; macroexpand:\n(let* ()\n (multiple-value-bind (#:new273)\n :key\n (multiple-value-bind (#:new274)\n nil\n (multiple-value-bind (#:new275)\n nil\n (setq nil #:new273)\n (setq :key #:new274)\n (setq nil #:new275)\n nil))))"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(gen-lambda nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by GEN-LAMBDA\n\n(gen-lambda nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro gen-lambda (params &body rest)\n \"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.\"\n `(let ((values-handler (create-values-handler)))\n (declare (ignorable values-handler))\n (make-instance \n 'basic-generator \n :function (lambda ,params ,@rest))))\n\n;; macroexpand:\n(let ((values-handler (create-values-handler)))\n (declare (ignorable values-handler))\n (make-instance 'basic-generator :function (lambda () :key nil)))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(cmatch* common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CMATCH*\n\n(cmatch* common-lisp:nil\n :key\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro cmatch* (whats &body clauses)\n #.+match*-doc+ \n (let ((temps (make-gensyms whats \"OTHERWISE\")))\n `(match2* ,whats\n ,@clauses\n (,temps\n (cerror \"continue\" 'match-error :pattern ',clauses :values (list ,@temps))))))\n\n;; macroexpand:\n(match2* common-lisp:nil\n :key\n common-lisp:nil\n (common-lisp:nil\n (common-lisp:cerror \"continue\" 'match-error :pattern '(:key common-lisp:nil)\n :values (common-lisp:list))))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(c-formula 'some-name)\n\nPattern to recognize: Macro call that should be transformed by C-FORMULA\n\n(c-formula 'some-name)"}, {"role": "assistant", "content": "(defmacro c-formula ((&rest keys &key lazy &allow-other-keys) &body forms)\n (assert (member lazy '(nil t :once-asked :until-asked :always)))\n `(make-c-dependent\n :code ',forms\n :value-state :unevaluated\n :rule (c-lambda ,@forms)\n ,@keys))\n\n;; macroexpand:\n(make-c-dependent :code 'nil :value-state :unevaluated :rule (c-lambda) quote\n some-name)"}]} -{"messages": [{"role": "user", "content": "Define a macro that eliminates this repetitive pattern:\n(with-boolean nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITH-BOOLEAN\n\n(with-boolean nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-boolean ((&rest branches) &body body\n &environment env)\n \"Establishes a lexical environment in which it is possible to use\nmacroexpand-time branching. Within the lexical scope of\n`with-boolean', it is possible to use `boolean-if', `boolean-when',\nand `boolean-unless' to conditionalize whether some forms are included\nat compilation time. (You may also use `:if', `:when', or `:unless'\nfor brevity.)\n\\\nThe first argument must be a list of symbols which name variables. This macro\nwill expand into a series of conditionals\"\n (cond (*boolean-bypass*\n `(progn ,@body))\n (t (let ((all-branches (macroexpand-1 '%all-branches% env)))\n `(macrolet ((:if (cond then else)\n (list 'boolean-if cond then else))\n (:when (cond &body then)\n (list* 'boolean-when cond then))\n (:unless (cond &body then)\n (list* 'boolean-unless cond then)))\n (locally\n (declare #+sbcl (sb-ext:disable-package-locks\n %in-branching% %all-branches%)\n #+sbcl (sb-ext:muffle-conditions\n sb-ext:code-deletion-note))\n (symbol-macrolet ((%in-branching% t)\n (%all-branches% (,@branches ,@all-branches))\n (%true-branches% ()))\n (locally (declare #+sbcl (sb-ext:enable-package-locks\n %in-branching% %all-branches%))\n (%with-boolean ,branches ,@body)))))))))\n\n;; macroexpand:\n(macrolet ((:if (cond serapeum/types::then serapeum/types::else)\n (list 'boolean-if cond serapeum/types::then serapeum/types::else))\n (:when (cond &body serapeum/types::then)\n (list* 'boolean-when cond serapeum/types::then))\n (:unless (cond &body serapeum/types::then)\n (list* 'boolean-unless cond serapeum/types::then)))\n (locally\n (declare\n (sb-ext:disable-package-locks serapeum/types::%in-branching%\n serapeum/types::%all-branches%)\n (sb-ext:muffle-conditions sb-ext:code-deletion-note))\n (symbol-macrolet ((serapeum/types::%in-branching% t)\n (serapeum/types::%all-branches% nil)\n (serapeum/types::%true-branches% nil))\n (locally\n (declare\n (sb-ext:enable-package-locks serapeum/types::%in-branching%\n serapeum/types::%all-branches%))\n (serapeum/types::%with-boolean nil\n :key\n nil)))))"}]} -{"messages": [{"role": "user", "content": "Create a Common Lisp macro for the following transformation. Before code:\n(with-unique-names nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-UNIQUE-NAMES\n\n(with-unique-names nil\n nil)"}, {"role": "assistant", "content": "(defmacro with-unique-names (names &body forms)\n \"Alias for WITH-GENSYMS.\"\n `(with-gensyms ,names ,@forms))\n\n;; macroexpand:\n(with-gensyms nil\n nil)"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(advisable-lambda 'some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ADVISABLE-LAMBDA\n\n(advisable-lambda 'some-name)"}, {"role": "assistant", "content": "(defmacro ADVISABLE-LAMBDA ...)\n\n;; macroexpand:\n(make-instance 'advisable-function :main #'(lambda (quote some-name))\n :arguments ''some-name :dispatcher-generator\n #'(lambda (#:fobj130)\n #'(lambda (quote some-name)\n #A((29) base-char . \"Advisable function dispatcher\")\n (let ((#:fixed131\n (append (list quote) (list some-name))))\n (apply-before #:fobj130 #:fixed131)\n (multiple-value-prog1\n (apply-around #:fobj130 #:fixed131)\n (apply-after #:fobj130 #:fixed131))))))"}]} -{"messages": [{"role": "user", "content": "Write a Common Lisp macro to handle this code pattern:\n(unless nil (progn))\n\nProblem: Macro call that should be transformed by UNLESS\n\n(unless nil (progn))"}, {"role": "assistant", "content": "(defmacro UNLESS ...)\n\n;; macroexpand:\n(if nil\n nil\n (progn))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(make* nil (progn))\n\nPattern to recognize: Macro call that should be transformed by MAKE*\n\n(make* nil (progn))"}, {"role": "assistant", "content": "(defmacro MAKE* ...)\n\n;; macroexpand:\n(apply #'make-instance nil (progn))"}]} -{"messages": [{"role": "user", "content": "You are a Common Lisp macro expert. Given this code pattern:\n(type common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by TYPE\n\n(type common-lisp:nil\n :key\n common-lisp:nil)"}, {"role": "assistant", "content": "(defmacro TYPE ...)\n\n;; macroexpand:\n(cl-annot-revisit-at-macro::add-declaration (common-lisp:type common-lisp:nil\n :key)\n common-lisp:nil)"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(prog2 nil nil)\n\nPattern to recognize: Macro call that should be transformed by PROG2\n\n(prog2 nil nil)"}, {"role": "assistant", "content": "(defmacro PROG2 ...)\n\n;; macroexpand:\n(prog1 (progn nil nil))"}]} -{"messages": [{"role": "user", "content": "Generate a defmacro form that transforms code like this:\n(with-explicit-encoder\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-EXPLICIT-ENCODER\n\n(with-explicit-encoder\n nil\n :key\n nil)"}, {"role": "assistant", "content": "(defmacro with-explicit-encoder (&body body)\n `(with-local-encoder (use-explicit-encoder)\n ,@body))\n\n;; macroexpand:\n(with-local-encoder\n (use-explicit-encoder)\n nil\n :key\n nil)"}]}