{"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(drelet nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DRELET", "input": "(drelet nil)", "output": "(defmacro DRELET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defmacro-clause 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DEFMACRO-CLAUSE", "input": "(defmacro-clause 'lol-gen::some-name)", "output": "(defmacro defmacro-clause (clause-template &body body)\n \"Macro for defining iterate clauses (with DEFMACRO).\"\n (define-clause 'defmacro clause-template body nil))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda () nil)\n\nProblem: Macro call that should be transformed by LAMBDA", "input": "(lambda () nil)", "output": "(defmacro LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(collecting\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by COLLECTING", "input": "(collecting\n nil\n nil)", "output": "(defmacro collecting (&body body)\n \"Like `with-collector', with the collector bound to the result of\ninterning `collect' in the current package.\"\n (with-current-package-symbols (collect)\n `(with-collector (,collect)\n ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(matrix-ccase nil)\n\nIssue: Macro call that should be transformed by MATRIX-CCASE", "input": "(matrix-ccase nil)", "output": "(defmacro MATRIX-CCASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(some-<>> nil nil)\n\nProblem: Macro call that should be transformed by SOME-<>>", "input": "(some-<>> nil nil)", "output": "(defmacro SOME-<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lret* nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by LRET*", "input": "(lret* nil\n :key\n nil)", "output": "(defmacro lret* ((&rest bindings) &body body)\n \"Cf. `lret'.\"\n `(lret-aux let* ,bindings\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(cond-every\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by COND-EVERY", "input": "(cond-every\n nil\n (progn))", "output": "(defmacro cond-every (&body clauses)\n \"Like `cond', but instead of stopping after the first clause that\nsucceeds, run all the clauses that succeed.\n\nReturn the value of the last successful clause.\n\nIf a clause begins with `cl:otherwise', it runs only if no preceding\nform has succeeded.\n\nNote that this does *not* do the same thing as a series of `when'\nforms: `cond-every' evaluates *all* the tests *before* it evaluates\nany of the forms.\n\nFrom Zetalisp.\"\n (let* ((otherwise-clause (find 'otherwise clauses :key #'car))\n (test-clauses (remove otherwise-clause clauses))\n (temps (make-gensym-list (length test-clauses))))\n `(let* ,(loop for temp in temps\n for (test . nil) in test-clauses\n collect `(,temp ,test))\n ;; Work around Iterate bug. See\n ;; .\n (if (or ,@temps)\n ,(with-gensyms (ret)\n `(let (,ret)\n ,@(loop for temp in temps\n for (nil . body) in test-clauses\n collect `(when ,temp\n (setf ,ret\n ,(if (null body)\n temp\n `(progn ,@body)))))\n ,ret))\n (progn ,@(rest otherwise-clause))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(some-<>> 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by SOME-<>>", "input": "(some-<>> 'lol-gen::some-name)", "output": "(defmacro SOME-<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-rules nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-RULES", "input": "(with-rules nil\n (progn))", "output": "(defmacro WITH-RULES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(removef nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by REMOVEF", "input": "(removef nil :key nil)", "output": "(defmacro REMOVEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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*", "input": "(lambda* nil)", "output": "(defmacro LAMBDA* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(ensure-transaction-with-isolation-level nil)\n\nPattern to recognize: Macro call that should be transformed by ENSURE-TRANSACTION-WITH-ISOLATION-LEVEL", "input": "(ensure-transaction-with-isolation-level nil)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(coalton-codegen-types)\n\nProblem: Macro call that should be transformed by COALTON-CODEGEN-TYPES", "input": "(coalton-codegen-types)", "output": "(defmacro COALTON-CODEGEN-TYPES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-unknown-first-class-functions-allowed\n nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-UNKNOWN-FIRST-CLASS-FUNCTIONS-ALLOWED", "input": "(with-unknown-first-class-functions-allowed\n nil\n nil)", "output": "(defmacro with-unknown-first-class-functions-allowed (&body body)\n `(let ((*allow-call-function-signature* t))\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n;; Explicit continuation-passing is verbose\n(defun fact-cps (n cont)\n (if (zerop n)\n (funcall cont 1)\n (fact-cps (- n 1)\n (lambda (x) (funcall cont (* n x))))))\n\n;; Every function must take an explicit continuation parameter.\n;; Every call must thread the continuation through.\n;; Simple sequential code becomes deeply nested.\n\nProblem: Manual continuation-passing style requires explicit continuation parameters and nested lambdas \u2014 want syntactic sugar for CPS", "input": ";; Explicit continuation-passing is verbose\n(defun fact-cps (n cont)\n (if (zerop n)\n (funcall cont 1)\n (fact-cps (- n 1)\n (lambda (x) (funcall cont (* n x))))))\n\n;; Every function must take an explicit continuation parameter.\n;; Every call must thread the continuation through.\n;; Simple sequential code becomes deeply nested.", "output": "(defmacro =lambda (parms &body body)\n `#'(lambda (*cont* ,@parms) ,@body))\n\n(defmacro =defun (name parms &body body)\n (let ((f (intern (concatenate 'string\n \"=\" (symbol-name name)))))\n `(progn\n (defmacro ,name ,parms\n `(,',f *cont* ,,@parms))\n (defun ,f (*cont* ,@parms) ,@body))))\n\n(defmacro =bind (parms expr &body body)\n `(let ((*cont* #'(lambda ,parms ,@body))) ,expr))\n\n(defmacro =values (&rest retvals)\n `(funcall *cont* ,@retvals))", "category": "control-flow", "technique": "nested-backquote", "complexity": "advanced", "quality_score": 0.975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-unique-names nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-UNIQUE-NAMES", "input": "(with-unique-names nil)", "output": "(defmacro with-unique-names (names &body body)\n `(let ,(mapcar (lambda (sym)\n `(,sym (gensym ,(symbol-name sym))))\n names)\n ,@body))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(pccase nil nil)\n\nProblem: Macro call that should be transformed by PCCASE", "input": "(pccase nil nil)", "output": "(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))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(necessarily?\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by NECESSARILY?", "input": "(necessarily?\n 'lol-gen::some-name)", "output": "(defmacro NECESSARILY? ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(eval-and-compile\n nil)\n\nPattern to recognize: Macro call that should be transformed by EVAL-AND-COMPILE", "input": "(eval-and-compile\n nil)", "output": "(defmacro eval-and-compile (&body body)\n \"Emacs's `eval-and-compile'.\nAlias for `eval-always'.\"\n `(eval-always\n ,@body))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-foreign-objects nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-FOREIGN-OBJECTS", "input": "(with-foreign-objects nil\n :key\n nil)", "output": "(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)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(join 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by JOIN", "input": "(join 'lol-gen::some-name)", "output": "(defmacro join (table &key (kind :inner) on using)\n `(make-clause :join ,(expand-op table)\n :kind ,kind\n ,@(if on\n `(:on ,(if (and (listp on)\n (keywordp (car on)))\n (expand-op on)\n `,on))\n nil)\n ,@(if using\n `(:using ',using)\n nil)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nconcf 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by NCONCF", "input": "(nconcf 'lol-gen::some-name)", "output": "(defmacro NCONCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defmacro+ps nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFMACRO+PS", "input": "(defmacro+ps nil\n :key\n nil)", "output": "(defmacro DEFMACRO+PS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-definition-resolver nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by DEFINE-DEFINITION-RESOLVER", "input": "(define-definition-resolver nil\n :key\n nil)", "output": "(defmacro define-definition-resolver (name args &body body)\n `(progn (setf (definition-resolver ',name)\n (lambda ,args ,@body))\n ',name))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "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 ->*", "input": "(->*)", "output": "(defmacro ->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(doc common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by DOC", "input": "(doc common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro DOC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(make-proxy nil nil)\n\nPattern to recognize: Macro call that should be transformed by MAKE-PROXY", "input": "(make-proxy nil nil)", "output": "(defmacro make-proxy (slot node-type &key (node-name 'item) (parent 'item))\n \"Add proxy nodes to slot. Note: all uses in c-mera and cm-c implicitly assue that the node is called ITEM.\"\n (let ((val (gensym)))\n `(if (or (eql (find-class 'nodelist) (class-of (slot-value ,node-name ',slot))))\n \t (let ((,val (slot-value (slot-value ,node-name ',slot) 'nodes)))\n \t (setf (slot-value (slot-value ,node-name ',slot) 'nodes)\n \t\t (loop for i in ,val collect\n \t\t (make-instance ,node-type\n\t\t\t\t :parent ,parent\n \t\t\t\t :proxy-subnode i\n \t\t\t\t :values '()\n \t\t\t\t :subnodes '(proxy-subnode)))))\n \t (let ((,val (slot-value ,node-name ',slot)))\n \t (if ,val\n \t (setf (slot-value ,node-name ',slot)\n \t\t (make-instance ,node-type\n\t\t\t\t :parent ,parent\n \t\t\t\t :proxy-subnode ,val\n \t\t\t\t :values '()\n \t\t\t\t :subnodes '(proxy-subnode)))\n \t (setf (slot-value ,node-name ',slot)\n \t \t (make-instance ,node-type\n\t\t\t\t :parent ,parent\n \t \t\t\t :proxy-subnode nil\n \t \t\t\t :values '()\n \t \t\t\t :subnodes '(proxy-subnode))))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(either\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by EITHER", "input": "(either\n 'lol-gen::some-name)", "output": "(defmacro EITHER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(for nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by FOR", "input": "(for nil\n (progn))", "output": "(defmacro for (&environment env bindings &body body)\n (let ((*environment* env))\n (multiple-value-bind (bind-init bind-forms bind-exit bind-post) (convert-bindings bindings)\n (multiple-value-bind (clause-init body-forms clause-exit) (convert-clauses body)\n `(with-interleaving\n ,@bind-init\n ,@clause-init\n (with-for-block ()\n (with-for-tagbody\n (progn ,@bind-forms\n ,@body-forms\n ,@bind-post)\n (return-for\n ,@clause-exit\n ,@bind-exit))))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(export-accessors\n common-lisp:nil\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by EXPORT-ACCESSORS", "input": "(export-accessors\n common-lisp:nil\n common-lisp:nil)", "output": "(defmacro EXPORT-ACCESSORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-simple-object-lookup nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-SIMPLE-OBJECT-LOOKUP", "input": "(define-simple-object-lookup nil\n (progn))", "output": "(defmacro define-simple-object-lookup (class lookup-function &body body)\n `(defmethod object ((,class ,class))\n ,(if body\n `(let ((,(first lookup-function) ,class))\n ,@body)\n `(,lookup-function (designator ,class)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(var nil)\n\nPattern to recognize: Macro call that should be transformed by VAR", "input": "(var nil)", "output": "(defmacro VAR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond->> nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by COND->>", "input": "(cond->> nil :key nil)", "output": "(defmacro COND->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": ";; 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", "output": "(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))))))))", "category": "control-flow", "technique": "macrolet,tagbody-go,gensym", "complexity": "advanced", "quality_score": 0.975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(rem-bops nil :key nil)\n\nIssue: Macro call that should be transformed by REM-BOPS", "input": "(rem-bops nil :key nil)", "output": "(defmacro REM-BOPS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(bind nil)\n\nPattern to recognize: Macro call that should be transformed by BIND", "input": "(bind nil)", "output": "(defmacro bind ((&rest bindings) &body body)\n \"Bind is a replacement for let*, destructuring-bind, multiple-value-bind and more. \n\nAn example is probably the best way to describe its syntax:\n\n \\(bind \\(\\(a 2\\)\n \\(\\(b &rest args &key \\(c 2\\) &allow-other-keys\\) '\\(:a :c 5 :d 10 :e 54\\)\\)\n \\(\\(:values d e\\) \\(truncate 4.5\\)\\)\n \\(\\(:structure xxx- slot1 slot2\\) \\(make-xxx\\)\\)\n \\(\\(:flet name \\(arg1 arg2\\)\\) \\(+ arg1 arg2\\)\\)\\)\n \\(list a b c d e args\\)\\)\n\nSimple bindings are as in let*. Destructuring is done if the first item\nin a binding is a list. Multiple value binding is done if the first item\nin a binding is a list and the first item in the list is ':values'. Other\nforms have their own syntax. For example, :structure first has the conc\nname and then slot names whereas :flet has the function name and a list\nof arguments and then the function body (in an implicit progn).\"\n (let (declarations)\n (loop while (and (consp (car body)) (eq (caar body) 'declare)) do\n (push (first body) declarations)\n (setf body (rest body)))\n (if bindings\n\t(let ((*all-declarations* (bind-expand-declarations (nreverse declarations))))\n\t (prog1\n\t (bind-macro-helper bindings body)\n\t (check-for-unused-variable-declarations *all-declarations*)))\n `(locally\n ,@declarations\n ,@body))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8274999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(symbol-value-in-$instance nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SYMBOL-VALUE-IN-$INSTANCE", "input": "(symbol-value-in-$instance nil nil)", "output": "(defmacro SYMBOL-VALUE-IN-$INSTANCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(etypecase-let 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ETYPECASE-LET", "input": "(etypecase-let 'lol-gen::some-name)", "output": "(defmacro etypecase-let ((var expr) &body cases)\n \"Like (let ((VAR EXPR)) (etypecase VAR ...)), with VAR read-only.\"\n `(let1 ,var ,expr\n (etypecase ,var\n ,@cases)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-vector-dispatch nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-VECTOR-DISPATCH", "input": "(with-vector-dispatch nil\n :key\n nil)", "output": "(defmacro with-vector-dispatch ((&rest types) var &body body)\n \"Like `with-subtype-dispatch' with an overall type of `vector'.\"\n ;; Always specialize for simple vectors.\n `(with-subtype-dispatch vector (simple-vector ,@types) ,var\n ,@body))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(assert 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ASSERT", "input": "(assert 'lol-gen::some-name)", "output": "(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))))", "category": "control-flow", "technique": "gensym", "complexity": "advanced", "quality_score": 0.8724999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(summing)\n\nProblem: Macro call that should be transformed by SUMMING", "input": "(summing)", "output": "(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))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Generate a defmacro form that transforms code like this:\n(unwrap-as common-lisp:nil (common-lisp:progn))\n\nPattern to recognize: Macro call that should be transformed by UNWRAP-AS", "input": "(unwrap-as common-lisp:nil (common-lisp:progn))", "output": "(defmacro unwrap-as (type cl:&optional (expr cl:nil expr-supplied-p))\n \"A syntactic convenience for type casting.\n\n (unwrap-as )\n\nis equivalent to\n\n (the (uwrap (tryInto )))\n\nand\n\n (unwrap-as )\n\nis equivalent to\n\n (fn (expr) (the (unwrap (tryInto expr)))).\n\nNote that this may copy the object or allocate memory.\"\n\n (cl:let ((try-into (cl:ignore-errors (cl:find-symbol \"TRYINTO\" \"COALTON/CLASSES\")))\n (unwrap (cl:ignore-errors (cl:find-symbol \"UNWRAP\" \"COALTON/CLASSES\"))))\n (cl:assert try-into () \"`try-as` macro does not have access to `try-into` yet.\")\n (cl:assert unwrap () \"`unwrap` macro does not have access to `unwrap` yet.\")\n (cl:if expr-supplied-p\n `(the ,type (,unwrap (,try-into ,expr)))\n (alexandria:with-gensyms (lexpr)\n `(fn (,lexpr)\n (the ,type (,unwrap (,try-into ,lexpr))))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(skip nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by SKIP", "input": "(skip nil\n :key\n nil)", "output": "(defmacro skip (desc &body tests)\n `(with-forced-status (:skipped ,@(if (listp desc) desc (list desc)))\n ,@tests))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(local\n nil)\n\nIssue: Macro call that should be transformed by LOCAL", "input": "(local\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-module-extension 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DEFINE-MODULE-EXTENSION", "input": "(define-module-extension 'lol-gen::some-name)", "output": "(defmacro define-module-extension ((module-identifier name) &body options)\n (let ((module (gensym \"MODULE\"))\n (name (string name)))\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (with-module (,module ,module-identifier)\n (pushnew ,name (module-storage ,module :extensions) :test #'string=)\n (pushnew ,(make-identifier name) (module-storage ,module :extensions) :test #'string=)\n ;; Add nicknames so the extension can be IN-PACKAGEd as if it\n ;; were a proper module.\n (extend-package ,module '((:nicknames\n ,(make-symbol name)\n ,(make-symbol (make-identifier name)))))\n (expand-module ,module ',options)\n ,module))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(dict-of nil nil)\n\nProblem: Macro call that should be transformed by DICT-OF", "input": "(dict-of nil nil)", "output": "(defmacro DICT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ps-once-only 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by PS-ONCE-ONLY", "input": "(ps-once-only 'lol-gen::some-name)", "output": "(defmacro PS-ONCE-ONLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-pp\n nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-PP", "input": "(with-pp\n nil\n (progn))", "output": "(defmacro with-pp (&body body)\n `(symbol-macrolet ((stream (get-stream-generic pp))\n\t\t (indent (get-indent-generic pp))\n\t\t (--indent (dec-indent-generic pp))\n\t\t (++indent (inc-indent-generic pp)))\n (macrolet ((push-sign (x) `(push-sign-generic pp ,x))\n\t\t(pop-sign () `(pop-sign-generic pp))\n\t\t(top-sign () `(top-sign-generic pp))\n\t\t(find-sign (x) `(find-sign-generic pp ,x))\n\t\t(push-info (x) `(push-info-generic pp ,x))\n\t\t(pop-info () `(pop-info-generic pp))\n\t\t(top-info () `(top-info-generic pp))\n\t\t(find-info (x) `(find-info-generic pp ,x))\n\t\t(info-size () `(info-size-generic pp))\n\t\t(node-slot (x) `(slot-value item ',x)))\n ,@body)))", "category": "anaphoric", "technique": "symbol-macrolet,macrolet,nested-backquote,anaphor", "complexity": "advanced", "quality_score": 0.9175} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(nconcf nil nil)\n\nProblem: Macro call that should be transformed by NCONCF", "input": "(nconcf nil nil)", "output": "(defmacro NCONCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(order-by nil)\n\nProblem: Macro call that should be transformed by ORDER-BY", "input": "(order-by nil)", "output": "(defmacro order-by (&rest expressions)\n `(make-clause :order-by ,@(expand-expression expressions)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(ps-once-only nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by PS-ONCE-ONLY", "input": "(ps-once-only nil\n (progn))", "output": "(defmacro PS-ONCE-ONLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-properties nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-PROPERTIES", "input": "(with-properties nil\n nil)", "output": "(defmacro WITH-PROPERTIES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(mk-part nil (progn))\n\nWhat needs to change: Macro call that should be transformed by MK-PART", "input": "(mk-part nil (progn))", "output": "(defmacro mk-part (md-name (md-class) &rest initargs)\n `(make-part ',md-name ',md-class ,@initargs\n :fm-parent (progn (assert self () \"mk-part null self for parent\") self)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(etypecase 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by ETYPECASE", "input": "(etypecase 'lol-gen::some-name)", "output": "(defmacro ETYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n;; Common pattern: read a value, apply a function, store back\n(let ((old (car place)))\n (setf (car place) (1+ old)))\n\n;; Or with a more complex place:\n(let ((old (getf plist :count)))\n (setf (getf plist :count) (* old 2)))\n\n;; Every operation needs manual read-modify-write boilerplate\n\nProblem: Read-modify-write on places requires manual let + access + setf \u2014 want a single operator that applies any function to a place", "input": ";; Common pattern: read a value, apply a function, store back\n(let ((old (car place)))\n (setf (car place) (1+ old)))\n\n;; Or with a more complex place:\n(let ((old (getf plist :count)))\n (setf (getf plist :count) (* old 2)))\n\n;; Every operation needs manual read-modify-write boilerplate", "output": "(defmacro _f (op place &rest args)\n (multiple-value-bind (vars forms var set access)\n (get-setf-method place)\n `(let* (,@(mapcar #'list vars forms)\n (,(car var) (,op ,access ,@args)))\n ,set)))", "category": "dsl", "technique": "defsetf", "complexity": "intermediate", "quality_score": 0.95} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ensure-transaction\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by ENSURE-TRANSACTION", "input": "(ensure-transaction\n 'lol-gen::some-name)", "output": "(defmacro ensure-transaction (&body body)\n \"Ensures that body is executed within a transaction, but does not begin a new\ntransaction if one is already in progress.\"\n `(call-with-ensured-transaction (lambda () ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n;; format with constant control strings interprets directives at runtime\n(format nil \"Value: ~a, Name: ~a\" val name)\n;; Every call: parse the ~a directives, resolve them, dispatch formatting\n;; The format string is known at compile time but still interpreted at runtime\n\nWrite a macro that addresses: format with compile-time-constant control strings wastes time interpreting directives at runtime \u2014 want compile-time compilation of format strings", "input": ";; format with constant control strings interprets directives at runtime\n(format nil \"Value: ~a, Name: ~a\" val name)\n;; Every call: parse the ~a directives, resolve them, dispatch formatting\n;; The format string is known at compile time but still interpreted at runtime", "output": "(defun fformat (&rest all)\n (apply #'format all))\n\n(define-compiler-macro fformat\n (&whole form\n stream fmt &rest args)\n (if (constantp fmt)\n (if stream\n `(funcall (formatter ,fmt)\n ,stream ,@args)\n (let ((g!stream (gensym \"stream\")))\n `(with-output-to-string (,g!stream)\n (funcall (formatter ,fmt)\n ,g!stream ,@args))))\n form))", "category": "compiler-macro", "technique": "compiler-macro,gensym", "complexity": "intermediate", "quality_score": 0.97} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fmap nil nil)\n\nWhat needs to change: Macro call that should be transformed by FMAP", "input": "(fmap nil nil)", "output": "(defmacro fmap (f thing)\n \"Apply a pure function to the inner contents of some parsing operation, if the\nparsing itself was successful.\"\n `(multiple-value-bind (res next) ,thing\n (if (failure? res)\n (fail next)\n (values (funcall ,f res) next))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(eko-if nil (progn))\n\nPattern to recognize: Macro call that should be transformed by EKO-IF", "input": "(eko-if nil (progn))", "output": "(defmacro eko-if ((&rest trcargs) &rest body)\n (let ((result (gensym)))\n `(let ((,result ,@body))\n (when ,result\n (trc ,(car trcargs) :res ,result ,@(cdr trcargs)))\n ,result)))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(enable-quasi-quoted-bivalent-to-bivalent-emitting-form-syntax\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BIVALENT-TO-BIVALENT-EMITTING-FORM-SYNTAX", "input": "(enable-quasi-quoted-bivalent-to-bivalent-emitting-form-syntax\n 'lol-gen::some-name)", "output": "(defmacro ENABLE-QUASI-QUOTED-BIVALENT-TO-BIVALENT-EMITTING-FORM-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(rem-plist-val! nil nil)\n\nProblem: Macro call that should be transformed by REM-PLIST-VAL!", "input": "(rem-plist-val! nil nil)", "output": "(defmacro rem-plist-val! (id place &key (test '(default-test)) (key '(default-key)))\n `(setf ,place\n (rem-plist-val ,id ,place :test ,test :key ,key)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(for-effects\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by FOR-EFFECTS", "input": "(for-effects\n 'lol-gen::some-name)", "output": "(defmacro FOR-EFFECTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(inext-noexit 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by INEXT-NOEXIT", "input": "(inext-noexit 'lol-gen::some-name)", "output": "(defmacro INEXT-NOEXIT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(some-<>>\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SOME-<>>", "input": "(some-<>>\n nil\n (progn))", "output": "(defmacro SOME-<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(necessarily?\n nil\n (progn))\n\nProblem: Macro call that should be transformed by NECESSARILY?", "input": "(necessarily?\n nil\n (progn))", "output": "(defmacro NECESSARILY? ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(do-macros-in-lexenv 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DO-MACROS-IN-LEXENV", "input": "(do-macros-in-lexenv 'lol-gen::some-name)", "output": "(defmacro DO-MACROS-IN-LEXENV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cond-<>>\n nil\n (progn))\n\nProblem: Macro call that should be transformed by COND-<>>", "input": "(cond-<>>\n nil\n (progn))", "output": "(defmacro COND-<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(dowhile-it nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by DOWHILE-IT", "input": "(dowhile-it nil\n :key\n nil)", "output": "(defmacro dowhile-it (test &body body)\n \"Like DOWHILE. IT is bound to TEST.\"\n `(do ((it ,test ,test))\n ((not it))\n ,@body))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defcell nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFCELL", "input": "(defcell nil nil)", "output": "(defmacro defcell (name value-form &environment env)\n \"Define a global cell identified by NAME.\n\nThis macro defines a cell identified by NAME with its value computed\nby VALUE-FORM. The value of the cell can be referenced by the symbol\nNAME following the DEFCELL form.\n\nIf VALUE-FORM is a constant, by CONSTANTP, a mutable cell is defined\nwhich can have its value set directly using SETF or SETQ on the symbol\nNAME.\n\nIf VALUE-FORM is not a constant a computed cell is created. A computed\ncell may reference one or more argument cells in VALUE-FORM or a\nfunction called during the evaluation of VALUE-FORM. When the values\nof any of the argument cells change, the value of the computed cell is\nrecomputed by evaluating VALUE-FORM again. The referenced argument\ncells are determined automatically when the VALUE-FORM is evaluated.\n\nThis macro creates a cell definition that is visible globally to all\nforms unless it is lexically shadowed by a definition with the same\nNAME using CELL-LET. Note that despite being visible globally, the\ncell definition is still lexically scoped and not dynamically scoped\nlike global variables defined with DEFVAR or DEFPARAMETER.\"\n\n (if (constantp value-form env)\n `(define-mutable-cell% ,name ,value-form)\n `(define-computed-cell% ,name ,value-form)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "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 ->>", "input": "(->> nil :key nil)", "output": "(defmacro ->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-gensyms nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-GENSYMS", "input": "(with-gensyms nil\n (progn))", "output": "(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))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(is-false nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by IS-FALSE", "input": "(is-false nil (progn))", "output": "(defmacro is-false (condition &rest reason-args)\n \"Generates a pass if CONDITION returns false, generates a\n failure otherwise. Like IS-TRUE, and unlike IS, IS-FALSE does\n not inspect CONDITION to determine what reason to give it case\n of test failure\"\n (with-gensyms (value)\n `(let ((,value ,condition))\n (if ,value\n (process-failure ',condition\n ,@(or reason-args\n `(\"~S returned the value ~S, which is true\" ',condition ,value)))\n (add-result 'test-passed :test-expr ',condition)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Generate a defmacro form that transforms code like this:\n(js nil nil)\n\nPattern to recognize: Macro call that should be transformed by JS", "input": "(js nil nil)", "output": "(defmacro JS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(any-of nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by ANY-OF", "input": "(any-of nil\n :key\n nil)", "output": "(defmacro ANY-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(set-bop nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by SET-BOP", "input": "(set-bop nil :key nil)", "output": "(defmacro SET-BOP ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defproxy 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DEFPROXY", "input": "(defproxy 'lol-gen::some-name)", "output": "(defmacro defproxy (name)\n \"Define node derived from proxy\"\n `(progn\n (defclass# ,name (proxy) (values subnodes parent))\n (make-instance# ,name () ())))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(defparameter* nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFPARAMETER*", "input": "(defparameter* nil (progn))", "output": "(defmacro DEFPARAMETER* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(pprint-coalton-codegen)\n\nIssue: Macro call that should be transformed by PPRINT-COALTON-CODEGEN", "input": "(pprint-coalton-codegen)", "output": "(defmacro PPRINT-COALTON-CODEGEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ltbdd-with-new-hash nil)\n\nIssue: Macro call that should be transformed by LTBDD-WITH-NEW-HASH", "input": "(ltbdd-with-new-hash nil)", "output": "(defmacro LTBDD-WITH-NEW-HASH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(max-of nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by MAX-OF", "input": "(max-of nil\n :key\n nil)", "output": "(defmacro MAX-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-direct-binding nil\n (progn))\n\nProblem: Macro call that should be transformed by DEFINE-DIRECT-BINDING", "input": "(define-direct-binding nil\n (progn))", "output": "(defmacro define-direct-binding (name args &body body)\n (let ((env (or (lambda-fiddle:environment-lambda-var args) (gensym \"ENVIRONMENT\"))))\n `(progn (setf (binding ',name)\n (lambda ,(lambda-fiddle:remove-environment-part args)\n (let ((,env *environment*))\n (declare (ignorable ,env))\n ,@body)))\n ',name)))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(do-functions-in-lexenv 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DO-FUNCTIONS-IN-LEXENV", "input": "(do-functions-in-lexenv 'lol-gen::some-name)", "output": "(defmacro DO-FUNCTIONS-IN-LEXENV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(alambda 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ALAMBDA", "input": "(alambda 'lol-gen::some-name)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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-<>", "input": "(some-<> nil)", "output": "(defmacro some-<> (init &body exps) (diamond-wand init exps nil t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(shrinkf nil (progn))\n\nIssue: Macro call that should be transformed by SHRINKF", "input": "(shrinkf nil (progn))", "output": "(defmacro SHRINKF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(m nil\n (progn))\n\nIssue: Macro call that should be transformed by M", "input": "(m nil\n (progn))", "output": "(defmacro M ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cond->\n nil\n nil)\n\nIssue: Macro call that should be transformed by COND->", "input": "(cond->\n nil\n nil)", "output": "(defmacro COND-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is-condition nil :key nil)\n\nProblem: Macro call that should be transformed by IS-CONDITION", "input": "(is-condition nil :key nil)", "output": "(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\"))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(f0\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by F0", "input": "(f0\n 'lol-gen::some-name)", "output": "(defmacro F0 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(c-abs nil)\n\nIssue: Macro call that should be transformed by C-ABS", "input": "(c-abs nil)", "output": "(defmacro c-abs (value &body body)\n `(make-c-drifter-absolute\n :code ',body\n :value-state :valid\n :value ,value\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-substitute-printed-representation-restart 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-SUBSTITUTE-PRINTED-REPRESENTATION-RESTART", "input": "(with-substitute-printed-representation-restart 'lol-gen::some-name)", "output": "(defmacro with-substitute-printed-representation-restart ((object stream)\n &body body)\n \"Establish a SUBSTITUTE-PRINTED-REPRESENTATION restart for OBJECT\nand execute BODY.\"\n `(restart-case (progn ,@body)\n (substitute-printed-representation ()\n (let ((repr (with-output-to-string (s)\n (write ,object :stream s :escape nil)\n nil)))\n (write-json-string repr ,stream)))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(identifier nil)\n\nProblem: Macro call that should be transformed by IDENTIFIER", "input": "(identifier nil)", "output": "(defmacro IDENTIFIER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defobject nil)\n\nPattern to recognize: Macro call that should be transformed by DEFOBJECT", "input": "(defobject nil)", "output": "(defmacro DEFOBJECT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(re-setf nil nil)\n\nIssue: Macro call that should be transformed by RE-SETF", "input": "(re-setf nil nil)", "output": "(defmacro re-setf (var &rest clauses)\n \"SETFs VAR to the value of each clause subsequently.\n Re-uses the new value of VAR in subsequent clauses.\n Expects VAR to be a valid place for SETF.\"\n `(progn ,@(mapcar (lambda (clause)\n `(setf ,var ,clause))\n clauses)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-hook-type nil nil)\n\nProblem: Macro call that should be transformed by DEFINE-HOOK-TYPE", "input": "(define-hook-type nil nil)", "output": "(defmacro define-hook-type (name type &optional documentation)\n \"Define hook class.\nType must be something like:\n\n (function (string) (values integer t))\n\nThe `handler-type' of the defined hook class has `:class' allocation\ntype, so that all hooks of such class have the same `handler-type'.\"\n (let* ((name (string name))\n (hook-class-name (intern (serapeum:concat \"HOOK-\" name))))\n `(defclass ,hook-class-name (hook)\n ((handler-type :initform ',type :allocation :class))\n (:metaclass closer-mop:funcallable-standard-class)\n ,@(when documentation\n `((:documentation ,documentation))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(as->* nil :key nil)\n\nIssue: Macro call that should be transformed by AS->*", "input": "(as->* nil :key nil)", "output": "(defmacro AS->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(adowhile nil\n nil)\n\nProblem: Macro call that should be transformed by ADOWHILE", "input": "(adowhile nil\n nil)", "output": "(defmacro ADOWHILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(var nil :key nil)\n\nIssue: Macro call that should be transformed by VAR", "input": "(var nil :key nil)", "output": "(defmacro VAR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dig nil)\n\nIssue: Macro call that should be transformed by DIG", "input": "(dig nil)", "output": "(defmacro DIG ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(listcase nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by LISTCASE", "input": "(listcase nil\n (progn))", "output": "(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)))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-walker-handler-lexical-environment\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT", "input": "(with-walker-handler-lexical-environment\n 'lol-gen::some-name)", "output": "(defmacro WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defmethod nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEFMETHOD", "input": "(defmethod nil nil)", "output": "(defmacro defmethod (name &rest args)\n (handler-case\n (multiple-value-bind (qualifiers specializers lambda-list body)\n (parse-method args)\n\n (declare (ignore qualifiers))\n\n (with-gensyms (method)\n (let ((fn-name (gentemp (symbol-name (block-name name)) *method-function-package*)))\n `(progn\n ,(make-method-function name fn-name lambda-list body)\n\n (let ((,method\n (walk-environment\n (c2mop:defmethod ,name ,@args))))\n\n (when (combination-options ',name)\n ,(make-add-method-info name method fn-name body)\n ,(make-static-dispatch name lambda-list specializers))\n\n ,method)))))\n\n (error (e)\n (simple-style-warning \"Error parsing DEFMETHOD form:~%~2T~a\" e)\n `(walk-environment\n (c2mop:defmethod ,name ,@args)))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(acond\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by ACOND", "input": "(acond\n 'lol-gen::some-name)", "output": "(defmacro ACOND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-unknown-first-class-functions-allowed)\n\nPattern to recognize: Macro call that should be transformed by WITH-UNKNOWN-FIRST-CLASS-FUNCTIONS-ALLOWED", "input": "(with-unknown-first-class-functions-allowed)", "output": "(defmacro with-unknown-first-class-functions-allowed (&body body)\n `(let ((*allow-call-function-signature* t))\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-rules nil)\n\nProblem: Macro call that should be transformed by WITH-RULES", "input": "(with-rules nil)", "output": "(defmacro WITH-RULES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-ignore nil)\n\nWhat needs to change: Macro call that should be transformed by COLLECT-IGNORE", "input": "(collect-ignore nil)", "output": "(defmacro COLLECT-IGNORE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(do () (progn))\n\nPattern to recognize: Macro call that should be transformed by DO", "input": "(do () (progn))", "output": "(defmacro DO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(remove-from-plistf 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by REMOVE-FROM-PLISTF", "input": "(remove-from-plistf 'lol-gen::some-name)", "output": "(defmacro REMOVE-FROM-PLISTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-symbol-macro nil nil)\n\nProblem: Macro call that should be transformed by DEFINE-SYMBOL-MACRO", "input": "(define-symbol-macro nil nil)", "output": "(defmacro DEFINE-SYMBOL-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-live-scope\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-LIVE-SCOPE", "input": "(with-live-scope\n nil\n :key\n nil)", "output": "(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))))))", "category": "anaphoric", "technique": "macrolet,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(slet nil)\n\nWhat needs to change: Macro call that should be transformed by SLET", "input": "(slet nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(undefreply nil)\n\nWhat needs to change: Macro call that should be transformed by UNDEFREPLY", "input": "(undefreply nil)", "output": "(defmacro UNDEFREPLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nth-value-or 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by NTH-VALUE-OR", "input": "(nth-value-or 'lol-gen::some-name)", "output": "(defmacro nth-value-or (nth-value &body forms)\n \"Evaluates FORM arguments one at a time, until the NTH-VALUE returned by one\nof the forms is true. It then returns all the values returned by evaluating\nthat form. If none of the forms return a true nth value, this form returns\nNIL.\"\n (once-only (nth-value)\n (with-gensyms (values)\n `(let ((,values (multiple-value-list ,(first forms))))\n (if (nth ,nth-value ,values)\n (values-list ,values)\n ,(if (rest forms)\n `(nth-value-or ,nth-value ,@(rest forms))\n nil))))))", "category": "anaphoric", "technique": "once-only,gensym,anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.8374999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(deletef nil nil)\n\nPattern to recognize: Macro call that should be transformed by DELETEF", "input": "(deletef nil nil)", "output": "(defmacro DELETEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-foreign-type nil :key nil)\n\nProblem: Macro call that should be transformed by DEFINE-FOREIGN-TYPE", "input": "(define-foreign-type nil :key nil)", "output": "(defmacro define-foreign-type (name supers slots &rest options)\n (multiple-value-bind (new-options simple-parser actual-type initargs)\n (let ((keywords '(:simple-parser :actual-type :default-initargs)))\n (apply #'values\n (remove-if (lambda (opt) (member (car opt) keywords)) options)\n (mapcar (lambda (kw) (cdr (assoc kw options))) keywords)))\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (defclass ,name ,(or supers '(enhanced-foreign-type))\n ,slots\n (:default-initargs ,@(when actual-type `(:actual-type ',actual-type))\n ,@initargs)\n ,@new-options)\n ,(when simple-parser\n `(define-parse-method ,(car simple-parser) (&rest args)\n (apply #'make-instance ',name args)))\n ',name)))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fm-otherv? nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by FM-OTHERV?", "input": "(fm-otherv? nil :key nil)", "output": "(defmacro fm-otherv? (md-name &optional (starting 'self) (global-search t))\n `(fm-other-v ,md-name ,starting ,global-search))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fields nil)\n\nIssue: Macro call that should be transformed by FIELDS", "input": "(fields nil)", "output": "(defmacro fields (&rest fields)\n `(make-clause :fields ,@(mapcar #'expand-op fields)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(without-symbol-access\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITHOUT-SYMBOL-ACCESS", "input": "(without-symbol-access\n nil\n (progn))", "output": "(defmacro WITHOUT-SYMBOL-ACCESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(matrix-etypecase 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by MATRIX-ETYPECASE", "input": "(matrix-etypecase 'lol-gen::some-name)", "output": "(defmacro MATRIX-ETYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ccase nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by CCASE", "input": "(ccase nil (progn))", "output": "(defmacro CCASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(enable-quasi-quoted-string-to-binary-emitting-form-syntax nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ENABLE-QUASI-QUOTED-STRING-TO-BINARY-EMITTING-FORM-SYNTAX", "input": "(enable-quasi-quoted-string-to-binary-emitting-form-syntax nil)", "output": "(defmacro ENABLE-QUASI-QUOTED-STRING-TO-BINARY-EMITTING-FORM-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(right nil)\n\nIssue: Macro call that should be transformed by RIGHT", "input": "(right nil)", "output": "(defmacro right (parser &rest parsers)\n \"Combination of parsers yielding the result of the rightmost one.\"\n `(*> ,parser ,@parsers))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(disable-dot-syntax)\n\nWrite a macro that addresses: Macro call that should be transformed by DISABLE-DOT-SYNTAX", "input": "(disable-dot-syntax)", "output": "(defmacro disable-dot-syntax ()\n \"Restore readtable which was active before last call to If there was no such call, the standard\nreadtable is used.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (%disable-dot-syntax)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(matrix-case 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by MATRIX-CASE", "input": "(matrix-case 'lol-gen::some-name)", "output": "(defmacro MATRIX-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(iterate\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by ITERATE", "input": "(iterate\n nil\n nil)", "output": "(defmacro iterate (&body body)\n \"Jonathan Amsterdam's powerful iteration facility\"\n `(iter .,body))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(push-end-new nil (progn))\n\nPattern to recognize: Macro call that should be transformed by PUSH-END-NEW", "input": "(push-end-new nil (progn))", "output": "(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)))))", "category": "anaphoric", "technique": "once-only,anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(special-symbol-reprogv nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by SPECIAL-SYMBOL-REPROGV", "input": "(special-symbol-reprogv nil\n (progn))", "output": "(defmacro SPECIAL-SYMBOL-REPROGV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-yield)\n\nWhat needs to change: Macro call that should be transformed by WITH-YIELD", "input": "(with-yield)", "output": "(defmacro WITH-YIELD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(shift-incf nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SHIFT-INCF", "input": "(shift-incf nil (progn))", "output": "(defmacro SHIFT-INCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(deftable nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFTABLE", "input": "(deftable nil\n :key\n nil)", "output": "(defmacro deftable (name &body definitions)\n \"Define a table. name can be either a symbol or a (symbol string) list. In the\nfirst case, the table name is derived from the symbol by S-SQL's rules, in the\nsecond case, the name is given explicitly. The body of definitions can contain\nanything that evaluates to a string, as well as S-SQL expressions. In this body,\nthe variables *table-name* and *table-symbol* are bound to the relevant values.\nNote that the evaluation of the definition is ordered, so you will generally\nwant to create your table first and then define indices on it.\"\n (multiple-value-bind (symbol name)\n (if (consp name) (values-list name) (values name (to-sql-name name nil)))\n (flet ((check-s-sql (form)\n (if (and (consp form) (keywordp (car form))) (list 'sql form) form)))\n `(add-table-definition\n ',symbol\n (lambda ()\n (let ((*table-name* ,name) (*table-symbol* ',symbol))\n (dolist (stat (list ,@(mapcar #'check-s-sql definitions)))\n (execute stat))))))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(c?1\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by C?1", "input": "(c?1\n nil\n :key\n nil)", "output": "(defmacro c?1 (&body body)\n `(c?once ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dynamic-extent common-lisp:nil\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by DYNAMIC-EXTENT", "input": "(dynamic-extent common-lisp:nil\n common-lisp:nil)", "output": "(defmacro DYNAMIC-EXTENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-hook-restart\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-HOOK-RESTART", "input": "(with-hook-restart\n nil\n :key\n nil)", "output": "(defmacro with-hook-restart (&body body)\n `(with-simple-restart (continue \"Call next function in hook ~s\" *hook*)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(export-class\n common-lisp:nil\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by EXPORT-CLASS", "input": "(export-class\n common-lisp:nil\n common-lisp:nil)", "output": "(defmacro EXPORT-CLASS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond-it\n nil)\n\nPattern to recognize: Macro call that should be transformed by COND-IT", "input": "(cond-it\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ematch nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EMATCH", "input": "(ematch nil\n nil)", "output": "(defmacro ematch (arg &body clauses)\n \"Same as MATCH, except MATCH-ERROR will be raised if not matched.\"\n (once-only (arg)\n (let ((else `(error 'match-error\n :values (list ,arg)\n :patterns ',(mapcar (lambda (c) (list (car c))) clauses))))\n (compile-match-1 arg clauses else))))", "category": "control-flow", "technique": "once-only", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ap nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AP", "input": "(ap nil nil)", "output": "(defmacro ap (f parser &rest parsers)\n \"Run many parsers that must all succeed, and apply their success values to a\ngiven lambda. More memory-efficient than the combination of `<*>' and `fmap'.\"\n (let ((offset (gensym \"ap-OFFSET\"))\n (final (gensym \"ap-FINAL\")))\n `(lambda (,offset)\n ,(labels ((recurse (ps rs i)\n (if (null ps)\n (let ((ordered (nreverse rs)))\n ;; NOTE: 2025-10-20 This final check allows the user to\n ;; yield `:fail' from within the passed lambda as well.\n ;; It will be detected here and the failure offset will\n ;; be set to the original offset, not the last one it\n ;; got to. Overall this improves error reporting, as\n ;; there was already nothing preventing the user from\n ;; yielding `:fail' anyway.\n `(let ((,final (funcall ,f ,@ordered)))\n (if (failure? ,final)\n (fail ,offset)\n (values ,final ,i))))\n (let ((res (gensym \"ap-RES\"))\n (next (gensym \"ap-NEXT\")))\n `(multiple-value-bind (,res ,next) (funcall ,(car ps) ,i)\n (if (failure? ,res)\n (fail ,next)\n ,(recurse (cdr ps) (cons res rs) next)))))))\n (recurse (cons parser parsers) '() offset)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(->> nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by ->>", "input": "(->> nil (progn))", "output": "(defmacro ->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(match nil\n (progn))", "output": "(defmacro match (arg &body clauses)\n \"Matches ARG with CLAUSES. CLAUSES is a list of the form of (PATTERN\n. BODY) where PATTERN is a pattern specifier and BODY is an implicit\nprogn. If ARG matches some PATTERN, `match` then evaluates\nthe corresponding BODY and returns the evaluated value. If no pattern matches,\nthen returns NIL.\n\nEvaluating a form (FAIL) in the clause body causes the latest pattern\nmatching to fail. For example,\n\n (match 1\n (x (if (eql x 1)\n (fail)\n x))\n (_ 'ok))\n\nreturns OK, because the form (FAIL) in the first clause is\nevaluated.\n\nIf BODY starts with the symbols WHEN or UNLESS, then the next form\nwill be used to introduce (FAIL). That is,\n\n (match list ((list x) when (oddp x) x))\n (match list ((list x) unless (evenp x) x))\n\nwill be translated to\n\n (match list ((list x) (if (oddp x) x (fail))))\n (match list ((list x) (if (evenp x) (fail) x)))\n\nExamples:\n\n (match 1 (1 1))\n => 1\n (match 1 (2 2))\n => 2\n (match 1 (x x))\n => 1\n (match (list 1 2 3)\n (list x y z) (+ x y z))\n => 6\"\n (compile-match-1 arg clauses nil))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(summing\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by SUMMING", "input": "(summing\n 'lol-gen::some-name)", "output": "(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))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(v-defun nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by V-DEFUN", "input": "(v-defun nil\n :key\n nil)", "output": "(defmacro v-defun (name args &body body)\n `(define-vari-function ,name ,args ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ecase-using nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by ECASE-USING", "input": "(ecase-using nil\n :key\n nil)", "output": "(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)))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(^fm-next-sib nil)\n\nIssue: Macro call that should be transformed by ^FM-NEXT-SIB", "input": "(^fm-next-sib nil)", "output": "(defmacro ^fm-next-sib (&optional (self 'self))\n (let ((s (gensym)))\n `(let ((,s ,self))\n (car (cdr (member ,s (kids (fm-parent ,s))))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is-error nil (progn))\n\nProblem: Macro call that should be transformed by IS-ERROR", "input": "(is-error nil (progn))", "output": "(defmacro IS-ERROR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(notinline common-lisp:nil\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by NOTINLINE", "input": "(notinline common-lisp:nil\n common-lisp:nil)", "output": "(defmacro NOTINLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c-lambda\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by C-LAMBDA", "input": "(c-lambda\n nil\n nil)", "output": "(defmacro c-lambda (&body body)\n `(c-lambda-var (slot-c) ,@body))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "basic", "quality_score": 0.7775} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(sort-values nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SORT-VALUES", "input": "(sort-values nil (progn))", "output": "(defmacro sort-values (pred &rest values)\n \"Sort VALUES with PRED and return as multiple values.\n\nEquivalent to\n\n (values-list (sort (list VALUES...) pred))\n\nBut with less consing, and potentially faster.\"\n ;; Remember to evaluate `pred' no matter what.\n (with-gensyms (gpred)\n `(let ((,gpred (ensure-function ,pred)))\n (declare (ignorable ,gpred)\n (function ,gpred)\n (optimize (safety 1) (debug 0) (compilation-speed 0)))\n ,(match values\n ((list) `(values))\n ((list x) `(values ,x))\n ;; The strategy here is to use a sorting network if the\n ;; inputs are few, and a stack-allocated vector if the\n ;; inputs are many.\n (otherwise\n (if (<= (length values) 8)\n `(sort-values/network ,gpred ,@values)\n `(sort-values/temp-vector ,gpred ,@values)))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(setypecase nil)\n\nPattern to recognize: Macro call that should be transformed by SETYPECASE", "input": "(setypecase nil)", "output": "(defmacro setypecase (keyform &body cases)\n \"Like ETYPECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for\nthe scope of the cases. IT can be set with SETF.\"\n `(symbolic etypecase ,keyform ,@cases))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-product nil)\n\nIssue: Macro call that should be transformed by COLLECT-PRODUCT", "input": "(collect-product nil)", "output": "(defmacro COLLECT-PRODUCT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(and-let nil nil)\n\nWhat needs to change: Macro call that should be transformed by AND-LET", "input": "(and-let nil nil)", "output": "(defmacro and-let (var &rest args)\n \"Like AND. VAR will be bound to the value of the previous AND form\"\n (cond ((null args) t)\n ((null (cdr args)) (car args))\n (t `(when-let (,var ,(car args))\n (and ,@(cdr args))))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda () :key nil)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA", "input": "(lambda () :key nil)", "output": "(defmacro LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(global\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by GLOBAL", "input": "(global\n 'lol-gen::some-name)", "output": "(defmacro GLOBAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make-kid nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-KID", "input": "(make-kid nil)", "output": "(defmacro make-kid (class &rest ia)\n (with-gensyms (c)\n `(let ((,c ,class))\n (make-instance ,c\n ,@ia\n :fm-parent (progn (assert self () \"make-kid: self nil making ~a\" ,c)\n self)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(in-compile-time nil)\n\nPattern to recognize: Macro call that should be transformed by IN-COMPILE-TIME", "input": "(in-compile-time nil)", "output": "(defmacro IN-COMPILE-TIME ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-dao-class nil :key nil)\n\nProblem: Macro call that should be transformed by DEFINE-DAO-CLASS", "input": "(define-dao-class nil :key nil)", "output": "(defmacro define-dao-class (name direct-superclasses direct-slots &rest options)\n \"Like defclass except two postmodern specific changes:\n1. The dao-class metaclass options is automatically added.\n2. If second value in a slot is not a keyword, it is assumed to be col-type.\n\nExample:\n(define-dao-class id-class ()\n ((id integer :initarg :id :accessor test-id)\n (email :col-type text :initarg :email :accessor email))\n (:keys id))\"\n (flet ((expand-slot (rest)\n\t (let ((second\n\t\t (second rest)))\n\t (if (keywordp second)\n\t\t rest\n\t\t (cons (first rest)\n\t\t (append (list :col-type second)\n\t\t\t (cddr rest)))))))\n (list* 'defclass name direct-superclasses\n\t (mapcar #'expand-slot direct-slots)\n\t (list :metaclass 'dao-class)\n\t options)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-cc 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-CC", "input": "(with-cc 'lol-gen::some-name)", "output": "(defmacro with-cc (id &body body)\n `(with-integrity (:change ,id)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-alternate-type-name nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-ALTERNATE-TYPE-NAME", "input": "(define-alternate-type-name nil nil)", "output": "(defmacro define-alternate-type-name (current-type-name alternate-type-name)\n `(add-alternate-type-name ',alternate-type-name ',current-type-name))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defgeneric nil (progn))\n\nIssue: Macro call that should be transformed by DEFGENERIC", "input": "(defgeneric nil (progn))", "output": "(defmacro DEFGENERIC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(collect-or nil)\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECT-OR", "input": "(collect-or nil)", "output": "(defmacro COLLECT-OR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(local\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by LOCAL", "input": "(local\n 'lol-gen::some-name)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(export)\n\nIssue: Macro call that should be transformed by EXPORT", "input": "(export)", "output": "(defmacro EXPORT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ignoring nil\n nil)\n\nIssue: Macro call that should be transformed by IGNORING", "input": "(ignoring nil\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond)\n\nWhat needs to change: Macro call that should be transformed by COND", "input": "(cond)", "output": "(defmacro COND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(is-every nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IS-EVERY", "input": "(is-every nil\n :key\n nil)", "output": "(defmacro is-every (predicate &body clauses)\n \"The input is either a list of lists, or a list of pairs. Generates (is (,predicate ,expr ,value))\n for each pair of elements or (is (,predicate ,expr ,value) ,@reason) for each list.\"\n `(progn\n ,@(if (every #'consp clauses)\n (loop for (expected actual . reason) in clauses\n collect `(is (,predicate ,expected ,actual) ,@reason))\n (progn\n (assert (evenp (list-length clauses)))\n (loop for (expr value) on clauses by #'cddr\n collect `(is (,predicate ,expr ,value)))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-train nil\n nil)\n\nProblem: Macro call that should be transformed by DEFINE-TRAIN", "input": "(define-train nil\n nil)", "output": "(defmacro define-train (name args &body body)\n \"Define a higher-order function and its compiler macro at once.\n\nWhen defining a higher-order function it is often a good idea to\nwrite a compiler macro so compilers can inline the resulting lambda\nform.\n\nFor the special case of a fixed-arity function that only takes other\nfunctions as arguments, you can use `define-train' to define the\nfunction and the compiler macro in one go. The catch is that you have\nto write the single definition as a macro.\n\nE.g., if `complement' did not exist, you could define it like so:\n\n (define-train complement (fn)\n `(lambda (&rest args)\n (not (apply ,fn args))))\n\nBesides providing an implicit compiler macro, `define-train' also\ninserts the proper declarations to ensure the compiler recognizes the\nfunction arguments as functions, avoiding runtime type checks.\n\nThe term \\\"train\\\" is from J.\"\n (multiple-value-bind (body decls docstring)\n (parse-body body :documentation t)\n `(progn\n (define-compiler-macro ,name ,args\n ,@decls\n (rebinding-functions ,args\n ,@body))\n (defun ,name ,args\n ,@(unsplice docstring)\n (macrolet ((,name ,args\n ,@decls\n (rebinding-functions ,args\n ,@body)))\n (,name ,@args))))))", "category": "anaphoric", "technique": "compiler-macro,macrolet,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9299999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(match common-lisp:nil)\n\nProblem: Macro call that should be transformed by MATCH", "input": "(match common-lisp:nil)", "output": "(defmacro match (what &body clauses)\n #.+match-doc+\n `(match2 ,what\n ,@clauses\n (_ nil)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(eval-always\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n nil\n (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c-formula nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by C-FORMULA", "input": "(c-formula nil\n (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fields nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FIELDS", "input": "(fields nil nil)", "output": "(defmacro fields (&rest fields)\n `(make-clause :fields ,@(mapcar #'expand-op fields)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(right-join nil)\n\nPattern to recognize: Macro call that should be transformed by RIGHT-JOIN", "input": "(right-join nil)", "output": "(defmacro right-join (table &key on using)\n `(join ,table :kind :right :on ,on :using ,using))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(translation-forms-for-class nil (progn))\n\nWhat needs to change: Macro call that should be transformed by TRANSLATION-FORMS-FOR-CLASS", "input": "(translation-forms-for-class nil (progn))", "output": "(defmacro translation-forms-for-class (class type-class)\n \"Make forms for translation of foreign structures to and from a standard class. The class slots are assumed to have the same name as the foreign structure.\"\n ;; Possible improvement: optional argument to map structure slot names to/from class slot names.\n `(progn\n (defmethod translate-from-foreign (pointer (type ,type-class))\n ;; Make the instance from the plist\n (apply 'make-instance ',class (call-next-method)))\n (defmethod translate-into-foreign-memory ((object ,class) (type ,type-class) pointer)\n (call-next-method\n ;; Translate into a plist and call the general method\n (loop for slot being the hash-value of (structure-slots type)\n for name = (slot-name slot)\n append (list slot-name (slot-value object slot-name)))\n type\n pointer))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(ensure-gethash nil (progn))\n\nPattern to recognize: Macro call that should be transformed by ENSURE-GETHASH", "input": "(ensure-gethash nil (progn))", "output": "(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))))))", "category": "anaphoric", "technique": "once-only,anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fm-otherv? nil (progn))\n\nProblem: Macro call that should be transformed by FM-OTHERV?", "input": "(fm-otherv? nil (progn))", "output": "(defmacro fm-otherv? (md-name &optional (starting 'self) (global-search t))\n `(fm-other-v ,md-name ,starting ,global-search))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(make-name-transformer nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by MAKE-NAME-TRANSFORMER", "input": "(make-name-transformer nil :key nil)", "output": "(defmacro MAKE-NAME-TRANSFORMER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fail-compile nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by FAIL-COMPILE", "input": "(fail-compile nil :key nil)", "output": "(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))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(js nil (progn))\n\nWhat needs to change: Macro call that should be transformed by JS", "input": "(js nil (progn))", "output": "(defmacro JS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(awhen nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by AWHEN", "input": "(awhen nil\n :key\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(type common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by TYPE", "input": "(type common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro TYPE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(false nil)\n\nProblem: Macro call that should be transformed by FALSE", "input": "(false nil)", "output": "(defmacro false (form &optional description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(false ,form)\n :value-form ',form\n :body (lambda () ,form)\n :expected 'NIL\n :comparison 'geq\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(next-in nil (progn))\n\nProblem: Macro call that should be transformed by NEXT-IN", "input": "(next-in nil (progn))", "output": "(defmacro NEXT-IN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-transaction nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-TRANSACTION", "input": "(with-transaction nil\n :key\n nil)", "output": "(defmacro with-transaction (conn &body body)\n \"Start a transaction and commit at the end of this block. If the evaluation `body` is interrupted, the transaction is rolled back automatically.\"\n (let ((conn-var (gensym \"CONN-VAR\")))\n `(let ((,conn-var ,conn))\n (if (in-transaction ,conn-var)\n (with-savepoint ,conn-var ,@body)\n (%with-transaction ,conn-var ,@body)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(returning)\n\nProblem: Macro call that should be transformed by RETURNING", "input": "(returning)", "output": "(defmacro returning (&rest expressions)\n `(apply #'make-clause :returning\n (list ,@(mapcar (lambda (expr)\n (if (and (listp expr)\n (keywordp (car expr)))\n (expand-op expr)\n `,expr))\n expressions))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond->> nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by COND->>", "input": "(cond->> nil\n :key\n nil)", "output": "(defmacro cond->> (init &body exps) (cond-arrow-macro init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(unless-match common-lisp:nil\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by UNLESS-MATCH", "input": "(unless-match common-lisp:nil\n common-lisp:nil)", "output": "(defmacro unless-match (pattern arg &body body)\n \"Equivalent to (match ARG (PATTERN) (_ BODY...)).\"\n `(match ,arg\n (,pattern)\n (_ ,.body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-object nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-OBJECT", "input": "(with-object nil\n nil)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-module 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-MODULE", "input": "(with-module 'lol-gen::some-name)", "output": "(defmacro with-module ((var &optional (module var)) &body body)\n `(let ((,var (module ,module)))\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-shuffling)\n\nWhat needs to change: Macro call that should be transformed by WITH-SHUFFLING", "input": "(with-shuffling)", "output": "(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))))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-yield\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-YIELD", "input": "(with-yield\n nil\n (progn))", "output": "(defmacro WITH-YIELD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(unless 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by UNLESS", "input": "(unless 'lol-gen::some-name)", "output": "(defmacro UNLESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(drelet* 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DRELET*", "input": "(drelet* 'lol-gen::some-name)", "output": "(defmacro DRELET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(skip-on nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SKIP-ON", "input": "(skip-on nil\n :key\n nil)", "output": "(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)))))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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 ->", "input": "(-> nil nil)", "output": "(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)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-fn nil :key nil)\n\nIssue: Macro call that should be transformed by COLLECT-FN", "input": "(collect-fn nil :key nil)", "output": "(defmacro COLLECT-FN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(iter\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by ITER", "input": "(iter\n nil\n nil)", "output": "(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)))))))", "category": "anaphoric", "technique": "tagbody-go,gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-hook-generic nil (progn))\n\nIssue: Macro call that should be transformed by DEFINE-HOOK-GENERIC", "input": "(define-hook-generic nil (progn))", "output": "(defmacro define-hook-generic (name gf-lambda-list &rest options)\n \"utility to help with gf's with method combination by remembering the combination type\n\nby default the combination type becomes the default qualifier for any newly defined hooks\nthis can be overriden by not using this and using defgeneric or supplying\nthe option :default-qualifier.\n\nsupplying `:hook-point t` will create a method qualified with the default-qualifier\nso that the generic acts like an extensible hook point and will not signal\nno-applicable-method error when no hooks have been defined.\n\nSee defhook\"\n (let* ((combination-option (find :method-combination options :key #'car :test #'eql))\n (combination-type\n (cond ((null combination-option) 'progn)\n ((null (cadr combination-option)) :unqualified)\n ((eql 'standard (cadr combination-option)) :unqualified)\n (t (cadr combination-option))))\n (default-qualifier\n (let ((d (cadr (find :default-qualifier options :key #'car :test #'eql))))\n (if (null d) combination-type d)))\n (hook-point (find :hook-point options :key #'car)))\n\n (intern-hook-generic name combination-type default-qualifier)\n `(progn (intern-hook-generic ',name ',combination-type ',default-qualifier)\n (defgeneric ,name ,gf-lambda-list\n ,@ (remove-if (lambda (s) (or (eql s :method-combination)\n (eql s :default-qualifier)\n (eql s :hook-point)))\n options :key #'car)\n (:method-combination\n ,(if (eql :unqualified combination-type) 'standard combination-type)))\n\n ,(when hook-point\n (remove :unqualified `(defmethod ,name ,default-qualifier ,gf-lambda-list)\n :end 3)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(dynamic-relet nil)\n\nPattern to recognize: Macro call that should be transformed by DYNAMIC-RELET", "input": "(dynamic-relet nil)", "output": "(defmacro DYNAMIC-RELET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-slots nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-SLOTS", "input": "(with-slots nil\n nil)", "output": "(defmacro WITH-SLOTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(undef$method 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by UNDEF$METHOD", "input": "(undef$method 'lol-gen::some-name)", "output": "(defmacro UNDEF$METHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-parse-method nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-PARSE-METHOD", "input": "(define-parse-method nil\n (progn))", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-stemcell-infer-hook 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-STEMCELL-INFER-HOOK", "input": "(with-stemcell-infer-hook 'lol-gen::some-name)", "output": "(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)))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-shadowed-custom-vars\n nil)\n\nProblem: Macro call that should be transformed by WITH-SHADOWED-CUSTOM-VARS", "input": "(with-shadowed-custom-vars\n nil)", "output": "(defmacro with-shadowed-custom-vars (&body body)\n `(let ,(loop for (var) in *custom-vars*\n collect `(,var (if (boundp ',var) ,var)))\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cmatch nil\n nil)\n\nIssue: Macro call that should be transformed by CMATCH", "input": "(cmatch nil\n nil)", "output": "(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))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(is nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IS", "input": "(is nil :key nil)", "output": "(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)))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(rotatef)\n\nWrite a macro that addresses: Macro call that should be transformed by ROTATEF", "input": "(rotatef)", "output": "(defmacro ROTATEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(f_%\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by F_%", "input": "(f_%\n nil\n :key\n nil)", "output": "(defmacro F_% ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(in-compile-time nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by IN-COMPILE-TIME", "input": "(in-compile-time nil\n (progn))", "output": "(defmacro IN-COMPILE-TIME ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(call-method nil)\n\nPattern to recognize: Macro call that should be transformed by CALL-METHOD", "input": "(call-method nil)", "output": "(defmacro call-method (method &optional methods)\n `(cl:call-method ,method ,methods))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-collectors nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-COLLECTORS", "input": "(with-collectors nil\n :key\n nil)", "output": "(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))))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(=> nil (progn))\n\nProblem: Macro call that should be transformed by =>", "input": "(=> nil (progn))", "output": "(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))))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(tree-ecase 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by TREE-ECASE", "input": "(tree-ecase 'lol-gen::some-name)", "output": "(defmacro TREE-ECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(example\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EXAMPLE", "input": "(example\n nil\n nil)", "output": "(defmacro example (&body body)\n \"Like `comment'.\"\n `(comment ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is-true nil :key nil)\n\nProblem: Macro call that should be transformed by IS-TRUE", "input": "(is-true nil :key nil)", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(for-all nil)\n\nWhat needs to change: Macro call that should be transformed by FOR-ALL", "input": "(for-all nil)", "output": "(defmacro for-all (bindings &body body)\n \"Bind BINDINGS to random variables and test BODY *num-trials* times.\n\nBINDINGS is a list of binding forms, each element is a list\nof (BINDING VALUE &optional GUARD). Value, which is evaluated\nonce when the for-all is evaluated, must return a generator which\nbe called each time BODY is evaluated. BINDING is either a symbol\nor a list which will be passed to destructuring-bind. GUARD is a\nform which, if present, stops BODY from executing when IT returns\nNIL. The GUARDS are evaluated after all the random data has been\ngenerated and they can refer to the current value of any\nbinding. NB: Generator forms, unlike guard forms, can not contain\nreferences to the bound variables.\n\nExamples:\n\n (for-all ((a (gen-integer)))\n (is (integerp a)))\n\n (for-all ((a (gen-integer) (plusp a)))\n (is (integerp a))\n (is (plusp a)))\n\n (for-all ((less (gen-integer))\n (more (gen-integer) (< less more)))\n (is (<= less more)))\n\n (for-all (((a b) (gen-two-integers)))\n (is (integerp a))\n (is (integerp b)))\"\n (with-gensyms (test-lambda-args)\n `(perform-random-testing\n (list ,@(mapcar #'second bindings))\n (lambda (,test-lambda-args)\n (destructuring-bind ,(mapcar #'first bindings)\n ,test-lambda-args\n (if (and ,@(delete-if #'null (mapcar #'third bindings)))\n (progn ,@body)\n (throw 'run-once\n (list :guard-conditions-failed))))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(multiple-value-bind nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by MULTIPLE-VALUE-BIND", "input": "(multiple-value-bind nil (progn))", "output": "(defmacro MULTIPLE-VALUE-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(test 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by TEST", "input": "(test 'lol-gen::some-name)", "output": "(defmacro test (name &body body)\n \"Create a test named NAME. If NAME is a list it must be of the\nform:\n\n (name &key depends-on suite fixture compile-at profile)\n\nNAME is the symbol which names the test.\n\nDEPENDS-ON is a list of the form:\n\n (AND . test-names) - This test is run only if all of the tests\n in TEST-NAMES have passed, otherwise a single test-skipped\n result is generated.\n\n (OR . test-names) - If any of TEST-NAMES has passed this test is\n run, otherwise a test-skipped result is generated.\n\n (NOT test-name) - This is test is run only if TEST-NAME failed.\n\nAND, OR and NOT can be combined to produce complex dependencies.\n\nIf DEPENDS-ON is a symbol it is interpreted as `(AND\n,depends-on), this is accomadate the common case of one test\ndepending on another.\n\nFIXTURE specifies a fixture to wrap the body in.\n\nIf PROFILE is T profiling information will be collected as well.\"\n (destructuring-bind (name &rest args)\n (ensure-list name)\n `(def-test ,name (,@args) ,@body)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(callf nil :key nil)\n\nProblem: Macro call that should be transformed by CALLF", "input": "(callf nil :key nil)", "output": "(defmacro callf (function place &rest args &environment env)\n \"Set PLACE to the value of calling FUNCTION on PLACE, with ARGS.\"\n (multiple-value-bind (vars vals stores setter getter)\n (get-setf-expansion place env)\n `(let* ,(mapcar #'list vars vals)\n (multiple-value-bind ,stores\n (funcall ,function ,getter ,@args)\n ,setter))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(save-generator)\n\nWrite a macro that addresses: Macro call that should be transformed by SAVE-GENERATOR", "input": "(save-generator)", "output": "(defmacro save-generator (&key name start-function in-package)\n `(defun ,name (name)\n (labels ((dump-start ()\n\t\t(in-package ,in-package)\n\t\t(setf (readtable-case *readtable*) :invert)\n\t\t#+sbcl (,start-function sb-ext:*posix-argv*)\n\t\t#+clozure (handler-case\n\t\t\t (,start-function ccl::*command-line-argument-list*)\n\t\t\t (error (err) (let ((*print-pretty* t))\n\t\t\t\t\t (format *error-output* \"~a\" err)\n\t\t\t\t\t (ccl::quit 1))))\n\t\t#+ecl (,start-function (loop for i from 0 below (si:argc) collect (si:argv i)))\n\t\t#-(or sbcl clozure ecl)\n\t\t(error \"Missing implementation of 'save-generator' for your lisp implementation\") \n\t\t))\n (net.didierverna.clon:dump name dump-start))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-c-syntax common-lisp:nil\n :key\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-C-SYNTAX", "input": "(with-c-syntax common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro with-c-syntax ((&rest options\n\t\t\t &key (preprocess t)\n (reader-level *with-c-syntax-reader-level*)\n (readtable-case (or *with-c-syntax-reader-case*\n (readtable-case *readtable*)))\n (input-file-pathname nil)\n\t\t\t (try-add-{} t))\n\t\t\t &environment *wcs-expanding-environment*\n\t\t\t &body body)\n \"This macro is a entry point of the with-c-syntax system. BODY will be\ninterpreted as C syntax, executed, and return values.\n\nThis macro returns the last form's value if BODY is a compound\nstatement, or returns NIL if BODY is a compilation unit.\n\nPREPROCESS specifies how to do preprocess. If nil, this macro compiles\nBODY without preprocessing. If t, preprocesses and compiles BODY. If\n`:preprocess-only', this macro preprocesses BODY and returns the\nresult as-is.\n\nREADER-LEVEL specifies the reader level (see `*with-c-syntax-reader-level*').\nThis is used when '#include' or '_Pragma()' was used.\n\nREADTABLE-CASE specifies the readtable case of symbols in BODY when it\nwas read. This affects how to intern C keywords by the preprocessor.\n\nINPUT-FILE-PATHNAME is passed to the preprocessor and used when\n'__FILE__' macro was used.\n\nIf TRY-ADD-{} is t and an error occurred at parsing, `with-c-syntax'\nadds '{' and '}' into the head and tail of FORM respectively, and\ntries to parse again.\"\n (cond\n ((null body)\n nil)\n ((and (length= 1 (the list body))\t; with-c-syntax is nested.\n\t (starts-with 'with-c-syntax (first body)))\n (destructuring-bind (op_ options2 &body body2)\n\t (first body)\n (declare (ignore op_))\n `(with-c-syntax (,@options ,@options2) ,@body2)))\n (t\n (ecase preprocess\n (:preprocess-only\n (preprocessor body reader-level readtable-case input-file-pathname))\n (t\n `(with-c-syntax (:preprocess nil :try-add-{} ,try-add-{})\n ,@(preprocessor body reader-level readtable-case input-file-pathname)))\n ((nil)\n (expand-c-syntax body\n\t\t try-add-{}))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.95} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(case 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by CASE", "input": "(case 'lol-gen::some-name)", "output": "(defmacro CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(summing-to nil)\n\nWhat needs to change: Macro call that should be transformed by SUMMING-TO", "input": "(summing-to nil)", "output": "(defmacro SUMMING-TO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(and-let* 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by AND-LET*", "input": "(and-let* 'lol-gen::some-name)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nix 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by NIX", "input": "(nix 'lol-gen::some-name)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond-it)\n\nPattern to recognize: Macro call that should be transformed by COND-IT", "input": "(cond-it)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(gatherlet nil\n nil)\n\nIssue: Macro call that should be transformed by GATHERLET", "input": "(gatherlet nil\n nil)", "output": "(defmacro GATHERLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cond->)\n\nProblem: Macro call that should be transformed by COND->", "input": "(cond->)", "output": "(defmacro COND-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-special-initargs* nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-SPECIAL-INITARGS*", "input": "(with-special-initargs* nil\n nil)", "output": "(defmacro WITH-SPECIAL-INITARGS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(pushnew nil nil)\n\nProblem: Macro call that should be transformed by PUSHNEW", "input": "(pushnew nil nil)", "output": "(defmacro PUSHNEW ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-test+run nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by DEFINE-TEST+RUN", "input": "(define-test+run nil\n :key\n nil)", "output": "(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))))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ignorable 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by IGNORABLE", "input": "(ignorable 'lol-gen::some-name)", "output": "(defmacro IGNORABLE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(some-<>> nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SOME-<>>", "input": "(some-<>> nil\n (progn))", "output": "(defmacro some-<>> (init &body exps) (diamond-wand init exps t t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(empty)\n\nWhat needs to change: Macro call that should be transformed by EMPTY", "input": "(empty)", "output": "(defmacro EMPTY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(as common-lisp:nil (common-lisp:progn))\n\nPattern to recognize: Macro call that should be transformed by AS", "input": "(as common-lisp:nil (common-lisp:progn))", "output": "(defmacro as (type cl:&optional (expr cl:nil expr-supplied-p))\n \"A syntactic convenience for type casting.\n\n (as )\n\nis equivalent to\n\n (the (into ))\n\nand\n\n (as )\n\nis equivalent to\n\n (fn (expr) (the (into expr))).\n\nNote that this may copy the object or allocate memory.\"\n\n (cl:let ((into (cl:ignore-errors (cl:find-symbol \"INTO\" \"COALTON/CLASSES\"))))\n (cl:assert into () \"`as` macro does not have access to `into` yet.\")\n (cl:if expr-supplied-p\n `(the ,type (,into ,expr))\n (alexandria:with-gensyms (lexpr)\n `(fn (,lexpr)\n (the ,type (,into ,lexpr)))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ensure-functionf)\n\nWrite a macro that addresses: Macro call that should be transformed by ENSURE-FUNCTIONF", "input": "(ensure-functionf)", "output": "(defmacro ensure-functionf (&rest places)\n \"Multiple-place modify macro for ENSURE-FUNCTION: ensures that each of\nPLACES contains a function.\"\n `(progn ,@(mapcar (lambda (x) `(ensure-functionf/1 ,x)) places)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.815} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c-formula 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by C-FORMULA", "input": "(c-formula 'lol-gen::some-name)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(make-dispatcher nil)\n\nIssue: Macro call that should be transformed by MAKE-DISPATCHER", "input": "(make-dispatcher nil)", "output": "(defmacro make-dispatcher (function-constructor)\n `(make-instance 'dispatcher :dispatch-function-constructor ',function-constructor\n :dispatch-function ,function-constructor))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(psetf nil (progn))\n\nIssue: Macro call that should be transformed by PSETF", "input": "(psetf nil (progn))", "output": "(defmacro PSETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(producing nil nil)\n\nProblem: Macro call that should be transformed by PRODUCING", "input": "(producing nil nil)", "output": "(defmacro PRODUCING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(nest nil)\n\nWhat needs to change: Macro call that should be transformed by NEST", "input": "(nest nil)", "output": "(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))", "category": "dsl", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8274999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(order-by nil (progn))\n\nProblem: Macro call that should be transformed by ORDER-BY", "input": "(order-by nil (progn))", "output": "(defmacro order-by (&rest expressions)\n `(make-clause :order-by ,@(expand-expression expressions)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-test+run nil)\n\nProblem: Macro call that should be transformed by DEFINE-TEST+RUN", "input": "(define-test+run nil)", "output": "(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))))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-vari-macro nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-VARI-MACRO", "input": "(define-vari-macro nil\n (progn))", "output": "(defmacro define-vari-macro (name lambda-list &body body)\n (check-args-for-constant-names :macro name lambda-list)\n (vbind (func-code context) (gen-macro-function-code name lambda-list body)\n `(progn\n (add-global-form-binding\n (make-regular-macro ',name ,func-code ',context nil))\n ',name)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(esc nil :key nil)\n\nProblem: Macro call that should be transformed by ESC", "input": "(esc nil :key nil)", "output": "(defmacro esc (&rest forms)\n `(list\n ,@(loop for form in forms\n collect (%escape-string-form form))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ekx nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by EKX", "input": "(ekx nil (progn))", "output": "(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)))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fdec nil nil)\n\nWhat needs to change: Macro call that should be transformed by FDEC", "input": "(fdec nil nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(secase nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by SECASE", "input": "(secase nil\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(jwhen nil)\n\nWhat needs to change: Macro call that should be transformed by JWHEN", "input": "(jwhen nil)", "output": "(defmacro jwhen (test &body body)\n \"JSON-aware version of `cl:when'.\nIf TEST is `jtruep' evaluate BODY.\"\n `(jif ,test\n (progn ,@body)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-hash nil nil)\n\nWhat needs to change: Macro call that should be transformed by COLLECT-HASH", "input": "(collect-hash nil nil)", "output": "(defmacro COLLECT-HASH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dolist (quote lol-gen::some-name))\n\nWrite a macro that addresses: Macro call that should be transformed by DOLIST", "input": "(dolist (quote lol-gen::some-name))", "output": "(defmacro DOLIST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-language-macro 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DEFINE-LANGUAGE-MACRO", "input": "(define-language-macro 'lol-gen::some-name)", "output": "(defmacro DEFINE-LANGUAGE-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(wnotrc nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WNOTRC", "input": "(wnotrc nil\n :key\n nil)", "output": "(defmacro wnotrc ((&optional (min 1) (max 50) &rest banner) &body body )\n (declare (ignore min max banner))\n `(progn ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(group-by nil nil)\n\nWhat needs to change: Macro call that should be transformed by GROUP-BY", "input": "(group-by nil nil)", "output": "(defmacro group-by (&rest expressions)\n `(apply #'make-clause :group-by ',expressions))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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 ~>", "input": "(~> nil :key nil)", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(opf nil (progn))\n\nIssue: Macro call that should be transformed by OPF", "input": "(opf nil (progn))", "output": "(defmacro opf (place expr)\n \"Like `(callf PLACE (op EXPR))'.\nFrom GOO.\"\n `(callf (op ,expr) ,place))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(reversef 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by REVERSEF", "input": "(reversef 'lol-gen::some-name)", "output": "(defmacro REVERSEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n;; Manual gensym creation is boilerplate-heavy\n(defmacro with-temp (var &body body)\n (let ((g (gensym)))\n `(let ((,g ,var))\n ,@body)))\n;; Every macro needs this pattern - repetitive and error-prone\n\nWrite a macro that addresses: Repeated gensym boilerplate in macro definitions \u2014 want automatic gensym creation from naming convention", "input": ";; Manual gensym creation is boilerplate-heavy\n(defmacro with-temp (var &body body)\n (let ((g (gensym)))\n `(let ((,g ,var))\n ,@body)))\n;; Every macro needs this pattern - repetitive and error-prone", "output": "(defun g!-symbol-p (s)\n (and (symbolp s)\n (> (length (symbol-name s)) 2)\n (string= (symbol-name s)\n \"G!\"\n :start1 0\n :end1 2)))\n\n(defmacro defmacro/g! (name args &rest body)\n (let ((syms (remove-duplicates\n (remove-if-not #'g!-symbol-p\n (flatten body)))))\n (multiple-value-bind (body declarations docstring)\n (parse-body body :documentation t)\n `(defmacro ,name ,args\n ,@(when docstring\n (list docstring))\n ,@declarations\n (let ,(mapcar\n (lambda (s)\n `(,s (gensym ,(subseq\n (symbol-name s)\n 2))))\n syms)\n ,@body)))))", "category": "capture-management", "technique": "gensym,code-walking", "complexity": "advanced", "quality_score": 0.9874999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(jmatch nil)\n\nWhat needs to change: Macro call that should be transformed by JMATCH", "input": "(jmatch nil)", "output": "(defmacro jmatch (form &body clauses)\n \"Similar to Trivia match macro, match the FORM (JSON value) against CLAUSES.\nCLAUSES are (PATTERN . BODY) forms, where\n- PATTERN is a `jbind' destructuring pattern.\n- And BODY is an implicit progn.\n\nIf PATTERN matches successfully in `jbind', then BODY is executed with\nthe variables from the PATTERN bound to the respective values, as per\n`jbind'.\n\nThe last clause could start with T, OTHERWISE, ELSE, or _, and it will\nbe invoked if other patterns don't match. If there's no such clause,\n`jmatch' will simply return NIL on no matching patterns.\"\n (let ((form-sym (gensym \"MATCH-FORM\")))\n `(let ((,form-sym ,form))\n (cond\n ,@(loop for (pattern . body) in clauses\n when (and (symbolp pattern)\n (member (symbol-name pattern) '(\"T\" \"_\" \"OTHERWISE\" \"ELSE\")\n :test #'string=))\n collect `(t ,@body)\n else\n collect `((ignore-errors (jbind ,pattern ,form-sym t))\n (jbind ,pattern ,form-sym ,@body)))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(compile-$flavor-$methods)\n\nWrite a macro that addresses: Macro call that should be transformed by COMPILE-$FLAVOR-$METHODS", "input": "(compile-$flavor-$methods)", "output": "(defmacro COMPILE-$FLAVOR-$METHODS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(when-failing nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WHEN-FAILING", "input": "(when-failing nil\n (progn))", "output": "(defmacro WHEN-FAILING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(drelet* nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DRELET*", "input": "(drelet* nil\n :key\n nil)", "output": "(defmacro DRELET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(some-<>> nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by SOME-<>>", "input": "(some-<>> nil\n :key\n nil)", "output": "(defmacro some-<>> (init &body exps) (diamond-wand init exps t t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(group 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by GROUP", "input": "(group 'lol-gen::some-name)", "output": "(defmacro group ((name &optional description &rest format-args) &body tests)\n `(eval-in-context\n *context*\n (make-instance 'group-result\n :expression ',name\n :body (lambda () ,@tests)\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ematch common-lisp:nil)\n\nProblem: Macro call that should be transformed by EMATCH", "input": "(ematch common-lisp:nil)", "output": "(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))))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defmethod* nil\n (progn))\n\nProblem: Macro call that should be transformed by DEFMETHOD*", "input": "(defmethod* nil\n (progn))", "output": "(defmacro DEFMETHOD* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-thunk 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-THUNK", "input": "(with-thunk 'lol-gen::some-name)", "output": "(defmacro with-thunk ((spec &rest args) &body body)\n \"A macro-writing macro for the `call-with-' style.\n\nIn the `call-with-' style of writing macros, the macro is simply a\nsyntactic convenience that wraps its body in a thunk and a call to the\nfunction that does the actual work.\n\n (defmacro with-foo (&body body)\n `(call-with-foo (lambda () ,@body)))\n\nThe `call-with-' style has many advantages. Functions are easier to\nwrite than macros; you can change the behavior of a function without\nhaving to recompile all its callers; functions can be traced, appear\nin backtraces, etc.\n\nBut meanwhile, all those thunks are being allocated on the heap. Can\nwe avoid this? Yes, but at a high cost in boilerplate: the closure has\nto be given a name (using `flet') so it can be declared\n`dynamic-extent'.\n\n (defmacro with-foo (&body body)\n (with-gensyms (thunk)\n `(flet ((,thunk () ,@body))\n (declare (dynamic-extent #',thunk))\n (call-with-foo #',thunk))))\n\n`with-thunk' avoids the boilerplate:\n\n (defmacro with-foo (&body body)\n (with-thunk (body)\n `(call-with-foo ,body)))\n\nYou can give the thunk a name for easier debugging.\n\n (with-thunk ((body :name foo)) ...)\n\nIt is also possible to construct a \\\"thunk\\\" with arguments.\n\n (with-thunk (body foo)\n `(call-with-foo ,body))\n \u2261 `(flet ((,thunk (,foo)\n ,@body))\n (declare (dynamic-extent #',thunk))\n (call-with-foo #',thunk))\n\nSomeday this may have a better name.\"\n ;; TODO Derive default name from &environment. Cf. log4cl.\n (destructuring-bind (var &key name) (ensure-list spec)\n (declare (type (and symbol (not null)) var)\n (type symbol name))\n (let* ((stack-fn-prefix (string 'stack-fn-))\n (stack-fn-name\n (or (concatenate 'string\n stack-fn-prefix\n (string (or name var)))))\n (stack-fn\n (gensym stack-fn-name)))\n (with-gensyms (b gargs)\n `(let ((,b ,var)\n (,var ',stack-fn)\n (,gargs (list ,@args)))\n `(flet ((,',stack-fn ,,gargs\n ,@,b))\n (declare (dynamic-extent (function ,',stack-fn)))\n (symbol-macrolet ((,',stack-fn (function ,',stack-fn)))\n ,,@body)))))))", "category": "anaphoric", "technique": "symbol-macrolet,gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8699999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(delete-from-plistf nil)\n\nProblem: Macro call that should be transformed by DELETE-FROM-PLISTF", "input": "(delete-from-plistf nil)", "output": "(defmacro DELETE-FROM-PLISTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defmacro+ps nil\n nil)\n\nProblem: Macro call that should be transformed by DEFMACRO+PS", "input": "(defmacro+ps nil\n nil)", "output": "(defmacro DEFMACRO+PS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(sor nil)\n\nPattern to recognize: Macro call that should be transformed by SOR", "input": "(sor nil)", "output": "(defmacro sor (first &rest rest)\n \"Like OR, except binds the first argument to IT (via SYMBOL-MACROLET) for\nthe scope of the rest of the arguments. IT can be set with SETF.\"\n `(symbolic or ,first ,@rest))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(skip)\n\nProblem: Macro call that should be transformed by SKIP", "input": "(skip)", "output": "(defmacro skip (&rest reason)\n \"Generates a TEST-SKIPPED result.\"\n `(add-result 'test-skipped :reason (format nil ,@reason)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fbindrec nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by FBINDREC", "input": "(fbindrec nil\n (progn))", "output": "(defmacro fbindrec (bindings &body body &environment *lexenv*)\n \"Like `fbind', but creates recursive bindings.\n\nThe consequences of referring to one binding in the expression that\ngenerates another are undefined.\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbindrec `(locally ,@body)))\n (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))\n (body decls (parse-body body))\n (simple complex lambda unref\n (partition-fbinds (append bindings lambdas)\n body))\n (temps (mapcar (op (gensym (string (first _)))) complex))\n (simple-decls complex-decls lambda-decls others\n (partition-declarations-by-kind simple complex lambda decls)))\n `(let ,env\n ,@(unsplice (and env-decls `(declare ,@env-decls)))\n ;; Simple expressions reference functions already defined\n ;; outside of the letrec, so we can handle them with fbind.\n (comment \"fbind: Simple\")\n (fbind ,simple\n ,@simple-decls\n (comment \"fbind: Temps for complex bindings\")\n (let ,(loop for temp in temps collect `(,temp #'invalid))\n (declare ,@(loop for temp in temps collect `(function ,temp)))\n (flet ,(loop for (name nil) in complex\n for temp in temps\n collect (build-bind/ftype name temp complex-decls env))\n ,@complex-decls\n (comment \"fbind: Lambdas\")\n (labels (,@(loop for (name lambda) in lambda\n collect `(,name ,@(cdr lambda))))\n ,@lambda-decls\n (comment \"fbind: Unreferenced\")\n (progn ,@(mapcar #'second unref))\n (comment \"fbind: Complex\")\n (psetf ,@(loop for temp in temps\n for (nil expr) in complex\n append `(,temp (ensure-function ,expr))))\n (locally ,@others\n ,@body))))))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(f_n\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by F_N", "input": "(f_n\n nil\n nil)", "output": "(defmacro F_N ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(unwrap-as common-lisp:nil common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by UNWRAP-AS", "input": "(unwrap-as common-lisp:nil common-lisp:nil)", "output": "(defmacro unwrap-as (type cl:&optional (expr cl:nil expr-supplied-p))\n \"A syntactic convenience for type casting.\n\n (unwrap-as )\n\nis equivalent to\n\n (the (uwrap (tryInto )))\n\nand\n\n (unwrap-as )\n\nis equivalent to\n\n (fn (expr) (the (unwrap (tryInto expr)))).\n\nNote that this may copy the object or allocate memory.\"\n\n (cl:let ((try-into (cl:ignore-errors (cl:find-symbol \"TRYINTO\" \"COALTON/CLASSES\")))\n (unwrap (cl:ignore-errors (cl:find-symbol \"UNWRAP\" \"COALTON/CLASSES\"))))\n (cl:assert try-into () \"`try-as` macro does not have access to `try-into` yet.\")\n (cl:assert unwrap () \"`unwrap` macro does not have access to `unwrap` yet.\")\n (cl:if expr-supplied-p\n `(the ,type (,unwrap (,try-into ,expr)))\n (alexandria:with-gensyms (lexpr)\n `(fn (,lexpr)\n (the ,type (,unwrap (,try-into ,lexpr))))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Generate a defmacro form that transforms code like this:\n(the-part nil (progn))\n\nPattern to recognize: Macro call that should be transformed by THE-PART", "input": "(the-part nil (progn))", "output": "(defmacro THE-PART ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(optimize common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by OPTIMIZE", "input": "(optimize common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro OPTIMIZE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(compile-$flavor-$methods nil nil)\n\nPattern to recognize: Macro call that should be transformed by COMPILE-$FLAVOR-$METHODS", "input": "(compile-$flavor-$methods nil nil)", "output": "(defmacro COMPILE-$FLAVOR-$METHODS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(use-foreign-library 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by USE-FOREIGN-LIBRARY", "input": "(use-foreign-library 'lol-gen::some-name)", "output": "(defmacro use-foreign-library (name)\n `(load-foreign-library ',name))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(counting 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COUNTING", "input": "(counting 'lol-gen::some-name)", "output": "(defmacro COUNTING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(unless-match common-lisp:nil\n :key\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by UNLESS-MATCH", "input": "(unless-match common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro unless-match (pattern arg &body body)\n \"Equivalent to (match ARG (PATTERN) (_ BODY...)).\"\n `(match ,arg\n (,pattern)\n (_ ,.body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(order-by nil (progn))\n\nProblem: Macro call that should be transformed by ORDER-BY", "input": "(order-by nil (progn))", "output": "(defmacro ORDER-BY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda () (progn))\n\nWhat needs to change: Macro call that should be transformed by LAMBDA", "input": "(lambda () (progn))", "output": "(defmacro LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is nil nil)\n\nProblem: Macro call that should be transformed by IS", "input": "(is nil nil)", "output": "(defmacro is (test &rest reason-args)\n \"The DWIM checking operator.\n\nIf TEST returns a true value a test-passed result is generated,\notherwise a test-failure result is generated. The reason, unless\nREASON-ARGS is provided, is generated based on the form of TEST:\n\n (predicate expected actual) - Means that we want to check\n whether, according to PREDICATE, the ACTUAL value is\n in fact what we EXPECTED.\n\n (predicate value) - Means that we want to ensure that VALUE\n satisfies PREDICATE.\n\n Wrapping the TEST form in a NOT simply produces a negated reason\n string.\"\n (assert (listp test)\n (test)\n \"Argument to IS must be a list, not ~S\" test)\n (let (bindings effective-test default-reason-args)\n (with-gensyms (e a v)\n (flet ((process-entry (predicate expected actual &optional negatedp)\n ;; make sure EXPECTED is holding the entry that starts with 'values\n (when (and (consp actual)\n (eq (car actual) 'values))\n (assert (not (and (consp expected)\n (eq (car expected) 'values))) ()\n \"Both the expected and actual part is a values expression.\")\n (rotatef expected actual))\n (let ((setf-forms))\n (if (and (consp expected)\n (eq (car expected) 'values))\n (progn\n (setf expected (copy-list expected))\n (setf setf-forms (loop for cell = (rest expected) then (cdr cell)\n for i from 0\n while cell\n when (eq (car cell) '*)\n collect `(setf (elt ,a ,i) nil)\n and do (setf (car cell) nil)))\n (setf bindings (list (list e `(list ,@(rest expected)))\n (list a `(multiple-value-list ,actual)))))\n (setf bindings (list (list e expected)\n (list a actual))))\n (setf effective-test `(progn\n ,@setf-forms\n ,(if negatedp\n `(not (,predicate ,e ,a))\n `(,predicate ,e ,a)))))))\n (list-match-case test\n ((not (?predicate ?expected ?actual))\n (process-entry ?predicate ?expected ?actual t)\n (setf default-reason-args\n (list \"~2&~S~2% evaluated to ~2&~S~2% which is ~2&~S~2%to ~2&~S~2% (it should not be)\"\n `',?actual a `',?predicate e)))\n ((not (?satisfies ?value))\n (setf bindings (list (list v ?value))\n effective-test `(not (,?satisfies ,v))\n default-reason-args\n (list \"~2&~S~2% evaluated to ~2&~S~2% which satisfies ~2&~S~2% (it should not)\"\n `',?value v `',?satisfies)))\n ((?predicate ?expected ?actual)\n (process-entry ?predicate ?expected ?actual)\n (setf default-reason-args\n (list \"~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%\"\n `',?actual a `',?predicate e)))\n ((?satisfies ?value)\n (setf bindings (list (list v ?value))\n effective-test `(,?satisfies ,v)\n default-reason-args\n (list \"~2&~S~2% evaluated to ~2&~S~2% which does not satisfy ~2&~S~2%\"\n `',?value v `',?satisfies)))\n (?_\n (setf bindings '()\n effective-test test\n default-reason-args (list \"~2&~S~2% was NIL.\" `',test)))))\n `(let ,bindings\n (if ,effective-test\n (add-result 'test-passed :test-expr ',test)\n (process-failure ',test\n ,@(or reason-args default-reason-args)))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(dynamic-reprogv nil\n (progn))\n\nProblem: Macro call that should be transformed by DYNAMIC-REPROGV", "input": "(dynamic-reprogv nil\n (progn))", "output": "(defmacro DYNAMIC-REPROGV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cond-> 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by COND->", "input": "(cond-> 'lol-gen::some-name)", "output": "(defmacro cond-> (init &body exps) (cond-arrow-macro init exps))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defun nil ())\n\nWhat needs to change: Macro call that should be transformed by DEFUN", "input": "(defun nil ())", "output": "(defmacro DEFUN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ensure-transaction\n nil\n nil)\n\nProblem: Macro call that should be transformed by ENSURE-TRANSACTION", "input": "(ensure-transaction\n nil\n nil)", "output": "(defmacro ensure-transaction (&body body)\n \"Ensures that body is executed within a transaction, but does not begin a new\ntransaction if one is already in progress.\"\n `(call-with-ensured-transaction (lambda () ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(finding nil nil)\n\nWhat needs to change: Macro call that should be transformed by FINDING", "input": "(finding nil nil)", "output": "(defmacro FINDING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-builder 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-BUILDER", "input": "(with-builder 'lol-gen::some-name)", "output": "(defmacro WITH-BUILDER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-context-variables 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-CONTEXT-VARIABLES", "input": "(with-context-variables 'lol-gen::some-name)", "output": "(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))", "category": "dispatch", "technique": "symbol-macrolet", "complexity": "basic", "quality_score": 0.8825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(rotatef 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ROTATEF", "input": "(rotatef 'lol-gen::some-name)", "output": "(defmacro ROTATEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda-ematch1 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-EMATCH1", "input": "(lambda-ematch1 'lol-gen::some-name)", "output": "(defmacro lambda-ematch1 (pattern &body body)\n \"Equivalent to (lambda (arg) (ematch arg (PATTERN BODY...))).\"\n `(lambda-ematch (,pattern ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(defiter nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFITER", "input": "(defiter nil\n :key\n nil)", "output": "(defmacro DEFITER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(destructuring-case 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DESTRUCTURING-CASE", "input": "(destructuring-case 'lol-gen::some-name)", "output": "(defmacro destructuring-case (keyform &body clauses)\n \"DESTRUCTURING-CASE, -CCASE, and -ECASE are a combination of CASE and DESTRUCTURING-BIND.\nKEYFORM must evaluate to a CONS.\n\nClauses are of the form:\n\n ((CASE-KEYS . DESTRUCTURING-LAMBDA-LIST) FORM*)\n\nThe clause whose CASE-KEYS matches CAR of KEY, as if by CASE, CCASE, or ECASE,\nis selected, and FORMs are then executed with CDR of KEY is destructured and\nbound by the DESTRUCTURING-LAMBDA-LIST.\n\nExample:\n\n (defun dcase (x)\n (destructuring-case x\n ((:foo a b)\n (format nil \\\"foo: ~S, ~S\\\" a b))\n ((:bar &key a b)\n (format nil \\\"bar: ~S, ~S\\\" a b))\n (((:alt1 :alt2) a)\n (format nil \\\"alt: ~S\\\" a))\n ((t &rest rest)\n (format nil \\\"unknown: ~S\\\" rest))))\n\n (dcase (list :foo 1 2)) ; => \\\"foo: 1, 2\\\"\n (dcase (list :bar :a 1 :b 2)) ; => \\\"bar: 1, 2\\\"\n (dcase (list :alt1 1)) ; => \\\"alt: 1\\\"\n (dcase (list :alt2 2)) ; => \\\"alt: 2\\\"\n (dcase (list :quux 1 2 3)) ; => \\\"unknown: 1, 2, 3\\\"\n\n (defun decase (x)\n (destructuring-case x\n ((:foo a b)\n (format nil \\\"foo: ~S, ~S\\\" a b))\n ((:bar &key a b)\n (format nil \\\"bar: ~S, ~S\\\" a b))\n (((:alt1 :alt2) a)\n (format nil \\\"alt: ~S\\\" a))))\n\n (decase (list :foo 1 2)) ; => \\\"foo: 1, 2\\\"\n (decase (list :bar :a 1 :b 2)) ; => \\\"bar: 1, 2\\\"\n (decase (list :alt1 1)) ; => \\\"alt: 1\\\"\n (decase (list :alt2 2)) ; => \\\"alt: 2\\\"\n (decase (list :quux 1 2 3)) ; =| error\n\"\n (expand-destructuring-case keyform clauses 'case))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(skip nil (progn))\n\nIssue: Macro call that should be transformed by SKIP", "input": "(skip nil (progn))", "output": "(defmacro skip (&rest reason)\n \"Generates a TEST-SKIPPED result.\"\n `(add-result 'test-skipped :reason (format nil ,@reason)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-simple-documentation-lookup nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-SIMPLE-DOCUMENTATION-LOOKUP", "input": "(define-simple-documentation-lookup nil nil)", "output": "(defmacro define-simple-documentation-lookup (class documentation-type)\n `(defmethod documentation ((,class ,class))\n ,(if (eql documentation-type T)\n `(cl:documentation (object ,class) 'T)\n `(cl:documentation (designator ,class) ',documentation-type))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(set= nil)\n\nProblem: Macro call that should be transformed by SET=", "input": "(set= nil)", "output": "(defmacro set= (&rest args)\n `(make-clause :set= ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(make-kid nil (progn))\n\nPattern to recognize: Macro call that should be transformed by MAKE-KID", "input": "(make-kid nil (progn))", "output": "(defmacro make-kid (class &rest ia)\n (with-gensyms (c)\n `(let ((,c ,class))\n (make-instance ,c\n ,@ia\n :fm-parent (progn (assert self () \"make-kid: self nil making ~a\" ,c)\n self)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(restart-bind nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by RESTART-BIND", "input": "(restart-bind nil\n nil)", "output": "(defmacro RESTART-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(match2* common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by MATCH2*", "input": "(match2* common-lisp:nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defclause nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFCLAUSE", "input": "(defclause nil\n (progn))", "output": "(defmacro defclause (name arglist &body body)\n \"Same as cl:defmacro, but additionally records in *clauses* as a known clause macro.\"\n `(progn\n (defmacro ,name ,arglist ,@body)\n (pushnew ',name *clauses*)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(eko-if nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EKO-IF", "input": "(eko-if nil nil)", "output": "(defmacro eko-if ((&rest trcargs) &rest body)\n (let ((result (gensym)))\n `(let ((,result ,@body))\n (when ,result\n (trc ,(car trcargs) :res ,result ,@(cdr trcargs)))\n ,result)))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dreletf nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DRELETF", "input": "(dreletf nil\n nil)", "output": "(defmacro DRELETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-accessors nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-ACCESSORS", "input": "(with-accessors nil\n (progn))", "output": "(defmacro WITH-ACCESSORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(iterate\n nil\n (progn))\n\nIssue: Macro call that should be transformed by ITERATE", "input": "(iterate\n nil\n (progn))", "output": "(defmacro iterate (&body body)\n \"Jonathan Amsterdam's powerful iteration facility\"\n `(iter .,body))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(disable-curly-syntax)\n\nIssue: Macro call that should be transformed by DISABLE-CURLY-SYNTAX", "input": "(disable-curly-syntax)", "output": "(defmacro DISABLE-CURLY-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda (quote lol-gen::some-name))\n\nPattern to recognize: Macro call that should be transformed by LAMBDA", "input": "(lambda (quote lol-gen::some-name))", "output": "(defmacro LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(all nil :key nil)\n\nIssue: Macro call that should be transformed by ALL", "input": "(all nil :key nil)", "output": "(defmacro all (parser &rest parsers)\n \"Combination of parsers yielding all results as a list.\"\n `(<*> ,parser ,@parsers))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(unless nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by UNLESS", "input": "(unless nil (progn))", "output": "(defmacro UNLESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-fixtures nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-FIXTURES", "input": "(with-fixtures nil\n (progn))", "output": "(defmacro with-fixtures (fixtures &body body)\n `(call-with-fixtures (lambda () ,@body) ,fixtures))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda-match\n nil)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-MATCH", "input": "(lambda-match\n nil)", "output": "(defmacro LAMBDA-MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c_1\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by C_1", "input": "(c_1\n nil\n nil)", "output": "(defmacro c_1 (&body body)\n `(make-c-dependent\n :code '(without-c-dependency ,@body)\n :inputp nil\n :lazy t\n :value-state :unevaluated\n :rule (c-lambda (without-c-dependency ,@body))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(let-match common-lisp:nil\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LET-MATCH", "input": "(let-match common-lisp:nil\n common-lisp:nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(sor nil (progn))\n\nPattern to recognize: Macro call that should be transformed by SOR", "input": "(sor nil (progn))", "output": "(defmacro sor (first &rest rest)\n \"Like OR, except binds the first argument to IT (via SYMBOL-MACROLET) for\nthe scope of the rest of the arguments. IT can be set with SETF.\"\n `(symbolic or ,first ,@rest))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(aand 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by AAND", "input": "(aand 'lol-gen::some-name)", "output": "(defmacro AAND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c-in-lazy\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by C-IN-LAZY", "input": "(c-in-lazy\n nil\n :key\n nil)", "output": "(defmacro c-in-lazy (&body body)\n `(c-input (:lazy :once-asked) (progn ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defobject nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFOBJECT", "input": "(defobject nil (progn))", "output": "(defmacro DEFOBJECT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-yield\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-YIELD", "input": "(with-yield\n nil\n :key\n nil)", "output": "(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)))))))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(on-conflict-do-update nil nil)\n\nWhat needs to change: Macro call that should be transformed by ON-CONFLICT-DO-UPDATE", "input": "(on-conflict-do-update nil nil)", "output": "(defmacro on-conflict-do-update (conflict-target update-set &optional where-condition)\n `(make-clause :on-conflict-do-update\n ,conflict-target\n ,update-set\n ,where-condition))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-last 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COLLECT-LAST", "input": "(collect-last 'lol-gen::some-name)", "output": "(defmacro COLLECT-LAST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(atypecase nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by ATYPECASE", "input": "(atypecase nil\n (progn))", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(f_\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by F_", "input": "(f_\n nil\n :key\n nil)", "output": "(defmacro F_ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c?+n\n nil\n nil)\n\nProblem: Macro call that should be transformed by C?+N", "input": "(c?+n\n nil\n nil)", "output": "(defmacro c?+n (&body body)\n `(make-c-dependent\n :inputp t\n :code ',body\n :value-state :unevaluated\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fm-other?! nil nil)\n\nProblem: Macro call that should be transformed by FM-OTHER?!", "input": "(fm-other?! nil nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dynamic-reprogv nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DYNAMIC-REPROGV", "input": "(dynamic-reprogv nil\n :key\n nil)", "output": "(defmacro DYNAMIC-REPROGV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(max-of nil\n nil)\n\nProblem: Macro call that should be transformed by MAX-OF", "input": "(max-of nil\n nil)", "output": "(defmacro MAX-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(<*> nil nil)\n\nPattern to recognize: Macro call that should be transformed by <*>", "input": "(<*> nil nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c-formula nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by C-FORMULA", "input": "(c-formula nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-foreign-pointer 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-FOREIGN-POINTER", "input": "(with-foreign-pointer 'lol-gen::some-name)", "output": "(defmacro with-foreign-pointer ((var size &optional size-var) &body body)\n \"Bind 'var to 'size bytes of foreign memory during 'body. The\n pointer in 'var is invalid beyond the dynamic extent of 'body, and\n may be stack-allocated if supported by the implementation. If\n 'size-var is supplied, it will be bound to 'size during 'body.\"\n (unless size-var\n (setf size-var (gensym (symbol-name '#:size))))\n ;; If the size is constant we can stack-allocate.\n (cond ((constantp size)\n (let ((alien-var (gensym (symbol-name '#:alien))))\n `(with-alien ((,alien-var (array (unsigned 8) ,(eval size))))\n (let ((,size-var ,size)\n (,var (alien-sap ,alien-var)))\n (declare (ignorable ,size-var))\n ,@body))))\n (t\n `(let ((,size-var ,size))\n (alien:with-bytes (,var ,size-var)\n ,@body)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(f-zerop nil)\n\nWrite a macro that addresses: Macro call that should be transformed by F-ZEROP", "input": "(f-zerop nil)", "output": "(defmacro f-zerop (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 (zerop new-basis))\n (progn\n (setf prior-fire-value (zerop new-basis))\n :propagate)\n :no-propagate)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(acase nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ACASE", "input": "(acase nil)", "output": "(defmacro acase (keyform &body cases)\n \"Like CASE, except binds the result of the keyform to IT (via LET) for the\nscope of the cases.\"\n `(anaphoric case ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-mapping-appender 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-MAPPING-APPENDER", "input": "(with-mapping-appender 'lol-gen::some-name)", "output": "(defmacro WITH-MAPPING-APPENDER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "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", "input": "(xor)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(f-zerop nil (progn))\n\nProblem: Macro call that should be transformed by F-ZEROP", "input": "(f-zerop nil (progn))", "output": "(defmacro f-zerop (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 (zerop new-basis))\n (progn\n (setf prior-fire-value (zerop new-basis))\n :propagate)\n :no-propagate)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(nconcf nil (progn))\n\nWhat needs to change: Macro call that should be transformed by NCONCF", "input": "(nconcf nil (progn))", "output": "(defmacro NCONCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(case-using nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by CASE-USING", "input": "(case-using nil\n (progn))", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defunion nil)\n\nIssue: Macro call that should be transformed by DEFUNION", "input": "(defunion nil)", "output": "(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)))))", "category": "anaphoric", "technique": "symbol-macrolet,anaphor", "complexity": "advanced", "quality_score": 0.8925} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(f nil\n nil)\n\nIssue: Macro call that should be transformed by F", "input": "(f nil\n nil)", "output": "(defmacro F ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(restart-bind nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by RESTART-BIND", "input": "(restart-bind nil\n :key\n nil)", "output": "(defmacro RESTART-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-sum nil (progn))\n\nWhat needs to change: Macro call that should be transformed by COLLECT-SUM", "input": "(collect-sum nil (progn))", "output": "(defmacro COLLECT-SUM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fn nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by FN", "input": "(fn nil\n (progn))", "output": "(defmacro FN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-unique-names nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-UNIQUE-NAMES", "input": "(with-unique-names nil\n (progn))", "output": "(defmacro WITH-UNIQUE-NAMES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-test+run-interactively nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-TEST+RUN-INTERACTIVELY", "input": "(define-test+run-interactively nil\n (progn))", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(f nil\n (progn))\n\nIssue: Macro call that should be transformed by F", "input": "(f nil\n (progn))", "output": "(defmacro F ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(specializing nil\n nil)\n\nProblem: Macro call that should be transformed by SPECIALIZING", "input": "(specializing nil\n nil)", "output": "(defmacro SPECIALIZING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(ok 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by OK", "input": "(ok 'lol-gen::some-name)", "output": "(defmacro ok (test &optional desc)\n (with-gensyms (duration result)\n (once-only (test desc)\n `(with-catching-errors (:expected T :description ,desc)\n (with-duration ((,duration ,result) ,test)\n (test ,result t ,desc\n :duration ,duration\n :test-fn (lambda (x y)\n (eq (not (null x)) y))\n :got-form ,test))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(cmatch common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by CMATCH", "input": "(cmatch common-lisp:nil)", "output": "(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))))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-constant nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-CONSTANT", "input": "(define-constant nil nil)", "output": "(defmacro define-constant (name initial-value &key (test ''eql) documentation)\n \"Ensures that the global variable named by NAME is a constant with a value\nthat is equal under TEST to the result of evaluating INITIAL-VALUE. TEST is a\n/function designator/ that defaults to EQL. If DOCUMENTATION is given, it\nbecomes the documentation string of the constant.\n\nSignals an error if NAME is already a bound non-constant variable.\n\nSignals an error if NAME is already a constant variable whose value is not\nequal under TEST to result of evaluating INITIAL-VALUE.\"\n `(defconstant ,name (%reevaluate-constant ',name ,initial-value ,test)\n ,@(when documentation `(,documentation))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nor 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by NOR", "input": "(nor 'lol-gen::some-name)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-constant nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-CONSTANT", "input": "(define-constant nil (progn))", "output": "(defmacro define-constant (name initial-value &key (test ''eql) documentation)\n \"Ensures that the global variable named by NAME is a constant with a value\nthat is equal under TEST to the result of evaluating INITIAL-VALUE. TEST is a\n/function designator/ that defaults to EQL. If DOCUMENTATION is given, it\nbecomes the documentation string of the constant.\n\nSignals an error if NAME is already a bound non-constant variable.\n\nSignals an error if NAME is already a constant variable whose value is not\nequal under TEST to result of evaluating INITIAL-VALUE.\"\n `(defconstant ,name (%reevaluate-constant ',name ,initial-value ,test)\n ,@(when documentation `(,documentation))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(inner-join 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by INNER-JOIN", "input": "(inner-join 'lol-gen::some-name)", "output": "(defmacro inner-join (table &key on using)\n `(join ,table :kind :inner :on ,on :using ,using))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defobject-amendment nil)\n\nIssue: Macro call that should be transformed by DEFOBJECT-AMENDMENT", "input": "(defobject-amendment nil)", "output": "(defmacro DEFOBJECT-AMENDMENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(keep-bops nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by KEEP-BOPS", "input": "(keep-bops nil :key nil)", "output": "(defmacro KEEP-BOPS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-yield\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-YIELD", "input": "(with-yield\n nil\n nil)", "output": "(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)))))))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(letrec* nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by LETREC*", "input": "(letrec* nil\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(if-not-let nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by IF-NOT-LET", "input": "(if-not-let nil\n :key\n nil)", "output": "(defmacro if-not-let (bindings &body (then-form &optional else-form))\n \"Creates new variable bindings, and conditionally executes either\nTHEN-FORM or ELSE-FORM. ELSE-FORM defaults to NIL.\nBINDINGS must be either single binding of the form:\n (variable initial-form)\nor a list of bindings of the form:\n ((variable-1 initial-form-1)\n (variable-2 initial-form-2)\n ...\n (variable-n initial-form-n))\nAll initial-forms are executed sequentially in the specified order. Then all\nthe variables are bound to the corresponding values.\nIf one of the variables was bound to NIL, the THEN-FORM is executed with the\nbindings in effect, otherwise the ELSE-FORM is executed with the bindings in\neffect.\nAdapted from Alexandria if-let.\"\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 (if-not (and ,@variables)\n\t ,then-form\n\t ,else-form))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make nil nil)\n\nWhat needs to change: Macro call that should be transformed by MAKE", "input": "(make nil nil)", "output": "(defmacro MAKE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c-envalue\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by C-ENVALUE", "input": "(c-envalue\n nil\n :key\n nil)", "output": "(defmacro c-envalue (&body body)\n `(make-c-envaluer\n :envalue-rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(defdata nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFDATA", "input": "(defdata nil\n (progn))", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defparam nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEFPARAM", "input": "(defparam nil nil)", "output": "(defmacro DEFPARAM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(either\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by EITHER", "input": "(either\n nil\n :key\n nil)", "output": "(defmacro EITHER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(labels* nil\n (progn))\n\nProblem: Macro call that should be transformed by LABELS*", "input": "(labels* nil\n (progn))", "output": "(defmacro LABELS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by LAMBDA*", "input": "(lambda* nil\n (progn))", "output": "(defmacro LAMBDA* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fnn nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FNN", "input": "(fnn nil nil)", "output": "(defmacro FNN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(and nil :key nil)\n\nProblem: Macro call that should be transformed by AND", "input": "(and nil :key nil)", "output": "(defmacro AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(declaration common-lisp:nil)\n\nProblem: Macro call that should be transformed by DECLARATION", "input": "(declaration common-lisp:nil)", "output": "(defmacro DECLARATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(export-always nil (progn))", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(as-> nil :key nil)\n\nProblem: Macro call that should be transformed by AS->", "input": "(as-> nil :key nil)", "output": "(defmacro AS-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(appendf nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by APPENDF", "input": "(appendf nil :key nil)", "output": "(defmacro APPENDF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-decoder-simple-list-semantics\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-DECODER-SIMPLE-LIST-SEMANTICS", "input": "(with-decoder-simple-list-semantics\n nil\n nil)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "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", "input": "(bind nil\n (progn))", "output": "(defmacro bind ((&rest bindings) &body body)\n \"Bind is a replacement for let*, destructuring-bind, multiple-value-bind and more. \n\nAn example is probably the best way to describe its syntax:\n\n \\(bind \\(\\(a 2\\)\n \\(\\(b &rest args &key \\(c 2\\) &allow-other-keys\\) '\\(:a :c 5 :d 10 :e 54\\)\\)\n \\(\\(:values d e\\) \\(truncate 4.5\\)\\)\n \\(\\(:structure xxx- slot1 slot2\\) \\(make-xxx\\)\\)\n \\(\\(:flet name \\(arg1 arg2\\)\\) \\(+ arg1 arg2\\)\\)\\)\n \\(list a b c d e args\\)\\)\n\nSimple bindings are as in let*. Destructuring is done if the first item\nin a binding is a list. Multiple value binding is done if the first item\nin a binding is a list and the first item in the list is ':values'. Other\nforms have their own syntax. For example, :structure first has the conc\nname and then slot names whereas :flet has the function name and a list\nof arguments and then the function body (in an implicit progn).\"\n (let (declarations)\n (loop while (and (consp (car body)) (eq (caar body) 'declare)) do\n (push (first body) declarations)\n (setf body (rest body)))\n (if bindings\n\t(let ((*all-declarations* (bind-expand-declarations (nreverse declarations))))\n\t (prog1\n\t (bind-macro-helper bindings body)\n\t (check-for-unused-variable-declarations *all-declarations*)))\n `(locally\n ,@declarations\n ,@body))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ematch 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by EMATCH", "input": "(ematch 'lol-gen::some-name)", "output": "(defmacro ematch (arg &body clauses)\n \"Same as MATCH, except MATCH-ERROR will be raised if not matched.\"\n (once-only (arg)\n (let ((else `(error 'match-error\n :values (list ,arg)\n :patterns ',(mapcar (lambda (c) (list (car c))) clauses))))\n (compile-match-1 arg clauses else))))", "category": "control-flow", "technique": "once-only", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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 ->*", "input": "(->* nil)", "output": "(defmacro ->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collecting-into-and-returning nil)\n\nIssue: Macro call that should be transformed by COLLECTING-INTO-AND-RETURNING", "input": "(collecting-into-and-returning nil)", "output": "(defmacro COLLECTING-INTO-AND-RETURNING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n($send nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by $SEND", "input": "($send nil (progn))", "output": "(defmacro $SEND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fm! nil nil)\n\nWhat needs to change: Macro call that should be transformed by FM!", "input": "(fm! nil nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda-match*\n common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-MATCH*", "input": "(lambda-match*\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-special-initargs nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-SPECIAL-INITARGS", "input": "(with-special-initargs nil\n (progn))", "output": "(defmacro WITH-SPECIAL-INITARGS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n;; Manual gensym binding is verbose\n(let ((g1 (gensym))\n (g2 (gensym))\n (g3 (gensym)))\n `(let ((,g1 ,x)\n (,g2 ,y))\n (f ,g1 ,g2 ,g3)))\n;; The let-bindings for gensyms obscure the macro logic\n\nIssue: Manual gensym creation with let-bindings is verbose \u2014 want concise declaration of gensym-intended symbols", "input": ";; Manual gensym binding is verbose\n(let ((g1 (gensym))\n (g2 (gensym))\n (g3 (gensym)))\n `(let ((,g1 ,x)\n (,g2 ,y))\n (f ,g1 ,g2 ,g3)))\n;; The let-bindings for gensyms obscure the macro logic", "output": "(defmacro with-gensyms (syms &body body)\n `(let ,(mapcar #'(lambda (s)\n `(,s (gensym)))\n syms)\n ,@body))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.95} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(pecase nil :key nil)\n\nProblem: Macro call that should be transformed by PECASE", "input": "(pecase nil :key nil)", "output": "(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))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(deftest nil)\n\nWhat needs to change: Macro call that should be transformed by DEFTEST", "input": "(deftest nil)", "output": "(defmacro deftest (name &body test-forms)\n (let ((tests (gensym \"TESTS\"))\n (test (gensym \"TEST\"))\n (test-fn (gensym \"TEST-FN\")))\n `(progn\n (unless (nth-value 1 (gethash *package* *package-tests*))\n (setf (gethash *package* *package-tests*) '()))\n (let* ((,tests (gethash *package* *package-tests*))\n (,test (assoc ',name ,tests :test #'string=))\n (,test-fn (lambda ()\n (subtest (princ-to-string ',name)\n ,@test-forms))))\n (if ,test\n (rplacd ,test ,test-fn)\n (push (cons ',name ,test-fn) (gethash *package* *package-tests*)))\n ',name))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ctypecase 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by CTYPECASE", "input": "(ctypecase 'lol-gen::some-name)", "output": "(defmacro CTYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(multiple-value-prog2 nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by MULTIPLE-VALUE-PROG2", "input": "(multiple-value-prog2 nil\n :key\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-decoder-simple-clos-semantics\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-DECODER-SIMPLE-CLOS-SEMANTICS", "input": "(with-decoder-simple-clos-semantics\n nil\n :key\n nil)", "output": "(defmacro with-decoder-simple-clos-semantics (&body body)\n \"Execute BODY in a dynamic environement where the decoder semantics\nis such as set by SET-DECODER-SIMPLE-CLOS-SEMANTICS.\"\n `(with-shadowed-custom-vars\n (set-decoder-simple-clos-semantics)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(string-case nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by STRING-CASE", "input": "(string-case nil\n (progn))", "output": "(defmacro STRING-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fsetf nil :key nil)\n\nIssue: Macro call that should be transformed by FSETF", "input": "(fsetf nil :key nil)", "output": "(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)))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(splice-seqf nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SPLICE-SEQF", "input": "(splice-seqf nil)", "output": "(defmacro SPLICE-SEQF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(as~> nil (progn))\n\nIssue: Macro call that should be transformed by AS~>", "input": "(as~> nil (progn))", "output": "(defmacro as~> (expr name &rest exprs)\n \"Like `~>' or `~>', but instead of threading by position, threading is\ndone based on NAME.\"\n `(let* ,(loop for expr in (cons expr exprs)\n collect (list name expr))\n ,name))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(trace)\n\nWhat needs to change: Macro call that should be transformed by TRACE", "input": "(trace)", "output": "(defmacro TRACE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fail nil)\n\nProblem: Macro call that should be transformed by FAIL", "input": "(fail nil)", "output": "(defmacro fail (&rest message-args)\n \"Simply generate a FAIL.\"\n `(process-failure ',message-args\n ,@message-args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(json-bind nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by JSON-BIND", "input": "(json-bind nil\n :key\n nil)", "output": "(defmacro json-bind ((&rest vars) json-source &body body)\n (let-gensyms (decoder validator value-handler key-handler pass)\n (let ((vars-tmp (loop repeat (length vars) collect (gensym))))\n `(let (,@vars-tmp (,pass (constantly t)))\n (let ((,validator\n (custom-decoder\n :beginning-of-object ,pass :object-key ,pass\n :object-value ,pass :end-of-object ,pass\n :beginning-of-array ,pass :array-member ,pass\n :end-of-array ,pass :beginning-of-string ,pass\n :string-char ,pass :end-of-string ,pass\n :internal-decoder 'decode-json))\n (,decoder (current-decoder))\n (,key-handler *object-key-handler*)\n (,value-handler *object-value-handler*))\n (declare (ignorable ,decoder ,key-handler ,value-handler))\n ,(if (null vars)\n `(decode-json-from-source ,json-source ,validator)\n `(bind-custom-vars\n (,@(json-bind-level-customizations\n (loop for var in vars for var-tmp in vars-tmp\n collect (cons var-tmp (symbol-name var)))\n nil decoder validator\n key-handler value-handler pass)\n :aggregate-scope\n (union *aggregate-scope-variables*\n '(*object-key-handler*\n *object-value-handler*\n *internal-decoder*)))\n (decode-json-from-source ,json-source))))\n (let ,(mapcar #'list vars vars-tmp)\n ,@body)))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(maxf 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by MAXF", "input": "(maxf 'lol-gen::some-name)", "output": "(defmacro MAXF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(accase 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ACCASE", "input": "(accase 'lol-gen::some-name)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(named-lambda nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by NAMED-LAMBDA", "input": "(named-lambda nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-foreign-objects 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WITH-FOREIGN-OBJECTS", "input": "(with-foreign-objects 'lol-gen::some-name)", "output": "(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)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-screamer-package nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-SCREAMER-PACKAGE", "input": "(define-screamer-package nil\n :key\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(matrix-etypecase nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MATRIX-ETYPECASE", "input": "(matrix-etypecase nil)", "output": "(defmacro MATRIX-ETYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-proxynodes nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-PROXYNODES", "input": "(with-proxynodes nil\n :key\n nil)", "output": "(defmacro with-proxynodes (proxy-nodes &body body)\n \"define proxy nodes for local usage\"\n (if (not (listp proxy-nodes))\n (setf proxy-nodes (list proxy-nodes)))\n (if proxy-nodes\n (let ((tmp (gensym (format nil \"~:@(proxy-~a-~)\" (first proxy-nodes)))))\n\t;(format t \"Symbol:: ~s\" tmp)\n\t(setf (gethash (first proxy-nodes) *proxy-node*) tmp)\n\t;;for debug/swank, else comment out\n\t;;(eval `(defnode ,tmp (proxy) ()))\n\t;;\n\t`(let ((,(first proxy-nodes) ',tmp))\n\n\t ;(defnode ,tmp (proxy) ())\n\t (defproxy ,tmp)\n\t \n\t (with-proxynodes ,(rest proxy-nodes) ,@body)))\n `(progn ,@body)))", "category": "dsl", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(compile-$flavor-$methods 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by COMPILE-$FLAVOR-$METHODS", "input": "(compile-$flavor-$methods 'lol-gen::some-name)", "output": "(defmacro COMPILE-$FLAVOR-$METHODS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(and nil nil)\n\nPattern to recognize: Macro call that should be transformed by AND", "input": "(and nil nil)", "output": "(defmacro AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(incf-pointer 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by INCF-POINTER", "input": "(incf-pointer 'lol-gen::some-name)", "output": "(defmacro INCF-POINTER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(awhen 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by AWHEN", "input": "(awhen 'lol-gen::some-name)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(secase nil)\n\nIssue: Macro call that should be transformed by SECASE", "input": "(secase nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c?n-until nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by C?N-UNTIL", "input": "(c?n-until nil\n nil)", "output": "(defmacro c?n-until (args &body body)\n `(make-c-dependent\n :optimize :when-value-t\n :code ',body\n :inputp t\n :value-state :unevaluated\n :rule (c-lambda ,@body)\n ,@args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(etypecase-of nil\n (progn))\n\nIssue: Macro call that should be transformed by ETYPECASE-OF", "input": "(etypecase-of nil\n (progn))", "output": "(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)))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(some-<>> nil (progn))\n\nIssue: Macro call that should be transformed by SOME-<>>", "input": "(some-<>> nil (progn))", "output": "(defmacro SOME-<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-inactive-layers nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-INACTIVE-LAYERS", "input": "(with-inactive-layers nil)", "output": "(defmacro WITH-INACTIVE-LAYERS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(psetq)\n\nIssue: Macro call that should be transformed by PSETQ", "input": "(psetq)", "output": "(defmacro PSETQ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(some->\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SOME->", "input": "(some->\n nil\n nil)", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(eval-when-execute\n common-lisp:nil)", "output": "(defmacro EVAL-WHEN-EXECUTE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "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", "input": "(defgeneric nil :key nil)", "output": "(defmacro defgeneric (name (&rest lambda-list) &rest options)\n (with-gensyms (gf)\n (flet ((make-save-method (args)\n (with-gensyms (method)\n (multiple-value-bind (qualifiers specializers lambda-list body)\n (parse-method args)\n\n (let ((fn-name (gentemp (symbol-name (block-name name)) *method-function-package*)))\n (list `(let ((,method (find-method% ,gf ',qualifiers ',specializers)))\n ,(make-add-method-info name method fn-name body :remove-on-redefine-p t))\n\n (make-method-function name fn-name lambda-list body)\n\n (make-static-dispatch name lambda-list specializers)))))))\n\n (let ((combination 'standard)\n (combination-options))\n\n `(progn\n (walk-environment\n (c2mop:defgeneric ,name ,lambda-list ,@options))\n\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (add-compiler-macro ',name)\n (remove-defined-methods ',name))\n\n (let ((,gf (fdefinition ',name)))\n (when (typep ,gf 'generic-function)\n ,@(handler-case\n (append\n (mappend\n (lambda-match\n ((list* :method args)\n (make-save-method args))\n\n ((list* :method-combination name options)\n (setf combination name)\n (setf combination-options options)))\n\n options)\n\n `((setf (combination-options ',name)\n '(,combination ,combination-options))))\n\n (error (e)\n (simple-style-warning \"Error parsing DEFGENERIC form:~%~a\" e)\n nil)))\n\n ,gf))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(static-let* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by STATIC-LET*", "input": "(static-let* nil\n (progn))", "output": "(defmacro static-let* ((&rest bindings) &body body &environment env)\n \"Like `let*', except the variables are only initialized once and\nretain their values between different invocations of `body'.\n\nEvery static binding is similar to a `let' binding, except it can have\nadditional keyword arguments:\n\n- `type' Denotes the type of the variable.\n- `once' If true, then binding initialization and mutation will be\n thread-safe.\n- `flush' If true, this binding will be flushable. Defaults to true.\n- `in' Denotes the static binding group in which the binding will be\n placed for flushing. Defaults to the value of `*package'.\n- `read-only' If true, then the binding cannot be mutated with `setf'.\n\nStatic bindings can be flushed via `flush-static-binding-group' and\n`flush-all-static-binding-groups'; the latter is automatically pushed\ninto `uiop:*dump-image-hooks*' by Serapeum.\n\nAn unflushable static binding will carry its value over into dumped\nLisp binaries.\"\n (parse-static-let* bindings body env))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8724999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(.> common-lisp:nil (common-lisp:progn))\n\nProblem: Macro call that should be transformed by .>", "input": "(.> common-lisp:nil (common-lisp:progn))", "output": "(defmacro .> (cl:&rest items)\n \"Left associative compose operator. Creates a new functions that will run the\nfunctions left to right when applied. This is the same as the `pipe` macro without supplying\nthe value. The composition is thus the reverse order of `compose`.\n\n`(.> f g h)` creates the function `(fn (x) (h (g (f x))))`.\"\n (alexandria:with-gensyms (x)\n `(fn (,x)\n (pipe ,x ,@items))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Generate a defmacro form that transforms code like this:\n(alter-table 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by ALTER-TABLE", "input": "(alter-table 'lol-gen::some-name)", "output": "(defmacro alter-table (table &body clauses)\n `(make-statement :alter-table\n ,(expand-expression table) ,@clauses))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(rotatef nil :key nil)\n\nProblem: Macro call that should be transformed by ROTATEF", "input": "(rotatef nil :key nil)", "output": "(defmacro ROTATEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-none-awake nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-NONE-AWAKE", "input": "(with-none-awake nil\n (progn))", "output": "(defmacro with-none-awake ((&key dbg diag) &body body)\n `(call-with-none-awake ,dbg (lambda () ,@body) ,diag))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fm? nil)\n\nProblem: Macro call that should be transformed by FM?", "input": "(fm? nil)", "output": "(defmacro fm? (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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nand nil)\n\nIssue: Macro call that should be transformed by NAND", "input": "(nand nil)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.815} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make-name-transformer nil)\n\nWhat needs to change: Macro call that should be transformed by MAKE-NAME-TRANSFORMER", "input": "(make-name-transformer nil)", "output": "(defmacro MAKE-NAME-TRANSFORMER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defun nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFUN", "input": "(defun nil (progn))", "output": "(defmacro DEFUN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(current-decoder 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by CURRENT-DECODER", "input": "(current-decoder 'lol-gen::some-name)", "output": "(defmacro current-decoder (&rest keys)\n \"Capture current values of custom variables and return a custom\ndecoder which restores these values in its dynamic environment.\"\n (let (exterior-bindings customizations)\n (flet ((collect (key var)\n (let ((exterior (gensym)))\n (push (list exterior var) exterior-bindings)\n (push exterior customizations)\n (push key customizations))))\n (if keys\n (loop for key in keys\n do (collect key (custom-key-to-variable key)))\n (loop-on-custom (key var)\n do (collect key var)))\n `(let ,exterior-bindings\n (custom-decoder ,@customizations)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(jbind nil\n nil)\n\nIssue: Macro call that should be transformed by JBIND", "input": "(jbind nil\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(def-c-unchanged-test 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DEF-C-UNCHANGED-TEST", "input": "(def-c-unchanged-test 'lol-gen::some-name)", "output": "(defmacro def-c-unchanged-test ((class slotname) &body test)\n `(defmethod c-unchanged-test ((self ,class) (slotname (eql ',slotname)))\n ,@test))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond->>\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by COND->>", "input": "(cond->>\n nil\n (progn))", "output": "(defmacro COND->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(as->* nil nil)\n\nPattern to recognize: Macro call that should be transformed by AS->*", "input": "(as->* nil nil)", "output": "(defmacro AS->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(special-symbol-reprogv nil\n nil)\n\nIssue: Macro call that should be transformed by SPECIAL-SYMBOL-REPROGV", "input": "(special-symbol-reprogv nil\n nil)", "output": "(defmacro SPECIAL-SYMBOL-REPROGV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(update nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by UPDATE", "input": "(update nil (progn))", "output": "(defmacro update (place value-form)\n (etypecase place\n (symbol `(setf ,place ,value-form))\n (list\n (let ((result (gensym \"RESULT\"))\n (var (gensym \"VAR\")))\n (lambda-fiddle:with-destructured-lambda-list (:required req :optional opt :rest rest :body body :key key) place\n (let ((rest (or rest body)))\n `(let ((,result ,value-form))\n ;; Convert required into test and POP\n ,@(loop for var in req\n do (assert (and (not (null var)) (symbolp var)))\n collect `(if ,result\n (setf ,var (pop ,result))\n (error \"Not enough arguments to satisfy lambda-list ~a.\" ',place)))\n ;; Convert &OPTIONAL into POP and default.\n ,@(loop for o in opt\n for (var default) = (enlist o)\n do (assert (and (not (null var)) (symbolp var)))\n collect `(setf ,var (or (pop ,result) ,default)))\n ;; If we don't have &REST or &KEY, error if there are some elements left.\n ,@(when (and (not rest) (not (find '&key place)))\n `((when ,result (error \"Too many elements supplied to satisfy lambda-list ~a.\" ',place))))\n ;; Convert &REST by just setting it to the remainder.\n ,@(when rest `((setf ,rest ,result)))\n ;; Convert &KEY into GETF and default.\n ,@(loop for k in key\n for (var default) = (enlist k)\n do (assert (and (not (null var)) (symbolp var)))\n collect `(setf ,var (or (getf ,result ,(intern (string var) :keyword)) ,default)))\n ;; If we have a non-empty &KEY list and don't have &ALLOW-OTHER-KEYS, check the keys.\n ,@(when (and key (not (find '&allow-other-keys place)))\n `((loop for ,var in ,result by #'cddr\n do (unless (find ,var ',(loop for k in key collect (intern (string k) :keyword)))\n (error \"Keyword argument ~s not found in lambda-list ~a.\"\n ,var ',place))))))))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c-input-dbg 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by C-INPUT-DBG", "input": "(c-input-dbg 'lol-gen::some-name)", "output": "(defmacro c-input-dbg (&optional (value nil valued-p))\n `(make-cell\n :inputp t\n :debug t\n :value-state ,(if valued-p :valid :unbound)\n :value ,value))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ensure-transaction-with-isolation-level nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ENSURE-TRANSACTION-WITH-ISOLATION-LEVEL", "input": "(ensure-transaction-with-isolation-level nil\n :key\n nil)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-unique-names nil)\n\nProblem: Macro call that should be transformed by WITH-UNIQUE-NAMES", "input": "(with-unique-names nil)", "output": "(defmacro with-unique-names (names &body forms)\n \"Alias for WITH-GENSYMS.\"\n `(with-gensyms ,names ,@forms))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(and-it nil nil)\n\nPattern to recognize: Macro call that should be transformed by AND-IT", "input": "(and-it nil nil)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(xhtml nil (progn))\n\nWhat needs to change: Macro call that should be transformed by XHTML", "input": "(xhtml nil (progn))", "output": "(defmacro xhtml (&rest tags)\n `(with-doctype :xhtml\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(continue-whopper nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CONTINUE-WHOPPER", "input": "(continue-whopper nil nil)", "output": "(defmacro CONTINUE-WHOPPER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fm-other?! nil (progn))\n\nPattern to recognize: Macro call that should be transformed by FM-OTHER?!", "input": "(fm-other?! nil (progn))", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-connection nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-CONNECTION", "input": "(with-connection nil)", "output": "(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*))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(defmethod* nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by DEFMETHOD*", "input": "(defmethod* nil :key nil)", "output": "(defmacro DEFMETHOD* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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 <-", "input": "(<- nil (progn))", "output": "(defmacro <- (place fn)\n \"Apply FN in-place to PLACE.\"\n `(setf ,place (call ,fn ,place)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(bind-custom-vars nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by BIND-CUSTOM-VARS", "input": "(bind-custom-vars nil\n nil)", "output": "(defmacro bind-custom-vars ((&rest customizations) &body body)\n `(let ,(loop-on-custom (key var value) customizations\n collect (list var value))\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-custom-decoder-level nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITH-CUSTOM-DECODER-LEVEL", "input": "(with-custom-decoder-level nil\n :key\n nil)", "output": "(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)))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-dot nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-DOT", "input": "(with-dot nil)", "output": "(defmacro with-dot (() &body body)\n `(progn ,@(replace-dot-calls body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(f_%)\n\nProblem: Macro call that should be transformed by F_%", "input": "(f_%)", "output": "(defmacro F_% ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(removef nil (progn))\n\nProblem: Macro call that should be transformed by REMOVEF", "input": "(removef nil (progn))", "output": "(defmacro REMOVEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(c-abs 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by C-ABS", "input": "(c-abs 'lol-gen::some-name)", "output": "(defmacro c-abs (value &body body)\n `(make-c-drifter-absolute\n :code ',body\n :value-state :valid\n :value ,value\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-explicit-encoder\n nil)\n\nIssue: Macro call that should be transformed by WITH-EXPLICIT-ENCODER", "input": "(with-explicit-encoder\n nil)", "output": "(defmacro with-explicit-encoder (&body body)\n `(with-local-encoder (use-explicit-encoder)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda-cmatch\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by LAMBDA-CMATCH", "input": "(lambda-cmatch\n 'lol-gen::some-name)", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(iterate nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ITERATE", "input": "(iterate nil nil)", "output": "(defmacro ITERATE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(with-unique-names nil\n (progn))", "output": "(defmacro with-unique-names (names &body body)\n `(let ,(mapcar (lambda (sym)\n `(,sym (gensym ,(symbol-name sym))))\n names)\n ,@body))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(aand nil)\n\nPattern to recognize: Macro call that should be transformed by AAND", "input": "(aand nil)", "output": "(defmacro aand (first &rest rest)\n \"Like AND, except binds the first argument to IT (via LET) for the\nscope of the rest of the arguments.\"\n `(anaphoric and ,first ,@rest))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(ensure nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by ENSURE", "input": "(ensure nil\n :key\n nil)", "output": "(defmacro ensure (place &body newval\n &environment env)\n \"Essentially (or place (setf place newval)).\n\nPLACE is treated as unbound if it returns `nil', signals\n`unbound-slot', or signals `unbound-variable'.\n\nNote that ENSURE is `setf'-able, so you can do things like\n (incf (ensure x 0))\n\nCf. `ensure2'.\"\n (multiple-value-bind (vars vals stores setter getter)\n (get-setf-expansion place env)\n `(let* ,(mapcar #'list vars vals)\n (or (ignore-some-conditions (unbound-slot unbound-variable)\n ,getter)\n (multiple-value-bind ,stores\n (progn ,@newval)\n (when ,(first stores)\n ,setter))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fm-other?! nil)\n\nWhat needs to change: Macro call that should be transformed by FM-OTHER?!", "input": "(fm-other?! nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-keys nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-KEYS", "input": "(with-keys nil\n :key\n nil)", "output": "(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)))", "category": "dsl", "technique": "once-only,nested-backquote", "complexity": "intermediate", "quality_score": 0.8725} {"instruction": "Generate a defmacro form that transforms code like this:\n(aand nil)\n\nPattern to recognize: Macro call that should be transformed by AAND", "input": "(aand nil)", "output": "(defmacro AAND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(defmacro* nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFMACRO*", "input": "(defmacro* nil\n :key\n nil)", "output": "(defmacro DEFMACRO* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(etypecase nil)\n\nWhat needs to change: Macro call that should be transformed by ETYPECASE", "input": "(etypecase nil)", "output": "(defmacro ETYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(isnt nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ISNT", "input": "(isnt nil :key nil)", "output": "(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)))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(declaim nil)\n\nPattern to recognize: Macro call that should be transformed by DECLAIM", "input": "(declaim nil)", "output": "(defmacro DECLAIM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(->> nil)\n\nProblem: Macro call that should be transformed by ->>", "input": "(->> nil)", "output": "(defmacro ->> (init &body exps) (arrow-macro init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(all-of nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ALL-OF", "input": "(all-of nil\n :key\n nil)", "output": "(defmacro ALL-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(between nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by BETWEEN", "input": "(between nil :key nil)", "output": "(defmacro between (a parser b &key (id nil))\n \"A main parser flanked by two other ones. Only the value of the main parser is\nkept. Good for parsing backets, parentheses, etc.\"\n (declare (ignore id))\n `(*> ,a (<* ,parser ,b)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(on-duplicate-key-update)\n\nWhat needs to change: Macro call that should be transformed by ON-DUPLICATE-KEY-UPDATE", "input": "(on-duplicate-key-update)", "output": "(defmacro on-duplicate-key-update (&rest args)\n `(make-clause :on-duplicate-key-update ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(match nil)\n\nProblem: Macro call that should be transformed by MATCH", "input": "(match nil)", "output": "(defmacro match (arg &body clauses)\n \"Matches ARG with CLAUSES. CLAUSES is a list of the form of (PATTERN\n. BODY) where PATTERN is a pattern specifier and BODY is an implicit\nprogn. If ARG matches some PATTERN, `match` then evaluates\nthe corresponding BODY and returns the evaluated value. If no pattern matches,\nthen returns NIL.\n\nEvaluating a form (FAIL) in the clause body causes the latest pattern\nmatching to fail. For example,\n\n (match 1\n (x (if (eql x 1)\n (fail)\n x))\n (_ 'ok))\n\nreturns OK, because the form (FAIL) in the first clause is\nevaluated.\n\nIf BODY starts with the symbols WHEN or UNLESS, then the next form\nwill be used to introduce (FAIL). That is,\n\n (match list ((list x) when (oddp x) x))\n (match list ((list x) unless (evenp x) x))\n\nwill be translated to\n\n (match list ((list x) (if (oddp x) x (fail))))\n (match list ((list x) (if (evenp x) (fail) x)))\n\nExamples:\n\n (match 1 (1 1))\n => 1\n (match 1 (2 2))\n => 2\n (match 1 (x x))\n => 1\n (match (list 1 2 3)\n (list x y z) (+ x y z))\n => 6\"\n (compile-match-1 arg clauses nil))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8274999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-interleaving)\n\nPattern to recognize: Macro call that should be transformed by WITH-INTERLEAVING", "input": "(with-interleaving)", "output": "(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))))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(aetypecase 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by AETYPECASE", "input": "(aetypecase 'lol-gen::some-name)", "output": "(defmacro aetypecase (keyform &body cases)\n \"Like ETYPECASE, except binds the result of the keyform to IT (via LET) for\nthe scope of the cases.\"\n `(anaphoric etypecase ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(delete-from-plistf nil (progn))\n\nProblem: Macro call that should be transformed by DELETE-FROM-PLISTF", "input": "(delete-from-plistf nil (progn))", "output": "(defmacro DELETE-FROM-PLISTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(or nil nil)\n\nPattern to recognize: Macro call that should be transformed by OR", "input": "(or nil nil)", "output": "(defmacro OR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(summing\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by SUMMING", "input": "(summing\n nil\n :key\n nil)", "output": "(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))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fail 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by FAIL", "input": "(fail 'lol-gen::some-name)", "output": "(defmacro fail (&rest message-args)\n \"Simply generate a FAIL.\"\n `(process-failure ',message-args\n ,@message-args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dict-of nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DICT-OF", "input": "(dict-of nil :key nil)", "output": "(defmacro DICT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(printing-unreadably nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PRINTING-UNREADABLY", "input": "(printing-unreadably nil nil)", "output": "(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)))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cmatch nil)\n\nIssue: Macro call that should be transformed by CMATCH", "input": "(cmatch nil)", "output": "(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))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-compilation-unit 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WITH-COMPILATION-UNIT", "input": "(with-compilation-unit 'lol-gen::some-name)", "output": "(defmacro WITH-COMPILATION-UNIT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c?)\n\nWrite a macro that addresses: Macro call that should be transformed by C?", "input": "(c?)", "output": "(defmacro c? (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(for nil)\n\nPattern to recognize: Macro call that should be transformed by FOR", "input": "(for nil)", "output": "(defmacro for (&environment env bindings &body body)\n (let ((*environment* env))\n (multiple-value-bind (bind-init bind-forms bind-exit bind-post) (convert-bindings bindings)\n (multiple-value-bind (clause-init body-forms clause-exit) (convert-clauses body)\n `(with-interleaving\n ,@bind-init\n ,@clause-init\n (with-for-block ()\n (with-for-tagbody\n (progn ,@bind-forms\n ,@body-forms\n ,@bind-post)\n (return-for\n ,@clause-exit\n ,@bind-exit))))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-foreign-strings nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-FOREIGN-STRINGS", "input": "(with-foreign-strings nil\n (progn))", "output": "(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)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(without-c-dependency\n nil)\n\nProblem: Macro call that should be transformed by WITHOUT-C-DEPENDENCY", "input": "(without-c-dependency\n nil)", "output": "(defmacro without-c-dependency (&body body)\n ` (let (*depender*)\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(in-optimizer common-lisp:nil)\n\nProblem: Macro call that should be transformed by IN-OPTIMIZER", "input": "(in-optimizer common-lisp:nil)", "output": "(defmacro in-optimizer (name &optional verbose)\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n ,@(when verbose\n `((when ,verbose (format *trace-output* \"~&Switching to the ~A optimizer~%\" ',name))))\n (setf *optimizer* ',name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(on-duplicate-key-update nil)\n\nProblem: Macro call that should be transformed by ON-DUPLICATE-KEY-UPDATE", "input": "(on-duplicate-key-update nil)", "output": "(defmacro on-duplicate-key-update (&rest args)\n `(make-clause :on-duplicate-key-update ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do-sequences nil)\n\nIssue: Macro call that should be transformed by DO-SEQUENCES", "input": "(do-sequences nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(drelet nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DRELET", "input": "(drelet nil\n nil)", "output": "(defmacro DRELET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-method-combination nil nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-METHOD-COMBINATION", "input": "(define-method-combination nil nil)", "output": "(defmacro DEFINE-METHOD-COMBINATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(local-output\n nil\n (progn))\n\nIssue: Macro call that should be transformed by LOCAL-OUTPUT", "input": "(local-output\n nil\n (progn))", "output": "(defmacro LOCAL-OUTPUT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(some-<>> nil)\n\nIssue: Macro call that should be transformed by SOME-<>>", "input": "(some-<>> nil)", "output": "(defmacro SOME-<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-shadowed-custom-vars\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-SHADOWED-CUSTOM-VARS", "input": "(with-shadowed-custom-vars\n nil\n (progn))", "output": "(defmacro with-shadowed-custom-vars (&body body)\n `(let ,(loop for (var) in *custom-vars*\n collect `(,var (if (boundp ',var) ,var)))\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(pcase nil (progn))\n\nPattern to recognize: Macro call that should be transformed by PCASE", "input": "(pcase nil (progn))", "output": "(defmacro pcase (pred keyform &rest clauses)\n \"Like CASE, but uses given PRED instead of EQL to select appropriate CLAUSE.\n\n Example usage:\n\n CL-USER> (pcase '< 1\n (0 (print \\\"Below zero\\\"))\n (2 (print \\\"OK\\\"))\n (otherwise (error \\\"Oops\\\")))\n\"\n (expand-predicate-case pred keyform clauses 'case))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-cc nil)\n\nProblem: Macro call that should be transformed by WITH-CC", "input": "(with-cc nil)", "output": "(defmacro with-cc (id &body body)\n `(with-integrity (:change ,id)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda-bind nil\n nil)\n\nProblem: Macro call that should be transformed by LAMBDA-BIND", "input": "(lambda-bind nil\n nil)", "output": "(defmacro lambda-bind ((&rest instrs) &body body)\n \"Use `bind' to allow restructuring of argument to lambda expressions.\n\nThis lets you funcall and destructure simultaneously. For example\n\n (let ((fn (lambda-bind ((a b) c) (cons a c))))\n (funcall fn '(1 2) 3))\n ;; => (1 . 3)\n\nVia eschulte (see git://gist.github.com/902174.git).\n\"\n #+(or)\n (declare (indent 1))\n (let* ((evald-instrs instrs)\n (syms (mapcar (lambda (_)\n\t\t\t (declare (ignore _))\n\t\t\t (gensym))\n\t\t evald-instrs)))\n `(lambda ,syms (bind ,(mapcar #'list evald-instrs syms) ,@body))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(nor nil (progn))\n\nWhat needs to change: Macro call that should be transformed by NOR", "input": "(nor nil (progn))", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ok nil (progn))\n\nWhat needs to change: Macro call that should be transformed by OK", "input": "(ok nil (progn))", "output": "(defmacro ok (test &optional desc)\n (with-gensyms (duration result)\n (once-only (test desc)\n `(with-catching-errors (:expected T :description ,desc)\n (with-duration ((,duration ,result) ,test)\n (test ,result t ,desc\n :duration ,duration\n :test-fn (lambda (x y)\n (eq (not (null x)) y))\n :got-form ,test))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make-window-or-instance nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-WINDOW-OR-INSTANCE", "input": "(make-window-or-instance nil :key nil)", "output": "(defmacro MAKE-WINDOW-OR-INSTANCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "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 <*>", "input": "(<*> nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-unique-names 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-UNIQUE-NAMES", "input": "(with-unique-names 'lol-gen::some-name)", "output": "(defmacro with-unique-names (names &body body)\n `(let ,(mapcar (lambda (sym)\n `(,sym (gensym ,(symbol-name sym))))\n names)\n ,@body))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(metaclass common-lisp:nil\n (common-lisp:progn))\n\nIssue: Macro call that should be transformed by METACLASS", "input": "(metaclass common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro METACLASS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-foreign-strings 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-FOREIGN-STRINGS", "input": "(with-foreign-strings 'lol-gen::some-name)", "output": "(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)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(and nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AND", "input": "(and nil nil)", "output": "(defmacro AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(is-print nil nil)\n\nWhat needs to change: Macro call that should be transformed by IS-PRINT", "input": "(is-print nil nil)", "output": "(defmacro is-print (got expected &optional desc)\n (with-gensyms (output duration duration-inner)\n (once-only (expected desc)\n `(with-catching-errors (:description ,desc :expected ,expected)\n (let* (,duration\n (,output (with-output-to-string (*standard-output*)\n (with-duration ((,duration-inner ,output) ,got)\n (declare (ignore ,output))\n (setq ,duration ,duration-inner)))))\n (test ,output ,expected ,desc\n :duration ,duration\n :got-form ',got\n :test-fn #'string=\n :report-expected-label \"output\"))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(abbr nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by ABBR", "input": "(abbr nil :key nil)", "output": "(defmacro abbr (short long &optional lambda-list)\n \"Abbreviate LONG macro or function name as SHORT.\n If LAMBDA-LIST is present, also copy appropriate SETF-expander.\"\n `(eval-always\n ;; Lispworks signals error while abbreviating to keywords\n ;; SBCL has package locks when accessing built-in functionality\n ;; other similar things are probably possible in other implementations\n (handler-bind ((error (lambda (e)\n (let ((r (find-restart 'continue e)))\n (when r\n (warn 'rutils-style-warning\n :format-control\n \"Skipped error during abbreviation: ~A\"\n :format-arguments (list e))\n (invoke-restart r))))))\n (cond\n ((macro-function ',long)\n (setf (macro-function ',short) (macro-function ',long))\n #+ccl (setf (ccl:arglist ',short) (ccl:arglist ',long)))\n ((special-operator-p ',long)\n (error \"Can't abbreviate a special-operator ~a\" ',long))\n ((fboundp ',long)\n (setf (fdefinition ',short) (fdefinition ',long))\n #+ccl (setf (ccl:arglist ',short) (ccl:arglist ',long))\n ,(when lambda-list\n `(define-setf-expander ,short ,lambda-list\n (values ,@(multiple-value-bind\n (dummies vals store store-form access-form)\n (get-setf-expansion\n (cons long (remove-if (lambda (sym)\n (member sym '(&optional &key)))\n lambda-list)))\n (let ((expansion-vals (mapcar (lambda (x) `(quote ,x))\n (list dummies\n vals\n store\n store-form\n access-form))))\n (setf (second expansion-vals)\n (cons 'list vals))\n expansion-vals))))))\n (t\n (error \"Can't abbreviate ~a\" ',long)))\n (setf (documentation ',short 'function) (documentation ',long 'function))\n ',short)))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(raw nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by RAW", "input": "(raw nil (progn))", "output": "(defmacro raw (&rest forms)\n `(list ,@forms))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(econd-let nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by ECOND-LET", "input": "(econd-let nil\n :key\n nil)", "output": "(defmacro econd-let (symbol &body clauses)\n \"Like `cond-let' for `econd'.\"\n `(cond-let ,symbol\n ,@clauses\n (t (error 'econd-failure))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-unique-names nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-UNIQUE-NAMES", "input": "(with-unique-names nil\n :key\n nil)", "output": "(defmacro with-unique-names (names &body body)\n `(let ,(mapcar (lambda (sym)\n `(,sym (gensym ,(symbol-name sym))))\n names)\n ,@body))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-sum nil)\n\nWhat needs to change: Macro call that should be transformed by COLLECT-SUM", "input": "(collect-sum nil)", "output": "(defmacro COLLECT-SUM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(or nil (progn))\n\nWhat needs to change: Macro call that should be transformed by OR", "input": "(or nil (progn))", "output": "(defmacro OR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(when nil)\n\nIssue: Macro call that should be transformed by WHEN", "input": "(when nil)", "output": "(defmacro WHEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(appendf nil (progn))\n\nIssue: Macro call that should be transformed by APPENDF", "input": "(appendf nil (progn))", "output": "(defmacro APPENDF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(trcx nil)\n\nWrite a macro that addresses: Macro call that should be transformed by TRCX", "input": "(trcx nil)", "output": "(defmacro trcx (tgt-form &rest os)\n (if (eql tgt-form 'nil)\n '(progn)\n `(without-c-dependency\n (call-trc t ,(format nil \"TX> ~(~s~)\" tgt-form)\n ,@(loop for obj in (or os (list tgt-form))\n nconcing (list (intern (format nil \"~a\" obj) :keyword) obj))))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(bcond\n nil)\n\nProblem: Macro call that should be transformed by BCOND", "input": "(bcond\n nil)", "output": "(defmacro bcond (&body clauses)\n \"Scheme's extended COND.\n\nThis is exactly like COND, except for clauses having the form\n\n (test :=> recipient)\n\nIn that case, if TEST evaluates to a non-nil result, then RECIPIENT, a\nfunction, is called with that result, and the result of RECIPIENT is\nreturn as the value of the `cond`.\n\nAs an extension, a clause like this:\n\n (test :=> var ...)\n\nCan be used as a shorthand for\n\n (test :=> (lambda (var) ...))\n\nThe name `bcond' for a \u201cbinding cond\u201d goes back at least to the days\nof the Lisp Machines. I do not know who was first to use it, but the\noldest examples I have found are by Michael Parker and Scott L.\nBurson.\"\n (flet ((send-clause? (clause)\n (let ((second (second clause)))\n (and (symbolp second)\n (string= second :=>))))\n (parse-send-clause (clause)\n (destructuring-bind (test => . body) clause\n (declare (ignore =>))\n (cond ((null body) (error \"Missing clause\"))\n ((null (rest body))\n (values test (car body)))\n (t (destructuring-bind (var . body) body\n (let ((fn `(lambda (,var) ,@body)))\n (values test fn))))))))\n ;; Note that we expand into `cond' rather than `if' so we don't\n ;; have to handle tests without bodies.\n (cond ((null clauses) nil)\n ((member-if #'send-clause? clauses)\n (let* ((tail (member-if #'send-clause? clauses))\n (preceding (ldiff clauses tail))\n (clause (car tail))\n (clauses (cdr tail)))\n (multiple-value-bind (test fn)\n (parse-send-clause clause)\n (with-gensyms (tmp)\n `(cond ,@preceding\n (t (if-let1 ,tmp ,test\n (funcall ,fn ,tmp)\n (bcond ,@clauses))))))))\n (t `(cond ,@clauses)))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(signals 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by SIGNALS", "input": "(signals 'lol-gen::some-name)", "output": "(defmacro signals (condition-spec\n &body body)\n \"Generates a pass if BODY signals a condition of type\nCONDITION. BODY is evaluated in a block named NIL, CONDITION is\nnot evaluated.\"\n (let ((block-name (gensym)))\n (destructuring-bind (condition &optional reason-control &rest reason-args)\n (ensure-list condition-spec)\n `(block ,block-name\n (handler-bind ((,condition (lambda (c)\n (declare (ignore c))\n ;; ok, body threw condition\n (add-result 'test-passed\n :test-expr ',condition)\n (return-from ,block-name t))))\n (block nil\n ,@body))\n (process-failure\n ',condition\n ,@(if reason-control\n `(,reason-control ,@reason-args)\n `(\"Failed to signal a ~S\" ',condition)))\n (return-from ,block-name nil)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(bdd-typecase nil)\n\nIssue: Macro call that should be transformed by BDD-TYPECASE", "input": "(bdd-typecase nil)", "output": "(defmacro BDD-TYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(letrec 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by LETREC", "input": "(letrec 'lol-gen::some-name)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(setf nil nil)\n\nPattern to recognize: Macro call that should be transformed by SETF", "input": "(setf nil nil)", "output": "(defmacro SETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(push-end nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PUSH-END", "input": "(push-end nil nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-read-only-vars nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-READ-ONLY-VARS", "input": "(with-read-only-vars nil\n (progn))", "output": "(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))))", "category": "anaphoric", "technique": "symbol-macrolet,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8325} {"instruction": "Generate a defmacro form that transforms code like this:\n(the-part 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by THE-PART", "input": "(the-part 'lol-gen::some-name)", "output": "(defmacro THE-PART ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defsubst nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFSUBST", "input": "(defsubst nil\n :key\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ecase-of nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ECASE-OF", "input": "(ecase-of nil\n :key\n nil)", "output": "(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)))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fn* nil)\n\nProblem: Macro call that should be transformed by FN*", "input": "(fn* nil)", "output": "(defmacro fn* (form &environment env)\n (fn*-internals form env))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Generate a defmacro form that transforms code like this:\n(awhen nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by AWHEN", "input": "(awhen nil\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(live\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by LIVE", "input": "(live\n 'lol-gen::some-name)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defalias nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFALIAS", "input": "(defalias nil\n :key\n nil)", "output": "(defmacro defalias (alias &body (def &optional docstring)\n &environment env)\n \"Define a value as a top-level function.\n\n (defalias string-gensym (compose #'gensym #'string))\n\nLike (setf (fdefinition ALIAS) DEF), but with a place to put\ndocumentation and some niceties to placate the compiler.\n\nNote that a function defined with `defalias' is declared `notinline'.\nThis is a matter of semantics: before we can assign to the function,\nwe must make it assignable (which is what `notinline' means).\n\nName from Emacs Lisp.\"\n `(progn\n (declaim (notinline ,alias))\n ,(multiple-value-bind (env decls lambda)\n (let-over-lambda def env)\n ;; If we can expand DEF into a lambda (possibly with some\n ;; variable bindings around it) then splice that lambda in\n ;; directly as the body of the function. (This is the same\n ;; function we use to resolve lambdas in `fbind'.)\n (if lambda\n (ematch lambda\n ((list* (and _ (eql 'lambda)) args body)\n `(let ,env\n (declare ,@decls)\n (defun ,alias ,args\n ,@(unsplice docstring)\n ,@body))))\n (with-unique-names (temp)\n `(let ((,temp (ensure-function ,def)))\n (declare (type function ,temp))\n ;; Give the function a temporary definition at\n ;; compile time so the compiler doesn't complain\n ;; about its being undefined.\n (defun ,alias (&rest args)\n (apply ,temp args))\n (setf (fdefinition ',alias) ,temp)\n ,@(unsplice\n (and docstring\n `(setf (documentation ',alias 'function) ,docstring)))))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-module nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-MODULE", "input": "(define-module nil)", "output": "(defmacro define-module (name &body options)\n (let ((name (string name))\n (package (gensym \"PACKAGE\")))\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (let ((,package (or (find-package ,name)\n (make-package ,name :use ()))))\n (modularize :package ,package :name ,name)\n (expand-module ,name ',options)\n ,package))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(defmethod nil)\n\nPattern to recognize: Macro call that should be transformed by DEFMETHOD", "input": "(defmethod nil)", "output": "(defmacro DEFMETHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(adowhile nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by ADOWHILE", "input": "(adowhile nil\n :key\n nil)", "output": "(defmacro ADOWHILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(export-only-always nil nil)\n\nPattern to recognize: Macro call that should be transformed by EXPORT-ONLY-ALWAYS", "input": "(export-only-always nil nil)", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-accumulation-binding nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-ACCUMULATION-BINDING", "input": "(define-accumulation-binding nil\n (progn))", "output": "(defmacro define-accumulation-binding (name (var &rest args) &body body)\n `(define-form-binding ,name (,var ,@args)\n ,@(form-fiddle:lambda-declarations `(lambda () ,@body))\n (values\n (progn ,@(form-fiddle:lambda-forms `(lambda () ,@body)))\n (delist var))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c-abs nil\n nil)\n\nProblem: Macro call that should be transformed by C-ABS", "input": "(c-abs nil\n nil)", "output": "(defmacro c-abs (value &body body)\n `(make-c-drifter-absolute\n :code ',body\n :value-state :valid\n :value ,value\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(nreversef nil)\n\nWhat needs to change: Macro call that should be transformed by NREVERSEF", "input": "(nreversef nil)", "output": "(defmacro NREVERSEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(yield-all nil)\n\nIssue: Macro call that should be transformed by YIELD-ALL", "input": "(yield-all nil)", "output": "(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))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(cell-let 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by CELL-LET", "input": "(cell-let 'lol-gen::some-name)", "output": "(defmacro cell-let ((&rest bindings) &body body &environment env)\n \"Define cells that are visible only to the forms in BODY.\n\nBINDINGS is a list of cell bindings to establish, similar to\nLET*. Each item in BINDINGS is a list of the form\n\n.. code-block::\n\n (NAME VALUE-FORM)\n\nwhere NAME is the symbol identifying the cell and VALUE-FORM is the\nvalue form of the cell. The cell can then be referenced within the\nforms in BODY by the symbol NAME.\n\nThe cells defined in BINDINGS lexcially shadow those in the\nenvironment defined with DEFCELL or by an enclosing CELL-LET\nform. Like LET* and unlike LET, each cell definition may reference the\ncells defined earlier in the same CELL-LET.\n\nThe forms in BODY are evaluated in an implicit PROGN. The value\nreturned by the last form is returned by the CELL-LET form.\"\n\n (flet ((make-cell-binding (binding form)\n (destructuring-bind (name &optional initform)\n (ensure-list binding)\n\n (if (constantp initform env)\n `(mutable-cell-let% (,name ,initform) ,form)\n `(computed-cell-let% (,name ,initform) ,form)))))\n\n (->> `(progn ,@body)\n (reduce #'make-cell-binding bindings :from-end t :initial-value))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do-generator 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DO-GENERATOR", "input": "(do-generator 'lol-gen::some-name)", "output": "(defmacro do-generator ((var &rest vars-and-generator) &body body)\n \"Steps through the specified generator, binding the value it returns to var, then executing the body for each step. If multiple variables are specified and the generator returns multiple values, the extra values will be bound to the extra variables.\"\n (let ((g (gensym)))\n `(let ((,g ,(car (last vars-and-generator))))\n (loop \n\t do (if-generator ((,var ,@(butlast vars-and-generator)) ,g)\n\t\t\t (progn\n\t\t\t ,@body)\n\t\t\t (return))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "Generate a defmacro form that transforms code like this:\n(c-in 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by C-IN", "input": "(c-in 'lol-gen::some-name)", "output": "(defmacro c-in (value)\n `(make-cell\n :inputp t\n :value-state :valid\n :value ,value))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(export-class\n common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by EXPORT-CLASS", "input": "(export-class\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro EXPORT-CLASS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(destructuring-ecase-of nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DESTRUCTURING-ECASE-OF", "input": "(destructuring-ecase-of nil\n (progn))", "output": "(defmacro destructuring-ecase-of (type expr &body body)\n \"Like `destructuring-ecase', from Alexandria, but with exhaustivness\nchecking.\n\nTYPE is a designator for a type, which should be defined as `(member\n...)'. At compile time, the macro checks that, taken together, the\nsymbol at the head of each of the destructuring lists in BODY form an\nexhaustive partition of TYPE, and warns if it is not so.\"\n (expand-destructuring-case-of type expr body 'ecase-of))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(def-metadata-kind nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEF-METADATA-KIND", "input": "(def-metadata-kind nil\n nil)", "output": "(defmacro def-metadata-kind (name (&key conc-name (binds-to :value))\n &body slot-names)\n (warn 'v-deprecated\n :old 'def-metadata-kind\n :new 'define-metadata-kind)\n `(define-metadata-kind ,name (:conc-name ,conc-name :binds-to ,binds-to)\n ,@slot-names))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nreversef nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NREVERSEF", "input": "(nreversef nil)", "output": "(defmacro NREVERSEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-global-parameter nil :key nil)\n\nIssue: Macro call that should be transformed by DEFINE-GLOBAL-PARAMETER", "input": "(define-global-parameter nil :key nil)", "output": "(defmacro DEFINE-GLOBAL-PARAMETER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(destructuring-bind () :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DESTRUCTURING-BIND", "input": "(destructuring-bind () :key nil)", "output": "(defmacro DESTRUCTURING-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(declare-deprecated-operators)\n\nWhat needs to change: Macro call that should be transformed by DECLARE-DEPRECATED-OPERATORS", "input": "(declare-deprecated-operators)", "output": "(defmacro DECLARE-DEPRECATED-OPERATORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(do-iter-values nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DO-ITER-VALUES", "input": "(do-iter-values nil\n :key\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "tagbody-go,gensym,anaphor", "complexity": "advanced", "quality_score": 0.825} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-setf-expander nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-SETF-EXPANDER", "input": "(define-setf-expander nil (progn))", "output": "(defmacro DEFINE-SETF-EXPANDER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c?\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by C?", "input": "(c?\n nil\n :key\n nil)", "output": "(defmacro c? (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(f_n\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by F_N", "input": "(f_n\n nil\n :key\n nil)", "output": "(defmacro F_N ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(->>\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ->>", "input": "(->>\n 'lol-gen::some-name)", "output": "(defmacro ->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda-match)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-MATCH", "input": "(lambda-match)", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(if-not nil :key nil)\n\nIssue: Macro call that should be transformed by IF-NOT", "input": "(if-not nil :key nil)", "output": "(defmacro if-not (test then &optional else)\n \"If TEST evaluates to NIL, evaluate THEN and return its values,\notherwise evaluate ELSE and return its values. ELSE defaults to NIL.\"\n `(if (not ,test)\n ,then\n ,else))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(summing-to nil (progn))\n\nProblem: Macro call that should be transformed by SUMMING-TO", "input": "(summing-to nil (progn))", "output": "(defmacro SUMMING-TO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ensure nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ENSURE", "input": "(ensure nil\n nil)", "output": "(defmacro ensure (place &body newval\n &environment env)\n \"Essentially (or place (setf place newval)).\n\nPLACE is treated as unbound if it returns `nil', signals\n`unbound-slot', or signals `unbound-variable'.\n\nNote that ENSURE is `setf'-able, so you can do things like\n (incf (ensure x 0))\n\nCf. `ensure2'.\"\n (multiple-value-bind (vars vals stores setter getter)\n (get-setf-expansion place env)\n `(let* ,(mapcar #'list vars vals)\n (or (ignore-some-conditions (unbound-slot unbound-variable)\n ,getter)\n (multiple-value-bind ,stores\n (progn ,@newval)\n (when ,(first stores)\n ,setter))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(finc nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FINC", "input": "(finc nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(-> nil)\n\nIssue: Macro call that should be transformed by ->", "input": "(-> nil)", "output": "(defmacro -> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-screamer-package nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-SCREAMER-PACKAGE", "input": "(define-screamer-package nil\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(case 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by CASE", "input": "(case 'lol-gen::some-name)", "output": "(defmacro CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(iterate\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by ITERATE", "input": "(iterate\n 'lol-gen::some-name)", "output": "(defmacro ITERATE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defvariant nil\n (progn))\n\nProblem: Macro call that should be transformed by DEFVARIANT", "input": "(defvariant nil\n (progn))", "output": "(defmacro DEFVARIANT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(isnt-values 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ISNT-VALUES", "input": "(isnt-values 'lol-gen::some-name)", "output": "(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)))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(-> nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by ->", "input": "(-> nil\n :key\n nil)", "output": "(defmacro -> (init &body exps) (arrow-macro init exps))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(is-false nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IS-FALSE", "input": "(is-false nil :key nil)", "output": "(defmacro is-false (condition &rest reason-args)\n \"Generates a pass if CONDITION returns false, generates a\n failure otherwise. Like IS-TRUE, and unlike IS, IS-FALSE does\n not inspect CONDITION to determine what reason to give it case\n of test failure\"\n (with-gensyms (value)\n `(let ((,value ,condition))\n (if ,value\n (process-failure ',condition\n ,@(or reason-args\n `(\"~S returned the value ~S, which is true\" ',condition ,value)))\n (add-result 'test-passed :test-expr ',condition)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-package-syntax\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-PACKAGE-SYNTAX", "input": "(define-package-syntax\n 'lol-gen::some-name)", "output": "(defmacro define-package-syntax (&body (package . options))\n (unless (typep package 'package-designator)\n (push package options)\n (setq package *package*))\n `(defsyntax ,(package-syntax-name package)\n ,@options))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-item-key-function 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-ITEM-KEY-FUNCTION", "input": "(with-item-key-function 'lol-gen::some-name)", "output": "(defmacro with-item-key-function ((key &optional (key-form key))\n &body body &environment env)\n \"For each of the most common key functions used in sequences, emit a\ncopy of BODY with KEY bound to a local macro that calls KEY-FORM.\n\nIf current optimization declarations favor space over speed, or\ncompilation speed over runtime speed, then BODY is only emitted once.\"\n (check-type key symbol)\n (with-unique-names (ukey)\n `(let* ((,key (canonicalize-key ,key-form))\n (,ukey ,key))\n ,@(expect-form-list\n (if (not (speed-matters? env))\n `((macrolet ((,key (x) (list 'funcall ',ukey x)))\n ,@body))\n `((cond ((eql ,ukey #'identity)\n (macrolet ((,key (x) x))\n ,@body))\n (t (macrolet ((,key (x) (list 'funcall ',ukey x)))\n ,@body)))))))))", "category": "dsl", "technique": "macrolet", "complexity": "intermediate", "quality_score": 0.8875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(where 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WHERE", "input": "(where 'lol-gen::some-name)", "output": "(defmacro where (expression)\n `(make-clause :where\n ,(if (and (listp expression)\n (keywordp (car expression)))\n (expand-op expression)\n `,expression)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defparameter* nil :key nil)\n\nIssue: Macro call that should be transformed by DEFPARAMETER*", "input": "(defparameter* nil :key nil)", "output": "(defmacro DEFPARAMETER* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(eif-let nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by EIF-LET", "input": "(eif-let nil\n :key\n nil)", "output": "(defmacro eif-let (&whole whole binds &body (then &optional (else nil else?)))\n \"Like `alexandria:if-let', but expects two branches.\nCompare `eif'.\"\n (unless else?\n (warn \"Missing else-branch in eif-let form:~%~a\"\n whole))\n `(if-let ,binds ,then ,else))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-object nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-OBJECT", "input": "(with-object nil\n (progn))", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-shuffling\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-SHUFFLING", "input": "(with-shuffling\n nil\n :key\n nil)", "output": "(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))))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(export-always 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by EXPORT-ALWAYS", "input": "(export-always 'lol-gen::some-name)", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fm! nil (progn))\n\nWhat needs to change: Macro call that should be transformed by FM!", "input": "(fm! nil (progn))", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(append-at-end nil :key nil)\n\nProblem: Macro call that should be transformed by APPEND-AT-END", "input": "(append-at-end nil :key nil)", "output": "(defmacro APPEND-AT-END ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-slots nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-SLOTS", "input": "(with-slots nil\n :key\n nil)", "output": "(defmacro WITH-SLOTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(export-class\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by EXPORT-CLASS", "input": "(export-class\n 'lol-gen::some-name)", "output": "(defmacro EXPORT-CLASS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(delete-from nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DELETE-FROM", "input": "(delete-from nil\n :key\n nil)", "output": "(defmacro delete-from (table &body clauses)\n `(make-statement :delete-from\n ,(expand-expression table) ,@clauses))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(->> 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by ->>", "input": "(->> 'lol-gen::some-name)", "output": "(defmacro ->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(the-kids)\n\nPattern to recognize: Macro call that should be transformed by THE-KIDS", "input": "(the-kids)", "output": "(defmacro the-kids (&rest kids)\n `(let ((*parent* self))\n (packed-flat! ,@kids)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dlet nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DLET", "input": "(dlet nil\n (progn))", "output": "(defmacro DLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-active-layers nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-ACTIVE-LAYERS", "input": "(with-active-layers nil\n nil)", "output": "(defmacro WITH-ACTIVE-LAYERS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(count-of nil)\n\nProblem: Macro call that should be transformed by COUNT-OF", "input": "(count-of nil)", "output": "(defmacro COUNT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is-true 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by IS-TRUE", "input": "(is-true 'lol-gen::some-name)", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dotimes (quote lol-gen::some-name))\n\nWrite a macro that addresses: Macro call that should be transformed by DOTIMES", "input": "(dotimes (quote lol-gen::some-name))", "output": "(defmacro DOTIMES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(for 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by FOR", "input": "(for 'lol-gen::some-name)", "output": "(defmacro for (update-type &key of nowait skip-locked)\n (let ((ident-list (if (keywordp of)\n `(list ,of)\n `(quote ,of))))\n `(make-clause :updatability ,update-type :of ,ident-list :nowait ,nowait :skip-locked ,skip-locked)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(some-> nil :key nil)\n\nProblem: Macro call that should be transformed by SOME->", "input": "(some-> nil :key nil)", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(accumulating-to 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ACCUMULATING-TO", "input": "(accumulating-to 'lol-gen::some-name)", "output": "(defmacro ACCUMULATING-TO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fbindrec* nil)\n\nWhat needs to change: Macro call that should be transformed by FBINDREC*", "input": "(fbindrec* nil)", "output": "(defmacro fbindrec* (bindings &body body &environment *lexenv*)\n \"Like `fbindrec`, but the function defined in each binding can be\nused in successive bindings.\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbindrec* `(locally ,@body)))\n (mvlet* ((env env-decls binds lambdas (analyze-fbinds bindings *lexenv*))\n (simple complex lambda unref\n (partition-fbinds (append binds lambdas)\n body))\n (temps (mapcar (op (gensym (string (first _)))) complex))\n (body decls (parse-body body))\n (simple-decls complex-decls lambda-decls others\n (partition-declarations-by-kind simple complex lambda decls)))\n `(let\n ;; Use dummies when we can (with ensure-function).\n ,(loop for (var init) in env\n collect (if (and (listp init)\n (eql (car init) 'ensure-function))\n `(,var #'invalid)\n var))\n ,@(unsplice (and env-decls `(declare ,@env-decls)))\n (comment \"fbind: Simple bindings\")\n (fbind ,simple\n ,@simple-decls\n (comment \"fbind: Temps for complex bindings\")\n (let ,(loop for temp in temps collect `(,temp #'invalid))\n (declare ,@(loop for temp in temps collect `(function ,temp)))\n (flet ,(loop for (name nil) in complex\n for temp in temps\n collect (build-bind/ftype name temp complex-decls env))\n ,@complex-decls\n (comment \"fbind: Lambdas\")\n (labels (,@(loop for (name lambda) in lambda\n collect `(,name ,@(cdr lambda))))\n ,@lambda-decls\n (comment \"fbind: Interleave unreferenced and complex bindings in order.\")\n ,@(remove nil\n (loop for (name nil) in bindings\n append (or (loop for (uname init) in unref\n if (eql uname name)\n return (list init))\n (loop for (cname init) in complex\n for temp in temps\n if (eql cname name)\n return `((setf ,temp (ensure-function ,init)))))))\n (comment \"fbind: Set the `env` variables for the lambdas\")\n (setf ,@(apply #'append env))\n (locally ,@others\n ,@body))))))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.79} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(iterate nil (progn))\n\nProblem: Macro call that should be transformed by ITERATE", "input": "(iterate nil (progn))", "output": "(defmacro ITERATE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(atypecase nil)\n\nProblem: Macro call that should be transformed by ATYPECASE", "input": "(atypecase nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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", "input": "(resolving\n nil\n (progn))", "output": "(defmacro RESOLVING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(dispatch-case-error)\n\nPattern to recognize: Macro call that should be transformed by DISPATCH-CASE-ERROR", "input": "(dispatch-case-error)", "output": "(defmacro dispatch-case-error (&key type datum &environment env)\n (let ((%matched-types (macroexpand-1 'matched-types env)))\n `(error 'dispatch-case-error\n :expected-type ,type\n :datum ,datum\n :matched-types ',(butlast %matched-types))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-active-layers 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-ACTIVE-LAYERS", "input": "(with-active-layers 'lol-gen::some-name)", "output": "(defmacro WITH-ACTIVE-LAYERS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(unwind-protect nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by UNWIND-PROTECT", "input": "(unwind-protect nil\n nil)", "output": "(defmacro UNWIND-PROTECT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(false nil (progn))\n\nIssue: Macro call that should be transformed by FALSE", "input": "(false nil (progn))", "output": "(defmacro false (form &optional description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(false ,form)\n :value-form ',form\n :body (lambda () ,form)\n :expected 'NIL\n :comparison 'geq\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do-symbols (quote lol-gen::some-name))\n\nIssue: Macro call that should be transformed by DO-SYMBOLS", "input": "(do-symbols (quote lol-gen::some-name))", "output": "(defmacro DO-SYMBOLS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(c?_\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by C?_", "input": "(c?_\n nil\n (progn))", "output": "(defmacro c?_ (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :lazy t\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(rte-ecase nil)\n\nProblem: Macro call that should be transformed by RTE-ECASE", "input": "(rte-ecase nil)", "output": "(defmacro RTE-ECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(rem-bops 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by REM-BOPS", "input": "(rem-bops 'lol-gen::some-name)", "output": "(defmacro REM-BOPS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(group-by nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by GROUP-BY", "input": "(group-by nil :key nil)", "output": "(defmacro GROUP-BY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(string-case nil)\n\nPattern to recognize: Macro call that should be transformed by STRING-CASE", "input": "(string-case nil)", "output": "(defmacro STRING-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(selector nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SELECTOR", "input": "(selector nil\n (progn))", "output": "(defmacro SELECTOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(modf nil (progn))\n\nIssue: Macro call that should be transformed by MODF", "input": "(modf nil (progn))", "output": "(defmacro modf (place value &rest more &environment env)\n \"Make a new object \\(which may use some of the old object) such that PLACE\nevaluates to VALUE.\n\nMORE should have the form...\n\nMORE : NIL\n | (TEMPORARY-BINDING ANOTHER-MODF-PLACE ANOTHER-VALUE . MORE)\n\nUse it to specify a temporary binding for the new object created which will be\nused in the subsequence MODF-PLACE NEW-VALUE pairs until the end of the MODF\nform.\"\n (if more\n (destructuring-bind (next-symbol next-place next-value &rest next-more) more\n `(let ((,next-symbol ,(modf-expand value place nil env)))\n (modf ,next-place ,next-value ,@next-more)))\n (modf-expand value place nil env)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(unionf nil (progn))\n\nProblem: Macro call that should be transformed by UNIONF", "input": "(unionf nil (progn))", "output": "(defmacro UNIONF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(summing\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by SUMMING", "input": "(summing\n nil\n (progn))", "output": "(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))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Generate a defmacro form that transforms code like this:\n(html5)\n\nPattern to recognize: Macro call that should be transformed by HTML5", "input": "(html5)", "output": "(defmacro html5 (&rest tags)\n `(with-doctype :html5\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(var 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by VAR", "input": "(var 'lol-gen::some-name)", "output": "(defmacro VAR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(is-expand nil nil)", "output": "(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))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "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*", "input": "(match2* common-lisp:nil\n common-lisp:nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-guessing-encoder)\n\nPattern to recognize: Macro call that should be transformed by WITH-GUESSING-ENCODER", "input": "(with-guessing-encoder)", "output": "(defmacro with-guessing-encoder (&body body)\n `(with-local-encoder (use-guessing-encoder)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(left nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LEFT", "input": "(left nil :key nil)", "output": "(defmacro left (parser &rest parsers)\n \"Combination of parsers yielding the result of the leftmost one.\"\n `(<* ,parser ,@parsers))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-interface)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-INTERFACE", "input": "(define-interface)", "output": "(defmacro DEFINE-INTERFACE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(if-and-let* nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IF-AND-LET*", "input": "(if-and-let* nil\n :key\n nil)", "output": "(defmacro if-and-let* (bindings &body (then-form &optional else-form))\n \"Like `and-let*', but with an `else' clause.\nNote that unlike `if-let*', the variables in BINDINGS are only bound\nfor THEN-FORM.\"\n (with-unique-names (block-name)\n `(block ,block-name\n (and-let* ,bindings\n (return-from ,block-name ,then-form))\n ,else-form)))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(upper nil)\n\nProblem: Macro call that should be transformed by UPPER", "input": "(upper nil)", "output": "(defmacro upper (self &optional (type t))\n `(container-typed ,self ',type))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defmacro nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFMACRO", "input": "(defmacro nil (progn))", "output": "(defmacro DEFMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(destructuring-case nil)\n\nWhat needs to change: Macro call that should be transformed by DESTRUCTURING-CASE", "input": "(destructuring-case nil)", "output": "(defmacro DESTRUCTURING-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(without-recursion nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITHOUT-RECURSION", "input": "(without-recursion nil\n :key\n nil)", "output": "(defmacro without-recursion ((&key) &body body)\n \"If BODY calls itself, at any depth, signal a (continuable) error of\ntype `recursion-forbidden'.\"\n (with-unique-names (recursion-id)\n `(progn\n (when (member ',recursion-id *recursions*)\n (cerror \"Recurse anyway.\"\n 'recursion-forbidden\n :form ',body))\n (let ((*recursions* (cons ',recursion-id *recursions*)))\n (declare (dynamic-extent *recursions*))\n ,@body))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dreletf* nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DRELETF*", "input": "(dreletf* nil\n nil)", "output": "(defmacro DRELETF* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(-> nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by ->", "input": "(-> nil :key nil)", "output": "(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)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(count-of 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COUNT-OF", "input": "(count-of 'lol-gen::some-name)", "output": "(defmacro COUNT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-open-file 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-OPEN-FILE", "input": "(with-open-file 'lol-gen::some-name)", "output": "(defmacro WITH-OPEN-FILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-truncated-stack nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-TRUNCATED-STACK", "input": "(with-truncated-stack nil\n (progn))", "output": "(defmacro with-truncated-stack (() &body body)\n `(stack-truncator (lambda () ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n;; Functions that build code also need gensyms for hygiene\n(defun build-setter (var)\n (let ((g (gensym)))\n `(lambda (,g)\n (setf ,var ,g))))\n;; Gensym boilerplate in code-generating functions\n\nIssue: Functions that generate code also need gensyms \u2014 want same G! prefix convention extended to defun", "input": ";; Functions that build code also need gensyms for hygiene\n(defun build-setter (var)\n (let ((g (gensym)))\n `(lambda (,g)\n (setf ,var ,g))))\n;; Gensym boilerplate in code-generating functions", "output": "(defmacro defun! (name args &body body)\n (let ((syms (remove-duplicates\n (remove-if-not #'g!-symbol-p\n (flatten body)))))\n (multiple-value-bind (body declarations docstring)\n (parse-body body :documentation t)\n `(defun ,name ,args\n ,@(when docstring\n (list docstring))\n ,@declarations\n (let ,(mapcar (lambda (s)\n `(,s (gensym ,(subseq (symbol-name s)\n 2))))\n syms)\n ,@body)))))", "category": "capture-management", "technique": "gensym,code-walking", "complexity": "intermediate", "quality_score": 0.975} {"instruction": "Generate a defmacro form that transforms code like this:\n(js-inline nil nil)\n\nPattern to recognize: Macro call that should be transformed by JS-INLINE", "input": "(js-inline nil nil)", "output": "(defmacro JS-INLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(c?+n\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by C?+N", "input": "(c?+n\n nil\n (progn))", "output": "(defmacro c?+n (&body body)\n `(make-c-dependent\n :inputp t\n :code ',body\n :value-state :unevaluated\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-walker-handler-lexical-environment\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT", "input": "(with-walker-handler-lexical-environment\n nil)", "output": "(defmacro WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-unique-js-names nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-UNIQUE-JS-NAMES", "input": "(with-unique-js-names nil :key nil)", "output": "(defmacro WITH-UNIQUE-JS-NAMES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defparameter nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPARAMETER", "input": "(defparameter nil nil)", "output": "(defmacro DEFPARAMETER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defproxy nil)\n\nIssue: Macro call that should be transformed by DEFPROXY", "input": "(defproxy nil)", "output": "(defmacro defproxy (name)\n \"Define node derived from proxy\"\n `(progn\n (defclass# ,name (proxy) (values subnodes parent))\n (make-instance# ,name () ())))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(count-of nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by COUNT-OF", "input": "(count-of nil\n (progn))", "output": "(defmacro COUNT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-yield\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-YIELD", "input": "(with-yield\n nil)", "output": "(defmacro WITH-YIELD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defun nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DEFUN", "input": "(defun nil :key nil)", "output": "(defmacro DEFUN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(multiple-value-setq nil nil)\n\nProblem: Macro call that should be transformed by MULTIPLE-VALUE-SETQ", "input": "(multiple-value-setq nil nil)", "output": "(defmacro MULTIPLE-VALUE-SETQ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ecase-using nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by ECASE-USING", "input": "(ecase-using nil\n (progn))", "output": "(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)))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(gen-lambda nil)\n\nIssue: Macro call that should be transformed by GEN-LAMBDA", "input": "(gen-lambda nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(slet nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SLET", "input": "(slet nil\n :key\n nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do+\n nil\n nil)\n\nIssue: Macro call that should be transformed by DO+", "input": "(do+\n nil\n nil)", "output": "(defmacro do+ (&body body)\n \"High-level, extensible iteration construct. Refer to the manual for syntax and semantics.\"\n `(do+/internal nil ,@body))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(make-$instance nil)\n\nPattern to recognize: Macro call that should be transformed by MAKE-$INSTANCE", "input": "(make-$instance nil)", "output": "(defmacro MAKE-$INSTANCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(select-dao nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SELECT-DAO", "input": "(select-dao nil\n nil)", "output": "(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))))))))))", "category": "capture-management", "technique": "macrolet,once-only,gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-foreign-objects nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-FOREIGN-OBJECTS", "input": "(with-foreign-objects nil)", "output": "(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)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.815} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(some-<> 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by SOME-<>", "input": "(some-<> 'lol-gen::some-name)", "output": "(defmacro SOME-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-foreign-objects nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-FOREIGN-OBJECTS", "input": "(with-foreign-objects nil\n (progn))", "output": "(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)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(pop nil)\n\nIssue: Macro call that should be transformed by POP", "input": "(pop nil)", "output": "(defmacro POP ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(time 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by TIME", "input": "(time 'lol-gen::some-name)", "output": "(defmacro TIME ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(local)\n\nWhat needs to change: Macro call that should be transformed by LOCAL", "input": "(local)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8274999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(eval-always)\n\nIssue: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(gather-result nil)\n\nWhat needs to change: Macro call that should be transformed by GATHER-RESULT", "input": "(gather-result nil)", "output": "(defmacro GATHER-RESULT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(is-false 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by IS-FALSE", "input": "(is-false 'lol-gen::some-name)", "output": "(defmacro is-false (condition &rest reason-args)\n \"Generates a pass if CONDITION returns false, generates a\n failure otherwise. Like IS-TRUE, and unlike IS, IS-FALSE does\n not inspect CONDITION to determine what reason to give it case\n of test failure\"\n (with-gensyms (value)\n `(let ((,value ,condition))\n (if ,value\n (process-failure ',condition\n ,@(or reason-args\n `(\"~S returned the value ~S, which is true\" ',condition ,value)))\n (add-result 'test-passed :test-expr ',condition)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "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->", "input": "(some-> nil :key nil)", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lret 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by LRET", "input": "(lret 'lol-gen::some-name)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "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", "input": "(match nil\n (progn))", "output": "(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)))))))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(bcond\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by BCOND", "input": "(bcond\n nil\n nil)", "output": "(defmacro bcond (&body clauses)\n \"Scheme's extended COND.\n\nThis is exactly like COND, except for clauses having the form\n\n (test :=> recipient)\n\nIn that case, if TEST evaluates to a non-nil result, then RECIPIENT, a\nfunction, is called with that result, and the result of RECIPIENT is\nreturn as the value of the `cond`.\n\nAs an extension, a clause like this:\n\n (test :=> var ...)\n\nCan be used as a shorthand for\n\n (test :=> (lambda (var) ...))\n\nThe name `bcond' for a \u201cbinding cond\u201d goes back at least to the days\nof the Lisp Machines. I do not know who was first to use it, but the\noldest examples I have found are by Michael Parker and Scott L.\nBurson.\"\n (flet ((send-clause? (clause)\n (let ((second (second clause)))\n (and (symbolp second)\n (string= second :=>))))\n (parse-send-clause (clause)\n (destructuring-bind (test => . body) clause\n (declare (ignore =>))\n (cond ((null body) (error \"Missing clause\"))\n ((null (rest body))\n (values test (car body)))\n (t (destructuring-bind (var . body) body\n (let ((fn `(lambda (,var) ,@body)))\n (values test fn))))))))\n ;; Note that we expand into `cond' rather than `if' so we don't\n ;; have to handle tests without bodies.\n (cond ((null clauses) nil)\n ((member-if #'send-clause? clauses)\n (let* ((tail (member-if #'send-clause? clauses))\n (preceding (ldiff clauses tail))\n (clause (car tail))\n (clauses (cdr tail)))\n (multiple-value-bind (test fn)\n (parse-send-clause clause)\n (with-gensyms (tmp)\n `(cond ,@preceding\n (t (if-let1 ,tmp ,test\n (funcall ,fn ,tmp)\n (bcond ,@clauses))))))))\n (t `(cond ,@clauses)))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(as-> nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by AS->", "input": "(as-> nil (progn))", "output": "(defmacro AS-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(def-shadow-type-constructor nil (progn))", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(print-unreadable-object 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by PRINT-UNREADABLE-OBJECT", "input": "(print-unreadable-object 'lol-gen::some-name)", "output": "(defmacro PRINT-UNREADABLE-OBJECT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defpattern nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFPATTERN", "input": "(defpattern nil\n (progn))", "output": "(defmacro DEFPATTERN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(some-> 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by SOME->", "input": "(some-> 'lol-gen::some-name)", "output": "(defmacro some-> (init &body exps) (arrow-macro init exps nil t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fn 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by FN", "input": "(fn 'lol-gen::some-name)", "output": "(defmacro FN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(do-for 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DO-FOR", "input": "(do-for 'lol-gen::some-name)", "output": "(defmacro DO-FOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(c?once)\n\nPattern to recognize: Macro call that should be transformed by C?ONCE", "input": "(c?once)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defpattern nil\n nil)\n\nIssue: Macro call that should be transformed by DEFPATTERN", "input": "(defpattern nil\n nil)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(all nil nil)\n\nWhat needs to change: Macro call that should be transformed by ALL", "input": "(all nil nil)", "output": "(defmacro all (parser &rest parsers)\n \"Combination of parsers yielding all results as a list.\"\n `(<*> ,parser ,@parsers))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(collecting 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by COLLECTING", "input": "(collecting 'lol-gen::some-name)", "output": "(defmacro COLLECTING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(current-decoder nil)\n\nIssue: Macro call that should be transformed by CURRENT-DECODER", "input": "(current-decoder nil)", "output": "(defmacro current-decoder (&rest keys)\n \"Capture current values of custom variables and return a custom\ndecoder which restores these values in its dynamic environment.\"\n (let (exterior-bindings customizations)\n (flet ((collect (key var)\n (let ((exterior (gensym)))\n (push (list exterior var) exterior-bindings)\n (push exterior customizations)\n (push key customizations))))\n (if keys\n (loop for key in keys\n do (collect key (custom-key-to-variable key)))\n (loop-on-custom (key var)\n do (collect key var)))\n `(let ,exterior-bindings\n (custom-decoder ,@customizations)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-rules nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-RULES", "input": "(with-rules nil\n nil)", "output": "(defmacro WITH-RULES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(-<> 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by -<>", "input": "(-<> 'lol-gen::some-name)", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-symbol-macro nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-SYMBOL-MACRO", "input": "(define-symbol-macro nil (progn))", "output": "(defmacro DEFINE-SYMBOL-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(pmap nil (progn))\n\nIssue: Macro call that should be transformed by PMAP", "input": "(pmap nil (progn))", "output": "(defmacro pmap (f parser)\n \"Similar to `fmap', but this transforms a parser into another one, altering\nits inner result if it happened to be successful.\"\n `(lambda (offset)\n (fmap ,f (funcall ,parser offset))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(execute nil (progn))\n\nIssue: Macro call that should be transformed by EXECUTE", "input": "(execute nil (progn))", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(all-values\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ALL-VALUES", "input": "(all-values\n 'lol-gen::some-name)", "output": "(defmacro ALL-VALUES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(match2 common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by MATCH2", "input": "(match2 common-lisp:nil\n :key\n common-lisp:nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ltbdd-with-new-hash nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by LTBDD-WITH-NEW-HASH", "input": "(ltbdd-with-new-hash nil\n :key\n nil)", "output": "(defmacro LTBDD-WITH-NEW-HASH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(*> 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by *>", "input": "(*> 'lol-gen::some-name)", "output": "(defmacro *> (parser &rest parsers)\n \"Combination of parsers yielding the result of the rightmost one.\"\n (let ((offset (gensym \"*>-OFFSET\")))\n `(lambda (,offset)\n ,(reduce (lambda (i p)\n (let ((res (gensym \"*>-RES\"))\n (next (gensym \"*>-NEXT\")))\n `(multiple-value-bind (,res ,next) ,i\n (if (ok? ,res)\n (funcall ,p ,next)\n (fail ,next)))))\n parsers\n :initial-value `(funcall ,parser ,offset)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(fbind nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by FBIND", "input": "(fbind nil\n nil)", "output": "(defmacro fbind (bindings &body body &environment *lexenv*)\n \"Binds values in the function namespace.\n\nThat is,\n (fbind ((fn (lambda () ...))))\n \u2261 (flet ((fn () ...))),\n\nexcept that a bare symbol in BINDINGS is rewritten as (symbol\nsymbol).\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbind `(locally ,@body)))\n ;; When possible (if the binding expands to a simple\n ;; let-over-lambda), we hoist the bindings to the top and bind\n ;; the lambda directly with flet.\n\n ;; Failing that, if we know that the function is never directly\n ;; dereferenced with sharp-quote, we can bind with `macrolet'\n ;; instead of `flet', leaving no runtime overhead vs. `funcall'.\n (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))\n (macro-vars\n (merely-syntactic-functions (mapcar #'first bindings)\n body\n *lexenv*))\n (vars (mapcar #'first bindings))\n (exprs (mapcar #'second bindings))\n (temps (mapcar #'string-gensym vars))\n (body decls (parse-body body)))\n `(let ,env\n ,@(unsplice (and env-decls `(declare ,@env-decls)))\n (comment \"fbind: Hidden variable bindings to close over.\")\n (let ,(loop for temp in temps\n for expr in exprs\n collect `(,temp (ensure-function ,expr)))\n ,@(when temps\n (unsplice\n `(declare (function ,@temps))))\n (comment \"fbind: Hidden variable bindings for function values.\")\n (flet (,@(loop for (name lambda) in lambdas\n collect `(,name ,@(cdr lambda)))\n ,@(loop for var in vars\n for temp in temps\n unless (member var macro-vars)\n collect (build-bind/ftype var temp decls env)))\n #-sbcl (declare (inline ,@(set-difference vars macro-vars)))\n ,@decls\n (comment \"fbind: Functions that might be sharp-quoted.\")\n (macrolet (,@(loop for var in vars\n for temp in temps\n when (member var macro-vars)\n collect `(,var\n (&rest args)\n (list* 'funcall ',temp args))))\n (comment \"fbind: Macros for functions provably never sharp-quoted.\")\n ,@body))))))", "category": "control-flow", "technique": "macrolet,gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(v-defstruct nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by V-DEFSTRUCT", "input": "(v-defstruct nil\n nil)", "output": "(defmacro v-defstruct (name context &body slots)\n `(define-vari-struct ,name ,context ,@slots))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(destructuring-case nil)\n\nProblem: Macro call that should be transformed by DESTRUCTURING-CASE", "input": "(destructuring-case nil)", "output": "(defmacro destructuring-case (keyform &body clauses)\n \"DESTRUCTURING-CASE, -CCASE, and -ECASE are a combination of CASE and DESTRUCTURING-BIND.\nKEYFORM must evaluate to a CONS.\n\nClauses are of the form:\n\n ((CASE-KEYS . DESTRUCTURING-LAMBDA-LIST) FORM*)\n\nThe clause whose CASE-KEYS matches CAR of KEY, as if by CASE, CCASE, or ECASE,\nis selected, and FORMs are then executed with CDR of KEY is destructured and\nbound by the DESTRUCTURING-LAMBDA-LIST.\n\nExample:\n\n (defun dcase (x)\n (destructuring-case x\n ((:foo a b)\n (format nil \\\"foo: ~S, ~S\\\" a b))\n ((:bar &key a b)\n (format nil \\\"bar: ~S, ~S\\\" a b))\n (((:alt1 :alt2) a)\n (format nil \\\"alt: ~S\\\" a))\n ((t &rest rest)\n (format nil \\\"unknown: ~S\\\" rest))))\n\n (dcase (list :foo 1 2)) ; => \\\"foo: 1, 2\\\"\n (dcase (list :bar :a 1 :b 2)) ; => \\\"bar: 1, 2\\\"\n (dcase (list :alt1 1)) ; => \\\"alt: 1\\\"\n (dcase (list :alt2 2)) ; => \\\"alt: 2\\\"\n (dcase (list :quux 1 2 3)) ; => \\\"unknown: 1, 2, 3\\\"\n\n (defun decase (x)\n (destructuring-case x\n ((:foo a b)\n (format nil \\\"foo: ~S, ~S\\\" a b))\n ((:bar &key a b)\n (format nil \\\"bar: ~S, ~S\\\" a b))\n (((:alt1 :alt2) a)\n (format nil \\\"alt: ~S\\\" a))))\n\n (decase (list :foo 1 2)) ; => \\\"foo: 1, 2\\\"\n (decase (list :bar :a 1 :b 2)) ; => \\\"bar: 1, 2\\\"\n (decase (list :alt1 1)) ; => \\\"alt: 1\\\"\n (decase (list :alt2 2)) ; => \\\"alt: 2\\\"\n (decase (list :quux 1 2 3)) ; =| error\n\"\n (expand-destructuring-case keyform clauses 'case))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(special-symbol-progv nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SPECIAL-SYMBOL-PROGV", "input": "(special-symbol-progv nil\n (progn))", "output": "(defmacro SPECIAL-SYMBOL-PROGV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda-coro\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by LAMBDA-CORO", "input": "(lambda-coro\n nil\n :key\n nil)", "output": "(defmacro LAMBDA-CORO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make-window-or-instance nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-WINDOW-OR-INSTANCE", "input": "(make-window-or-instance nil (progn))", "output": "(defmacro MAKE-WINDOW-OR-INSTANCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(in-suite* nil)\n\nProblem: Macro call that should be transformed by IN-SUITE*", "input": "(in-suite* nil)", "output": "(defmacro in-suite* (suite-name &key in)\n \"Just like in-suite, but silently creates missing suites.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (%in-suite ,suite-name :in ,in :fail-on-error nil)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(esc nil)\n\nProblem: Macro call that should be transformed by ESC", "input": "(esc nil)", "output": "(defmacro esc (&rest forms)\n `(list\n ,@(loop for form in forms\n collect (%escape-string-form form))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c?dbg\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by C?DBG", "input": "(c?dbg\n nil\n :key\n nil)", "output": "(defmacro c?dbg (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :debug t\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(accumulating-to-and-returning nil)\n\nWhat needs to change: Macro call that should be transformed by ACCUMULATING-TO-AND-RETURNING", "input": "(accumulating-to-and-returning nil)", "output": "(defmacro ACCUMULATING-TO-AND-RETURNING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-train nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFINE-TRAIN", "input": "(define-train nil\n :key\n nil)", "output": "(defmacro define-train (name args &body body)\n \"Define a higher-order function and its compiler macro at once.\n\nWhen defining a higher-order function it is often a good idea to\nwrite a compiler macro so compilers can inline the resulting lambda\nform.\n\nFor the special case of a fixed-arity function that only takes other\nfunctions as arguments, you can use `define-train' to define the\nfunction and the compiler macro in one go. The catch is that you have\nto write the single definition as a macro.\n\nE.g., if `complement' did not exist, you could define it like so:\n\n (define-train complement (fn)\n `(lambda (&rest args)\n (not (apply ,fn args))))\n\nBesides providing an implicit compiler macro, `define-train' also\ninserts the proper declarations to ensure the compiler recognizes the\nfunction arguments as functions, avoiding runtime type checks.\n\nThe term \\\"train\\\" is from J.\"\n (multiple-value-bind (body decls docstring)\n (parse-body body :documentation t)\n `(progn\n (define-compiler-macro ,name ,args\n ,@decls\n (rebinding-functions ,args\n ,@body))\n (defun ,name ,args\n ,@(unsplice docstring)\n (macrolet ((,name ,args\n ,@decls\n (rebinding-functions ,args\n ,@body)))\n (,name ,@args))))))", "category": "anaphoric", "technique": "compiler-macro,macrolet,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.945} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(aecase nil)\n\nWhat needs to change: Macro call that should be transformed by AECASE", "input": "(aecase nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(and-let nil)\n\nIssue: Macro call that should be transformed by AND-LET", "input": "(and-let nil)", "output": "(defmacro and-let (var &rest args)\n \"Like AND. VAR will be bound to the value of the previous AND form\"\n (cond ((null args) t)\n ((null (cdr args)) (car args))\n (t `(when-let (,var ,(car args))\n (and ,@(cdr args))))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(-<>> nil (progn))\n\nProblem: Macro call that should be transformed by -<>>", "input": "(-<>> nil (progn))", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(destructuring-bind () (progn))\n\nWhat needs to change: Macro call that should be transformed by DESTRUCTURING-BIND", "input": "(destructuring-bind () (progn))", "output": "(defmacro DESTRUCTURING-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda-cmatch*)\n\nIssue: Macro call that should be transformed by LAMBDA-CMATCH*", "input": "(lambda-cmatch*)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "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 -<>>", "input": "(-<>> nil)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-stemcell-infer-hook nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-STEMCELL-INFER-HOOK", "input": "(with-stemcell-infer-hook nil\n :key\n nil)", "output": "(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)))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ensure-transaction-with-isolation-level nil\n (progn))\n\nProblem: Macro call that should be transformed by ENSURE-TRANSACTION-WITH-ISOLATION-LEVEL", "input": "(ensure-transaction-with-isolation-level nil\n (progn))", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-html-output 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WITH-HTML-OUTPUT", "input": "(with-html-output 'lol-gen::some-name)", "output": "(defmacro with-html-output ((var &optional stream\n &rest rest\n &key prologue indent)\n &body body)\n \"Transform the enclosed BODY consisting of HTML as s-expressions\ninto Lisp code to write the corresponding HTML as strings to VAR -\nwhich should either hold a stream or which'll be bound to STREAM if\nsupplied.\"\n (declare (ignore prologue))\n (multiple-value-bind (declarations forms) (extract-declarations body)\n `(let ((,var ,(or stream var)))\n ,@declarations\n (check-type ,var stream)\n (macrolet ((htm (&body body)\n `(with-html-output (,',var nil :prologue nil :indent ,,indent)\n ,@body))\n (fmt (&rest args)\n `(format ,',var ,@args))\n (esc (thing)\n (with-unique-names (result)\n `(let ((,result ,thing))\n (when ,result (write-string (escape-string ,result) ,',var)))))\n (str (thing)\n (with-unique-names (result)\n `(let ((,result ,thing))\n (when ,result (princ ,result ,',var))))))\n ,@(apply 'tree-to-commands forms var rest)))))", "category": "dsl", "technique": "macrolet,recursive-expansion", "complexity": "advanced", "quality_score": 0.9249999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(xor nil (progn))\n\nIssue: Macro call that should be transformed by XOR", "input": "(xor nil (progn))", "output": "(defmacro xor (&rest datums)\n \"Evaluates its arguments one at a time, from left to right. If more than one\nargument evaluates to a true value no further DATUMS are evaluated, and NIL is\nreturned as both primary and secondary value. If exactly one argument\nevaluates to true, its value is returned as the primary value after all the\narguments have been evaluated, and T is returned as the secondary value. If no\narguments evaluate to true NIL is returned as primary, and T as secondary\nvalue.\"\n (with-gensyms (xor tmp true)\n `(let (,tmp ,true)\n (declare (ignorable ,tmp))\n (block ,xor\n ,@(mapcar (lambda (datum)\n `(if (setf ,tmp ,datum)\n (if ,true\n (return-from ,xor (values nil nil))\n (setf ,true ,tmp))))\n datums)\n (return-from ,xor (values ,true t))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nlet nil\n nil)\n\nIssue: Macro call that should be transformed by NLET", "input": "(nlet nil\n nil)", "output": "(defmacro NLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ignore-some-conditions 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by IGNORE-SOME-CONDITIONS", "input": "(ignore-some-conditions 'lol-gen::some-name)", "output": "(defmacro ignore-some-conditions ((&rest conditions) &body body)\n \"Similar to CL:IGNORE-ERRORS but the (unevaluated) CONDITIONS\nlist determines which specific conditions are to be ignored.\"\n `(handler-case\n (progn ,@body)\n ,@(loop for condition in conditions collect\n `(,condition (c) (values nil c)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(-> nil)\n\nPattern to recognize: Macro call that should be transformed by ->", "input": "(-> nil)", "output": "(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)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(undefreply nil :key nil)\n\nIssue: Macro call that should be transformed by UNDEFREPLY", "input": "(undefreply nil :key nil)", "output": "(defmacro UNDEFREPLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(export-accessors\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by EXPORT-ACCESSORS", "input": "(export-accessors\n 'lol-gen::some-name)", "output": "(defmacro EXPORT-ACCESSORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(example\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by EXAMPLE", "input": "(example\n 'lol-gen::some-name)", "output": "(defmacro example (&body body)\n \"Like `comment'.\"\n `(comment ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lazy-seq nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by LAZY-SEQ", "input": "(lazy-seq nil (progn))", "output": "(defmacro lazy-seq (head &optional tail)\n \"Creates a `LAZY-SEQ' where HEAD is the first element in the\n sequence and TAIL is a form which computes the remainder of the\n sequence. TAIL is wrapped in a function that stores the result of\n evaluating FORM, the first time it is invoked, and returns the\n stored result in future invocations.\"\n\n `(make-lazy-seq :head ,head :tail (thunk ,tail)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-fixture-restore nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-FIXTURE-RESTORE", "input": "(define-fixture-restore nil\n (progn))", "output": "(defmacro define-fixture-restore (name args &body body)\n `(progn (setf (gethash ',name *fixture-restores*)\n (lambda ,args ,@body))\n ',name))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(defclause-sequence nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFCLAUSE-SEQUENCE", "input": "(defclause-sequence nil (progn))", "output": "(defmacro defclause-sequence (element-name index-name\n &key access-fn size-fn\n element-type sequence-type\n element-doc-string index-doc-string)\n \"A simple way to define a FOR-like &sequence clause.\"\n\n;Package subtlety: FOR should be in the same package as the\n;element-name or index-name.\"\n (let* ((seq-for (when element-name\n (intern (symbol-name 'for) (symbol-package element-name))))\n (seq-def (when element-name\n `(defclause-driver\n (,seq-for var ,element-name seq &sequence)\n ,element-doc-string\n (return-sequence-code :element-var var\n :sequence seq\n :access-fn ,access-fn\n :size-fn ,size-fn\n :element-type ,element-type\n :sequence-type ,sequence-type))))\n #+nil\n (inx-for (when index-name\n (intern (symbol-name 'for) (symbol-package index-name))))\n (inx-def (when index-name\n `(defclause-driver (:for var ,index-name seq &sequence)\n ,index-doc-string\n (if with-index\n (clause-error \"WITH-INDEX keyword should not ~\nbe specified for this clause\")\n (progn\n (setq with-index var)\n (return-sequence-code\n :sequence seq\n :size-fn ,size-fn\n :sequence-type ,sequence-type)))))))\n `(progn ,seq-def ,inx-def)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond->> 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by COND->>", "input": "(cond->> 'lol-gen::some-name)", "output": "(defmacro COND->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(->> nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by ->>", "input": "(->> nil\n (progn))", "output": "(defmacro ->> (init &body exps) (arrow-macro init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(sif nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by SIF", "input": "(sif nil :key nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defclause-sequence nil nil)\n\nProblem: Macro call that should be transformed by DEFCLAUSE-SEQUENCE", "input": "(defclause-sequence nil nil)", "output": "(defmacro defclause-sequence (element-name index-name\n\t\t\t &key access-fn size-fn\n\t\t\t element-type sequence-type\n\t\t\t element-doc-string index-doc-string)\n \"A simple way to define a simple FOR ... &sequence clause\"\n ;; Package subtlety: the FOR should be in the same package as the\n ;; element-name or index-name.\n (let* ((seq-for (if element-name\n\t\t (intern (symbol-name 'for) (symbol-package element-name))))\n\t (seq-def (if element-name\n\t\t `(defclause-driver (,seq-for var ,element-name seq\n\t\t\t\t\t\t &sequence)\n\t\t\t ,element-doc-string\n\t\t\t (return-sequence-code\n\t\t\t :element-var var\n\t\t\t :sequence seq\n\t\t\t :access-fn ,access-fn\n\t\t\t :size-fn ,size-fn\n\t\t\t :element-type ,element-type\n\t\t\t :sequence-type ,sequence-type))))\n\t (inx-for (if index-name\n\t\t (intern (symbol-name 'for) (symbol-package index-name))))\n\t (inx-def (if index-name\n\t\t `(defclause-driver (,inx-for var ,index-name seq\n\t\t\t\t\t\t &sequence)\n\t\t\t ,index-doc-string\n\t\t\t (cond\n\t\t\t (with-index\n\t\t\t (clause-error\n\t\t\t \"WITH-INDEX should not be specified for this clause\"))\n\t\t\t (t\n\t\t\t (setq with-index var)\n\t\t\t (return-sequence-code\n\t\t\t :sequence seq\n\t\t\t :size-fn ,size-fn\n\t\t\t :sequence-type ,sequence-type)))))))\n `(progn ,seq-def ,inx-def)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-html-string)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-HTML-STRING", "input": "(with-html-string)", "output": "(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)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(set-dynamic nil (progn))\n\nIssue: Macro call that should be transformed by SET-DYNAMIC", "input": "(set-dynamic nil (progn))", "output": "(defmacro SET-DYNAMIC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(type common-lisp:nil)", "output": "(defmacro TYPE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(rte-case nil)\n\nProblem: Macro call that should be transformed by RTE-CASE", "input": "(rte-case nil)", "output": "(defmacro RTE-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fmap nil (progn))\n\nProblem: Macro call that should be transformed by FMAP", "input": "(fmap nil (progn))", "output": "(defmacro fmap (f thing)\n \"Apply a pure function to the inner contents of some parsing operation, if the\nparsing itself was successful.\"\n `(multiple-value-bind (res next) ,thing\n (if (failure? res)\n (fail next)\n (values (funcall ,f res) next))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(mvlet* nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by MVLET*", "input": "(mvlet* nil\n :key\n nil)", "output": "(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))))))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(defvar-unbound nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFVAR-UNBOUND", "input": "(defvar-unbound nil\n (progn))", "output": "(defmacro defvar-unbound (var &body (docstring))\n \"Define VAR as if by `defvar' with no init form, and set DOCSTRING\nas its documentation.\n\nI believe the name comes from Edi Weitz.\"\n `(progn\n (defvar ,var)\n (setf (documentation ',var 'variable) ,docstring)\n ',var))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(on-conflict-do-update nil :key nil)\n\nIssue: Macro call that should be transformed by ON-CONFLICT-DO-UPDATE", "input": "(on-conflict-do-update nil :key nil)", "output": "(defmacro on-conflict-do-update (conflict-target update-set &optional where-condition)\n `(make-clause :on-conflict-do-update\n ,conflict-target\n ,update-set\n ,where-condition))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(gathering nil\n nil)\n\nProblem: Macro call that should be transformed by GATHERING", "input": "(gathering nil\n nil)", "output": "(defmacro GATHERING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defmethod nil :key nil)\n\nIssue: Macro call that should be transformed by DEFMETHOD", "input": "(defmethod nil :key nil)", "output": "(defmacro DEFMETHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(compiler-macro-lambda nil\n nil)\n\nProblem: Macro call that should be transformed by COMPILER-MACRO-LAMBDA", "input": "(compiler-macro-lambda nil\n nil)", "output": "(defmacro compiler-macro-lambda (lambda-list &body body)\n (introspect-environment:parse-compiler-macro (gensym \"COMPILER-MACRO-LAMBDA\")\n lambda-list\n body))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(c-assert nil)\n\nPattern to recognize: Macro call that should be transformed by C-ASSERT", "input": "(c-assert nil)", "output": "(defmacro c-assert (assertion &optional places fmt$ &rest fmt-args)\n (declare (ignorable assertion places fmt$ fmt-args))\n #+(or)`(progn) \n `(unless *stop*\n (unless ,assertion\n ,(if fmt$\n `(c-break ,fmt$ ,@fmt-args)\n `(c-break \"failed assertion: ~a\" ',assertion)))))", "category": "control-flow", "technique": "nested-backquote", "complexity": "intermediate", "quality_score": 0.8725} {"instruction": "Generate a defmacro form that transforms code like this:\n(as common-lisp:nil common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by AS", "input": "(as common-lisp:nil common-lisp:nil)", "output": "(defmacro as (type cl:&optional (expr cl:nil expr-supplied-p))\n \"A syntactic convenience for type casting.\n\n (as )\n\nis equivalent to\n\n (the (into ))\n\nand\n\n (as )\n\nis equivalent to\n\n (fn (expr) (the (into expr))).\n\nNote that this may copy the object or allocate memory.\"\n\n (cl:let ((into (cl:ignore-errors (cl:find-symbol \"INTO\" \"COALTON/CLASSES\"))))\n (cl:assert into () \"`as` macro does not have access to `into` yet.\")\n (cl:if expr-supplied-p\n `(the ,type (,into ,expr))\n (alexandria:with-gensyms (lexpr)\n `(fn (,lexpr)\n (the ,type (,into ,lexpr)))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defvar nil)\n\nProblem: Macro call that should be transformed by DEFVAR", "input": "(defvar nil)", "output": "(defmacro DEFVAR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(without-symbol-access)\n\nWrite a macro that addresses: Macro call that should be transformed by WITHOUT-SYMBOL-ACCESS", "input": "(without-symbol-access)", "output": "(defmacro WITHOUT-SYMBOL-ACCESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(update nil nil)\n\nProblem: Macro call that should be transformed by UPDATE", "input": "(update nil nil)", "output": "(defmacro update (place value-form)\n (etypecase place\n (symbol `(setf ,place ,value-form))\n (list\n (let ((result (gensym \"RESULT\"))\n (var (gensym \"VAR\")))\n (lambda-fiddle:with-destructured-lambda-list (:required req :optional opt :rest rest :body body :key key) place\n (let ((rest (or rest body)))\n `(let ((,result ,value-form))\n ;; Convert required into test and POP\n ,@(loop for var in req\n do (assert (and (not (null var)) (symbolp var)))\n collect `(if ,result\n (setf ,var (pop ,result))\n (error \"Not enough arguments to satisfy lambda-list ~a.\" ',place)))\n ;; Convert &OPTIONAL into POP and default.\n ,@(loop for o in opt\n for (var default) = (enlist o)\n do (assert (and (not (null var)) (symbolp var)))\n collect `(setf ,var (or (pop ,result) ,default)))\n ;; If we don't have &REST or &KEY, error if there are some elements left.\n ,@(when (and (not rest) (not (find '&key place)))\n `((when ,result (error \"Too many elements supplied to satisfy lambda-list ~a.\" ',place))))\n ;; Convert &REST by just setting it to the remainder.\n ,@(when rest `((setf ,rest ,result)))\n ;; Convert &KEY into GETF and default.\n ,@(loop for k in key\n for (var default) = (enlist k)\n do (assert (and (not (null var)) (symbolp var)))\n collect `(setf ,var (or (getf ,result ,(intern (string var) :keyword)) ,default)))\n ;; If we have a non-empty &KEY list and don't have &ALLOW-OTHER-KEYS, check the keys.\n ,@(when (and key (not (find '&allow-other-keys place)))\n `((loop for ,var in ,result by #'cddr\n do (unless (find ,var ',(loop for k in key collect (intern (string k) :keyword)))\n (error \"Keyword argument ~s not found in lambda-list ~a.\"\n ,var ',place))))))))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(parse-conjunctive-clauses nil :key nil)\n\nIssue: Macro call that should be transformed by PARSE-CONJUNCTIVE-CLAUSES", "input": "(parse-conjunctive-clauses nil :key nil)", "output": "(defmacro parse-conjunctive-clauses (client region read-name-p &rest args)\n (with-unique-names (clauses next)\n `(prog (,clauses)\n ,next\n (push (do-parse-clause ,client ,region *index* ,read-name-p ,@args)\n ,clauses)\n (when (maybe-parse-token :keywords '(:and))\n (go ,next))\n (return (nreverse ,clauses)))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nest common-lisp:nil common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NEST", "input": "(nest common-lisp:nil common-lisp:nil)", "output": "(defmacro nest (cl:&rest items)\n \"A syntactic convenience for function application. Transform\n\n (nest f g h x)\n\nto\n\n (f (g (h x))).\"\n (cl:assert (cl:<= 2 (cl:list-length items)))\n (cl:let ((last (cl:last items))\n (butlast (cl:butlast items)))\n (cl:reduce (cl:lambda (x acc)\n (cl:list x acc))\n butlast :from-end cl:t :initial-value (cl:first last))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defun-advisable nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFUN-ADVISABLE", "input": "(defun-advisable nil\n :key\n nil)", "output": "(defmacro DEFUN-ADVISABLE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(once-on nil\n nil)\n\nProblem: Macro call that should be transformed by ONCE-ON", "input": "(once-on nil\n nil)", "output": "(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))))))", "category": "anaphoric", "technique": "once-only,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(some-<>> nil\n nil)\n\nProblem: Macro call that should be transformed by SOME-<>>", "input": "(some-<>> nil\n nil)", "output": "(defmacro some-<>> (init &body exps) (diamond-wand init exps t t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(boolean-unless 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by BOOLEAN-UNLESS", "input": "(boolean-unless 'lol-gen::some-name)", "output": "(defmacro boolean-unless (branch &body body &environment env)\n \"Includes some forms based on whether a macroexpand-time branch is false. The\nfirst argument must be a symbol naming a branch in the lexically enclosing\nWITH-BOOLEAN form.\n\\\nIt is an error to use this macro outside the lexical environment established by\nWITH-BOOLEAN.\"\n (cond (*boolean-bypass*\n `(unless ,branch ,@body))\n ((not (member branch (macroexpand-1 '%all-branches% env)))\n (missing-branch branch))\n ((not (macroexpand-1 '%in-branching% env))\n (conditional-error 'unless))\n ((member branch (macroexpand-1 '%true-branches% env))\n `(progn))\n ((= 0 (length body))\n `(progn))\n ((= 1 (length body))\n (car body))\n (t `(progn ,@body))))", "category": "anaphoric", "technique": "nested-backquote,anaphor", "complexity": "advanced", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(alet nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ALET", "input": "(alet nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(mvlet nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by MVLET", "input": "(mvlet nil\n (progn))", "output": "(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))))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(left nil nil)\n\nPattern to recognize: Macro call that should be transformed by LEFT", "input": "(left nil nil)", "output": "(defmacro left (parser &rest parsers)\n \"Combination of parsers yielding the result of the leftmost one.\"\n `(<* ,parser ,@parsers))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-compiler-macro nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-COMPILER-MACRO", "input": "(define-compiler-macro nil\n (progn))", "output": "(defmacro DEFINE-COMPILER-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-boolean nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-BOOLEAN", "input": "(with-boolean nil\n (progn))", "output": "(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)))))))))", "category": "anaphoric", "technique": "symbol-macrolet,macrolet,anaphor", "complexity": "intermediate", "quality_score": 0.8925} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(char-ecase nil)\n\nWhat needs to change: Macro call that should be transformed by CHAR-ECASE", "input": "(char-ecase nil)", "output": "(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)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(<* nil nil)\n\nIssue: Macro call that should be transformed by <*", "input": "(<* nil nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nor nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NOR", "input": "(nor nil :key nil)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(isnt nil nil)\n\nIssue: Macro call that should be transformed by ISNT", "input": "(isnt nil nil)", "output": "(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)))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(when-let nil\n (progn))\n\nProblem: Macro call that should be transformed by WHEN-LET", "input": "(when-let nil\n (progn))", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dreletf* 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DRELETF*", "input": "(dreletf* 'lol-gen::some-name)", "output": "(defmacro DRELETF* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defmacro/ps nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFMACRO/PS", "input": "(defmacro/ps nil\n :key\n nil)", "output": "(defmacro DEFMACRO/PS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(when-match common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by WHEN-MATCH", "input": "(when-match common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro when-match (pattern arg &body body)\n \"Equivalent to (match ARG (PATTERN BODY...)).\"\n `(match ,arg (,pattern ,.body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(if-it nil (progn))\n\nPattern to recognize: Macro call that should be transformed by IF-IT", "input": "(if-it nil (progn))", "output": "(defmacro if-it (test then &optional else)\n \"Like IF. IT is bound to TEST.\"\n `(let ((it ,test))\n (if it ,then ,else)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(without-recursion nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITHOUT-RECURSION", "input": "(without-recursion nil\n (progn))", "output": "(defmacro without-recursion ((&key) &body body)\n \"If BODY calls itself, at any depth, signal a (continuable) error of\ntype `recursion-forbidden'.\"\n (with-unique-names (recursion-id)\n `(progn\n (when (member ',recursion-id *recursions*)\n (cerror \"Recurse anyway.\"\n 'recursion-forbidden\n :form ',body))\n (let ((*recursions* (cons ',recursion-id *recursions*)))\n (declare (dynamic-extent *recursions*))\n ,@body))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(jor nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by JOR", "input": "(jor nil :key nil)", "output": "(defmacro jor (&rest args)\n \"JSON-aware version of `cl:or'.\"\n `(or ,@(loop for arg in args\n collecting `(jwhen ,arg ,arg))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(without-c-dependency\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITHOUT-C-DEPENDENCY", "input": "(without-c-dependency\n 'lol-gen::some-name)", "output": "(defmacro without-c-dependency (&body body)\n ` (let (*depender*)\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(global\n nil\n nil)\n\nIssue: Macro call that should be transformed by GLOBAL", "input": "(global\n nil\n nil)", "output": "(defmacro GLOBAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(when-it nil\n nil)\n\nIssue: Macro call that should be transformed by WHEN-IT", "input": "(when-it nil\n nil)", "output": "(defmacro when-it (test &body body)\n \"Like WHEN. IT is bound to TEST.\"\n `(let ((it ,test))\n (when it\n ,@body)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(defproxymethod nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFPROXYMETHOD", "input": "(defproxymethod nil\n :key\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(select nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SELECT", "input": "(select nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c?_\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by C?_", "input": "(c?_\n nil)", "output": "(defmacro c?_ (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :lazy t\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(static-load-time-value nil (progn))\n\nWhat needs to change: Macro call that should be transformed by STATIC-LOAD-TIME-VALUE", "input": "(static-load-time-value nil (progn))", "output": "(defmacro static-load-time-value\n (form &optional (read-only-p nil read-only-p-supplied?))\n \"Like `load-time-value', but signals an error if it cannot preserve identity.\n\nOn close reading of the standard, in a function that is evaluated but\nnot compiled, it is permissible for implementations to repeatedly\nexecute a `load-time-value' form, and in fact some implementations do\nthis \\(including, at the time of writing, ABCL, CLISP, Allegro and\nLispWorks).\n\nWhen `static-load-time-value' is compiled, it behaves exactly like\n`load-time-value'. Otherwise it conducts a run-time check to ensure\nthat `load-time-value' preserves identity.\"\n ;; Thanks to Jean-Philippe Paradis and Micha\u0142 Herda for helping to\n ;; diagnose and treat the problem here.\n (if *compile-file-truename*\n `(load-time-value ,form\n ,@(and read-only-p-supplied? (list read-only-p)))\n `(progn\n (flet ((fn () (load-time-value (random most-positive-fixnum))))\n (declare (dynamic-extent #'fn) (ignorable #'fn)\n #+LispWorks (notinline fn))\n ;; Do the actual test out of line.\n (test-load-time-value #'fn ',form ',read-only-p))\n (load-time-value ,form\n ,@(and read-only-p-supplied? (list read-only-p))))))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-nconc 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by COLLECT-NCONC", "input": "(collect-nconc 'lol-gen::some-name)", "output": "(defmacro COLLECT-NCONC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(gather-next nil (progn))\n\nProblem: Macro call that should be transformed by GATHER-NEXT", "input": "(gather-next nil (progn))", "output": "(defmacro GATHER-NEXT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda ())\n\nIssue: Macro call that should be transformed by LAMBDA", "input": "(lambda ())", "output": "(defmacro LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make-name-transformer 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-NAME-TRANSFORMER", "input": "(make-name-transformer 'lol-gen::some-name)", "output": "(defmacro MAKE-NAME-TRANSFORMER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(wnotrc nil)\n\nWhat needs to change: Macro call that should be transformed by WNOTRC", "input": "(wnotrc nil)", "output": "(defmacro wnotrc ((&optional (min 1) (max 50) &rest banner) &body body )\n (declare (ignore min max banner))\n `(progn ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(match nil nil)\n\nWhat needs to change: Macro call that should be transformed by MATCH", "input": "(match nil nil)", "output": "(defmacro MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(esc nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by ESC", "input": "(esc nil (progn))", "output": "(defmacro esc (&rest forms)\n `(list\n ,@(loop for form in forms\n collect (%escape-string-form form))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(of-type nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by OF-TYPE", "input": "(of-type nil :key nil)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(dlet* nil\n nil)\n\nProblem: Macro call that should be transformed by DLET*", "input": "(dlet* nil\n nil)", "output": "(defmacro DLET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-compilation-unit nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-COMPILATION-UNIT", "input": "(with-compilation-unit nil)", "output": "(defmacro WITH-COMPILATION-UNIT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(pop-assoc nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by POP-ASSOC", "input": "(pop-assoc nil (progn))", "output": "(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))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fm-count-named nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FM-COUNT-NAMED", "input": "(fm-count-named nil nil)", "output": "(defmacro fm-count-named (family md-name &key (global-search t))\n `(length (fm-find-all ,family ,md-name\n :must-find nil\n :global-search ,global-search)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(custom-decoder nil)\n\nPattern to recognize: Macro call that should be transformed by CUSTOM-DECODER", "input": "(custom-decoder nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(html5 nil nil)\n\nProblem: Macro call that should be transformed by HTML5", "input": "(html5 nil nil)", "output": "(defmacro html5 (&rest tags)\n `(with-doctype :html5\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(do-for nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DO-FOR", "input": "(do-for nil\n (progn))", "output": "(defmacro DO-FOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code 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\nWrite a macro that addresses: Cond with per-branch variable bindings leads to duplicated body code \u2014 want shared body with branch-specific bindings", "input": ";; 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", "output": "(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)))))", "category": "control-flow", "technique": "gensym,nested-backquote", "complexity": "intermediate", "quality_score": 0.9625} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(*let nil)\n\nProblem: Macro call that should be transformed by *LET", "input": "(*let nil)", "output": "(defmacro *LET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(as->* 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by AS->*", "input": "(as->* 'lol-gen::some-name)", "output": "(defmacro AS->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-proxynodes 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-PROXYNODES", "input": "(with-proxynodes 'lol-gen::some-name)", "output": "(defmacro with-proxynodes (proxy-nodes &body body)\n \"define proxy nodes for local usage\"\n (if (not (listp proxy-nodes))\n (setf proxy-nodes (list proxy-nodes)))\n (if proxy-nodes\n (let ((tmp (gensym (format nil \"~:@(proxy-~a-~)\" (first proxy-nodes)))))\n\t;(format t \"Symbol:: ~s\" tmp)\n\t(setf (gethash (first proxy-nodes) *proxy-node*) tmp)\n\t;;for debug/swank, else comment out\n\t;;(eval `(defnode ,tmp (proxy) ()))\n\t;;\n\t`(let ((,(first proxy-nodes) ',tmp))\n\n\t ;(defnode ,tmp (proxy) ())\n\t (defproxy ,tmp)\n\t \n\t (with-proxynodes ,(rest proxy-nodes) ,@body)))\n `(progn ,@body)))", "category": "dsl", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cond 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by COND", "input": "(cond 'lol-gen::some-name)", "output": "(defmacro COND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(html nil :key nil)\n\nIssue: Macro call that should be transformed by HTML", "input": "(html nil :key nil)", "output": "(defmacro html (&rest tags)\n `(with-doctype :html\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-decoder-simple-list-semantics\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-DECODER-SIMPLE-LIST-SEMANTICS", "input": "(with-decoder-simple-list-semantics\n nil)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(set= nil :key nil)\n\nProblem: Macro call that should be transformed by SET=", "input": "(set= nil :key nil)", "output": "(defmacro set= (&rest args)\n `(make-clause :set= ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(some-> nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by SOME->", "input": "(some-> nil\n :key\n nil)", "output": "(defmacro some-> (init &body exps) (arrow-macro init exps nil t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defclause-driver 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFCLAUSE-DRIVER", "input": "(defclause-driver 'lol-gen::some-name)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(eval-always\n nil\n nil)\n\nProblem: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n nil\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda-ematch\n common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-EMATCH", "input": "(lambda-ematch\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(finish nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by FINISH", "input": "(finish nil :key nil)", "output": "(defmacro finish (form &optional description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'finishing-result\n :expression '(finish ,form)\n :body (lambda () ,form)\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(enable-quasi-quoted-string-to-binary-emitting-form-syntax 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ENABLE-QUASI-QUOTED-STRING-TO-BINARY-EMITTING-FORM-SYNTAX", "input": "(enable-quasi-quoted-string-to-binary-emitting-form-syntax 'lol-gen::some-name)", "output": "(defmacro ENABLE-QUASI-QUOTED-STRING-TO-BINARY-EMITTING-FORM-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(char-case nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CHAR-CASE", "input": "(char-case nil)", "output": "(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)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defwalker-handler nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFWALKER-HANDLER", "input": "(defwalker-handler nil\n nil)", "output": "(defmacro DEFWALKER-HANDLER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(json-bind nil\n (progn))\n\nProblem: Macro call that should be transformed by JSON-BIND", "input": "(json-bind nil\n (progn))", "output": "(defmacro json-bind ((&rest vars) json-source &body body)\n (let-gensyms (decoder validator value-handler key-handler pass)\n (let ((vars-tmp (loop repeat (length vars) collect (gensym))))\n `(let (,@vars-tmp (,pass (constantly t)))\n (let ((,validator\n (custom-decoder\n :beginning-of-object ,pass :object-key ,pass\n :object-value ,pass :end-of-object ,pass\n :beginning-of-array ,pass :array-member ,pass\n :end-of-array ,pass :beginning-of-string ,pass\n :string-char ,pass :end-of-string ,pass\n :internal-decoder 'decode-json))\n (,decoder (current-decoder))\n (,key-handler *object-key-handler*)\n (,value-handler *object-value-handler*))\n (declare (ignorable ,decoder ,key-handler ,value-handler))\n ,(if (null vars)\n `(decode-json-from-source ,json-source ,validator)\n `(bind-custom-vars\n (,@(json-bind-level-customizations\n (loop for var in vars for var-tmp in vars-tmp\n collect (cons var-tmp (symbol-name var)))\n nil decoder validator\n key-handler value-handler pass)\n :aggregate-scope\n (union *aggregate-scope-variables*\n '(*object-key-handler*\n *object-value-handler*\n *internal-decoder*)))\n (decode-json-from-source ,json-source))))\n (let ,(mapcar #'list vars vars-tmp)\n ,@body)))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-collectors nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-COLLECTORS", "input": "(with-collectors nil)", "output": "(defmacro WITH-COLLECTORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(op\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by OP", "input": "(op\n nil\n (progn))", "output": "(defmacro op (&body body &environment env)\n \"GOO's simple macro for positional lambdas.\n\nAn OP is like a lambda without an argument list. Within the body of the OP\nform, an underscore introduces a new argument.\n\n (reduce (op (set-intersection _ _ :test #'equal))\n sets)\n\nYou can refer back to each argument by number, starting with _1.\n\n (funcall (op (+ _ _1)) 2) => 4\n\nYou can also use positional arguments directly:\n\n (reduce (op (funcall _2 _1)) ...)\n\nArgument lists can be sparse:\n\n (apply (op (+ _1 _3 _5)) '(1 2 3 4 5)) => 9\n\nNote that OP with a single argument is equivalent to CONSTANTLY:\n\n (funcall (op 1)) => 1\n\nand that OP with a single placeholder is equivalent to IDENTITY:\n\n (funcall (op _) 1) => 1\n\nOP can also be used to define variadic functions by using _* as the\nplaceholder. It is not necessary to use APPLY.\n\n (apply (op (+ _*)) '(1 2 3 4)) => 10\n\nOP is intended for simple functions -- one-liners. Parameters are\nextracted according to a depth-first walk of BODY. Macro expansion\nmay, or may not, be done depending on the implementation; it should\nnot be relied on. Lexical bindings may, or may not, shadow\nplaceholders -- again, it depends on the implementation. (This means,\namong other things, that nested use of `op' is not a good idea.)\nBecause of the impossibility of a truly portable code walker, `op'\nwill never be a true replacement for `lambda'. But even if it were\npossible to do better, `op' would still only be suited for one-liners.\nIf you need more than a one-liner, then you should be giving your\nparameters names.\n\n\\(One thing you *can* count on is the ability to use `op' with\nquasiquotes. If using placeholders inside quasiquotes does not work on\nyour Lisp implementation, that's a bug, not a limitation.)\"\n (let ((env (extract-op-env body env)))\n (op-env-lambda env)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(next-in nil nil)\n\nIssue: Macro call that should be transformed by NEXT-IN", "input": "(next-in nil nil)", "output": "(defmacro NEXT-IN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ctypecase-let 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by CTYPECASE-LET", "input": "(ctypecase-let 'lol-gen::some-name)", "output": "(defmacro ctypecase-let ((var expr) &body cases)\n \"Like (let ((VAR EXPR)) (ctypecase VAR ...)), with VAR correctable.\"\n `(let ((,var ,expr))\n (ctypecase ,var\n ,@cases)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(enable-quasi-quoted-bivalent-to-binary-emitting-form-syntax nil)\n\nPattern to recognize: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BIVALENT-TO-BINARY-EMITTING-FORM-SYNTAX", "input": "(enable-quasi-quoted-bivalent-to-binary-emitting-form-syntax nil)", "output": "(defmacro ENABLE-QUASI-QUOTED-BIVALENT-TO-BINARY-EMITTING-FORM-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dynamic-extent common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by DYNAMIC-EXTENT", "input": "(dynamic-extent common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro DYNAMIC-EXTENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(letrec* nil\n (progn))\n\nIssue: Macro call that should be transformed by LETREC*", "input": "(letrec* nil\n (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(delete-from nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DELETE-FROM", "input": "(delete-from nil\n nil)", "output": "(defmacro delete-from (table &body clauses)\n `(make-statement :delete-from\n ,(expand-expression table) ,@clauses))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(f_%\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by F_%", "input": "(f_%\n 'lol-gen::some-name)", "output": "(defmacro F_% ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(-> 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by ->", "input": "(-> 'lol-gen::some-name)", "output": "(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)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Generate a defmacro form that transforms code like this:\n(skip 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by SKIP", "input": "(skip 'lol-gen::some-name)", "output": "(defmacro skip (desc &body tests)\n `(with-forced-status (:skipped ,@(if (listp desc) desc (list desc)))\n ,@tests))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(fbind* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by FBIND*", "input": "(fbind* nil\n (progn))", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(f0\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by F0", "input": "(f0\n nil\n (progn))", "output": "(defmacro F0 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(instead nil (progn))\n\nIssue: Macro call that should be transformed by INSTEAD", "input": "(instead nil (progn))", "output": "(defmacro instead (item parser)\n \"Run some parser, but substitute its inner value with some `item' if parsing was\n successful.\"\n `(<$ ,item ,parser))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(and-bind nil (progn))\n\nWhat needs to change: Macro call that should be transformed by AND-BIND", "input": "(and-bind nil (progn))", "output": "(defmacro AND-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(eif-let nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by EIF-LET", "input": "(eif-let nil\n (progn))", "output": "(defmacro eif-let (&whole whole binds &body (then &optional (else nil else?)))\n \"Like `alexandria:if-let', but expects two branches.\nCompare `eif'.\"\n (unless else?\n (warn \"Missing else-branch in eif-let form:~%~a\"\n whole))\n `(if-let ,binds ,then ,else))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(eko nil)\n\nPattern to recognize: Macro call that should be transformed by EKO", "input": "(eko nil)", "output": "(defmacro eko ((&rest trcargs) &rest body)\n (let ((result (gensym)))\n `(let ((,result ,@body))\n ,(if (stringp (car trcargs))\n `(trc ,(car trcargs) :=> ,result ,@(cdr trcargs))\n `(trc ,(car trcargs) ,(cadr trcargs) :=> ,result ,@(cddr trcargs)))\n ,result)))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(->*\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by ->*", "input": "(->*\n nil\n (progn))", "output": "(defmacro ->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(do-select 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DO-SELECT", "input": "(do-select 'lol-gen::some-name)", "output": "(defmacro do-select ((dao select &optional index) &body body)\n (with-gensyms (main main-body select-fn cursor i)\n `(block nil\n (labels ((,main-body (,dao ,(or index i))\n ,@(and (not index)\n `((declare (ignore ,i))))\n ,@body)\n (,select-fn () ,select)\n (,main ()\n (case (dbi:connection-driver-type *connection*)\n (:postgres\n (let ((,cursor (let ((*want-cursor* t))\n (,select-fn))))\n (loop ,@(and index `(for ,i from 0))\n for ,dao = (fetch-dao-from-cursor ,cursor)\n while ,dao\n do (,main-body ,dao ,i))))\n (otherwise\n (loop ,@(and index `(for ,i from 0))\n for ,dao in (,select-fn)\n do (,main-body ,dao ,i))))))\n (if (dbi:in-transaction *connection*)\n (,main)\n (dbi:with-transaction *connection*\n (,main)))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "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", "input": "(fn nil\n nil)", "output": "(defmacro FN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(match-of nil\n (progn))\n\nProblem: Macro call that should be transformed by MATCH-OF", "input": "(match-of nil\n (progn))", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(alt 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ALT", "input": "(alt 'lol-gen::some-name)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(to 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by TO", "input": "(to 'lol-gen::some-name)", "output": "(defmacro TO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(esc nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ESC", "input": "(esc nil nil)", "output": "(defmacro esc (&rest forms)\n `(list\n ,@(loop for form in forms\n collect (%escape-string-form form))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cmatch common-lisp:nil\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by CMATCH", "input": "(cmatch common-lisp:nil\n common-lisp:nil)", "output": "(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))))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(match nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by MATCH", "input": "(match nil\n (progn))", "output": "(defmacro MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(and 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by AND", "input": "(and 'lol-gen::some-name)", "output": "(defmacro AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda-match*\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by LAMBDA-MATCH*", "input": "(lambda-match*\n common-lisp:nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-foreign-strings nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-FOREIGN-STRINGS", "input": "(with-foreign-strings nil\n nil)", "output": "(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)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond-let nil)\n\nWhat needs to change: Macro call that should be transformed by COND-LET", "input": "(cond-let nil)", "output": "(defmacro cond-let (var &body clauses)\n \"Cross between COND and LET.\n\n (cond-let x ((test ...)))\n \u2261 (let (x)\n (cond ((setf x test) ...)))\n\nCf. `acond' in Anaphora.\"\n (match clauses\n (() nil)\n ((list* (list test) clauses)\n `(if-let1 ,var ,test\n ,var\n (cond-let ,var ,@clauses)))\n ((list* (list* t body) _)\n `(progn ,@body))\n ((list* (list* test body) clauses)\n `(let ((,var ,test))\n (if ,var\n ;; Rebind the variables for declarations.\n (let1 ,var ,var\n ,@body)\n (cond-let ,var ,@clauses))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8274999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-interleaving\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-INTERLEAVING", "input": "(with-interleaving\n 'lol-gen::some-name)", "output": "(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))))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(-<>\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by -<>", "input": "(-<>\n 'lol-gen::some-name)", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(odig nil)\n\nIssue: Macro call that should be transformed by ODIG", "input": "(odig nil)", "output": "(defmacro ODIG ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(awhen nil\n nil)\n\nIssue: Macro call that should be transformed by AWHEN", "input": "(awhen nil\n nil)", "output": "(defmacro AWHEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(doquery nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DOQUERY", "input": "(doquery nil\n (progn))", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-decoder-simple-list-semantics\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-DECODER-SIMPLE-LIST-SEMANTICS", "input": "(with-decoder-simple-list-semantics\n 'lol-gen::some-name)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(resolve\n nil\n (progn))\n\nIssue: Macro call that should be transformed by RESOLVE", "input": "(resolve\n nil\n (progn))", "output": "(defmacro RESOLVE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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 ->", "input": "(-> nil :key nil)", "output": "(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)))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(def-fixture nil\n nil)\n\nProblem: Macro call that should be transformed by DEF-FIXTURE", "input": "(def-fixture nil\n nil)", "output": "(defmacro def-fixture (name (&rest args) &body body)\n \"Defines a fixture named NAME. A fixture is very much like a\nmacro but is used only for simple templating. A fixture created\nwith DEF-FIXTURE is a macro which can use the special macrolet\n&BODY to specify where the body should go.\n\nSee Also: WITH-FIXTURE\n\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (get-fixture ',name) (cons ',args ',body))\n ',name))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(set-plist-val! nil :key nil)\n\nProblem: Macro call that should be transformed by SET-PLIST-VAL!", "input": "(set-plist-val! nil :key nil)", "output": "(defmacro set-plist-val! (new id place\n &key (test '(default-test)) (key '(default-key)))\n `(setf ,place\n (set-plist-val ,new ,id ,place :test ,test :key ,key)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(filterf nil nil)\n\nProblem: Macro call that should be transformed by FILTERF", "input": "(filterf nil nil)", "output": "(defmacro FILTERF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(with-string-dispatch nil\n nil)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(rem-bops nil)\n\nPattern to recognize: Macro call that should be transformed by REM-BOPS", "input": "(rem-bops nil)", "output": "(defmacro REM-BOPS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cond-> nil :key nil)\n\nProblem: Macro call that should be transformed by COND->", "input": "(cond-> nil :key nil)", "output": "(defmacro COND-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defmd nil nil)\n\nProblem: Macro call that should be transformed by DEFMD", "input": "(defmd nil nil)", "output": "(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)))))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(when-let 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WHEN-LET", "input": "(when-let 'lol-gen::some-name)", "output": "(defmacro when-let ((var test) &body body)\n \"Like WHEN. VAR will be bound to TEST.\"\n `(let ((,var ,test))\n (when ,var\n ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-port-value-slot nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-PORT-VALUE-SLOT", "input": "(define-port-value-slot nil :key nil)", "output": "(defmacro DEFINE-PORT-VALUE-SLOT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(none-of nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by NONE-OF", "input": "(none-of nil\n (progn))", "output": "(defmacro NONE-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fm-mapc nil nil)\n\nPattern to recognize: Macro call that should be transformed by FM-MAPC", "input": "(fm-mapc nil nil)", "output": "(defmacro fm-mapc (fn md-name)\n `(mapc ,fn (fm-find-all self ',md-name)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(current-decoder nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by CURRENT-DECODER", "input": "(current-decoder nil :key nil)", "output": "(defmacro current-decoder (&rest keys)\n \"Capture current values of custom variables and return a custom\ndecoder which restores these values in its dynamic environment.\"\n (let (exterior-bindings customizations)\n (flet ((collect (key var)\n (let ((exterior (gensym)))\n (push (list exterior var) exterior-bindings)\n (push exterior customizations)\n (push key customizations))))\n (if keys\n (loop for key in keys\n do (collect key (custom-key-to-variable key)))\n (loop-on-custom (key var)\n do (collect key var)))\n `(let ,exterior-bindings\n (custom-decoder ,@customizations)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(~> nil)\n\nProblem: Macro call that should be transformed by ~>", "input": "(~> nil)", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.79} {"instruction": "Generate a defmacro form that transforms code like this:\n(minimizing 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by MINIMIZING", "input": "(minimizing 'lol-gen::some-name)", "output": "(defmacro MINIMIZING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fbind 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by FBIND", "input": "(fbind 'lol-gen::some-name)", "output": "(defmacro fbind (bindings &body body &environment *lexenv*)\n \"Binds values in the function namespace.\n\nThat is,\n (fbind ((fn (lambda () ...))))\n \u2261 (flet ((fn () ...))),\n\nexcept that a bare symbol in BINDINGS is rewritten as (symbol\nsymbol).\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbind `(locally ,@body)))\n ;; When possible (if the binding expands to a simple\n ;; let-over-lambda), we hoist the bindings to the top and bind\n ;; the lambda directly with flet.\n\n ;; Failing that, if we know that the function is never directly\n ;; dereferenced with sharp-quote, we can bind with `macrolet'\n ;; instead of `flet', leaving no runtime overhead vs. `funcall'.\n (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))\n (macro-vars\n (merely-syntactic-functions (mapcar #'first bindings)\n body\n *lexenv*))\n (vars (mapcar #'first bindings))\n (exprs (mapcar #'second bindings))\n (temps (mapcar #'string-gensym vars))\n (body decls (parse-body body)))\n `(let ,env\n ,@(unsplice (and env-decls `(declare ,@env-decls)))\n (comment \"fbind: Hidden variable bindings to close over.\")\n (let ,(loop for temp in temps\n for expr in exprs\n collect `(,temp (ensure-function ,expr)))\n ,@(when temps\n (unsplice\n `(declare (function ,@temps))))\n (comment \"fbind: Hidden variable bindings for function values.\")\n (flet (,@(loop for (name lambda) in lambdas\n collect `(,name ,@(cdr lambda)))\n ,@(loop for var in vars\n for temp in temps\n unless (member var macro-vars)\n collect (build-bind/ftype var temp decls env)))\n #-sbcl (declare (inline ,@(set-difference vars macro-vars)))\n ,@decls\n (comment \"fbind: Functions that might be sharp-quoted.\")\n (macrolet (,@(loop for var in vars\n for temp in temps\n when (member var macro-vars)\n collect `(,var\n (&rest args)\n (list* 'funcall ',temp args))))\n (comment \"fbind: Macros for functions provably never sharp-quoted.\")\n ,@body))))))", "category": "control-flow", "technique": "macrolet,gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ps-once-only nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PS-ONCE-ONLY", "input": "(ps-once-only nil\n nil)", "output": "(defmacro PS-ONCE-ONLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c?n\n nil\n nil)\n\nProblem: Macro call that should be transformed by C?N", "input": "(c?n\n nil\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cond-<>\n nil\n nil)\n\nProblem: Macro call that should be transformed by COND-<>", "input": "(cond-<>\n nil\n nil)", "output": "(defmacro COND-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(sort-values 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by SORT-VALUES", "input": "(sort-values 'lol-gen::some-name)", "output": "(defmacro sort-values (pred &rest values)\n \"Sort VALUES with PRED and return as multiple values.\n\nEquivalent to\n\n (values-list (sort (list VALUES...) pred))\n\nBut with less consing, and potentially faster.\"\n ;; Remember to evaluate `pred' no matter what.\n (with-gensyms (gpred)\n `(let ((,gpred (ensure-function ,pred)))\n (declare (ignorable ,gpred)\n (function ,gpred)\n (optimize (safety 1) (debug 0) (compilation-speed 0)))\n ,(match values\n ((list) `(values))\n ((list x) `(values ,x))\n ;; The strategy here is to use a sorting network if the\n ;; inputs are few, and a stack-allocated vector if the\n ;; inputs are many.\n (otherwise\n (if (<= (length values) 8)\n `(sort-values/network ,gpred ,@values)\n `(sort-values/temp-vector ,gpred ,@values)))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fdec 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by FDEC", "input": "(fdec 'lol-gen::some-name)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-value-symbol-macro-binding nil\n (progn))\n\nProblem: Macro call that should be transformed by DEFINE-VALUE-SYMBOL-MACRO-BINDING", "input": "(define-value-symbol-macro-binding nil\n (progn))", "output": "(defmacro define-value-symbol-macro-binding (name (var &rest args) &body body)\n (let ((vars (lambda-fiddle:extract-lambda-vars (lambda-fiddle:remove-aux-part args))))\n (emit-binding-definition name var args body :extra-vars vars :symbol-macro-p T)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-synapse nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-SYNAPSE", "input": "(with-synapse nil\n (progn))", "output": "(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)))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(make* 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by MAKE*", "input": "(make* 'lol-gen::some-name)", "output": "(defmacro MAKE* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(any-of 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ANY-OF", "input": "(any-of 'lol-gen::some-name)", "output": "(defmacro ANY-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(do-iter-values nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DO-ITER-VALUES", "input": "(do-iter-values nil\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "tagbody-go,gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(-<> nil :key nil)\n\nIssue: Macro call that should be transformed by -<>", "input": "(-<> nil :key nil)", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(live\n nil\n (progn))\n\nProblem: Macro call that should be transformed by LIVE", "input": "(live\n nil\n (progn))", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(query nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by QUERY", "input": "(query nil :key nil)", "output": "(defmacro query (query &rest args/format)\n \"Execute the given query, which can be either a string or an S-SQL form (list\nstarting with a keyword). If the query contains placeholders ($1, $2, etc)\ntheir values can be given as extra arguments. If one of these arguments is a\nkeyword occurring in the table below, it will not be used as a query\nargument, but will determine the format in which the results are returned\ninstead. Any of the following formats can be used, with the default being :rows:\n\n| :none\t | Ignore the result values. |\n| :lists, :rows | Return a list of lists, each list containing the values |\n| | for a row. |\n| :list, :row | Return a single row as a list. |\n| :alists\t | Return a list of alists which map column names to values, |\n| | with the names represented as keywords. |\n| :alist\t | Return a single row as an alist. |\n| :array-hash | Return an array of hashtables which map column names to |\n| | hash table keys. NOTE: It will return an empty array |\n| | if there is no result. |\n| :vectors | Returns a vector of vectors where each internal vector is |\n| | a returned row from the query. The field names are not |\n| | included. NOTE: It will return an empty vector instead of |\n| | NIL if there is no result. |\n| :str-alists | Like :alists, but use the original column names. |\n| :str-alist\t | Return a single row as an alist, with strings for names. |\n| :plists\t | Return a list of plists which map column names to values, |\n| | with the names represented as keywords. |\n| :plist\t | Return a single row as a plist. |\n| :column\t | Return a single column as a list. |\n| :single\t | Return a single value. |\n| :single!\t | Like :single, but raise an error when the number of |\n| | selected rows is not equal to 1. |\n| (:dao type)\t | Return a list of DAOs of the given type. The names of the |\n| | fields returned by the query must match slots in the DAO |\n| | class the same way as with query-dao. |\n| (:dao type :single)| Return a single DAO of the given type. |\n| :json-strs | Return a list of strings where each row is a json object |\n| | expressed as a string |\n| :json-str | Return a single string where the row returned is a json |\n| | object expressed as a string. |\n| :json-array-str | Return a string containing a json array, each element in |\n| | the array is a selected row expressed as a json object. |\n| | NOTE: If there is no result, it will return a string with |\n| | an empty json array. |\n\nIf the database returns information about the amount rows that were affected,\nsuch as with updating or deleting queries, this is returned as a second value.\"\n (let* ((format :rows)\n (args (loop :for arg :in args/format\n :if (or (dao-spec-for-format arg)\n (assoc arg *result-styles*)) :do (setf format arg)\n :else :collect arg)))\n (destructuring-bind (reader result-form) (reader-for-format format)\n (let ((base (if args\n\t\t (let ((vars (loop :for x :in args :collect (gensym))))\n\t\t\t`(let ,(loop :for v :in vars :for a :in args :collect `(,v ,a))\n\t\t\t (prepare-query *database* \"\" ,(real-query query) (list ,@vars))\n\t\t\t (exec-prepared *database* \"\" (list ,@vars) ,reader)))\n\t\t `(exec-query *database* ,(real-query query) ,reader))))\n `(,result-form ,base)))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(-<>>\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by -<>>", "input": "(-<>>\n nil\n nil)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(collect-max nil)\n\nProblem: Macro call that should be transformed by COLLECT-MAX", "input": "(collect-max nil)", "output": "(defmacro COLLECT-MAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(labels* nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LABELS*", "input": "(labels* nil\n nil)", "output": "(defmacro LABELS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(char-case nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CHAR-CASE", "input": "(char-case nil\n nil)", "output": "(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)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(who-ps-html nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by WHO-PS-HTML", "input": "(who-ps-html nil :key nil)", "output": "(defmacro WHO-PS-HTML ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n;; Regex matching with captures requires manual multiple-value-bind\n(multiple-value-bind (matchp captures)\n (cl-ppcre:scan-to-strings \"_(\\\\w+)@(\\\\w+)\\\\.com_\" email)\n (if matchp\n (let ((user (aref captures 0))\n (domain (aref captures 1)))\n (format t \"~a at ~a~%\" user domain))\n :invalid))\n\n;; Verbose: bind result, extract captures by index, branch - repetitive\n\nIssue: Regex matching with named captures requires verbose destructuring \u2014 want $1, $2, ... anaphors bound to capture groups", "input": ";; Regex matching with captures requires manual multiple-value-bind\n(multiple-value-bind (matchp captures)\n (cl-ppcre:scan-to-strings \"_(\\\\w+)@(\\\\w+)\\\\.com_\" email)\n (if matchp\n (let ((user (aref captures 0))\n (domain (aref captures 1)))\n (format t \"~a at ~a~%\" user domain))\n :invalid))\n\n;; Verbose: bind result, extract captures by index, branch - repetitive", "output": "#+cl-ppcre\n(defun dollar-symbol-p (s)\n (and (symbolp s)\n (> (length (symbol-name s)) 1)\n (string= (symbol-name s)\n \"$\"\n :start1 0\n :end1 1)\n (ignore-errors (parse-integer (subseq (symbol-name s) 1)))))\n\n(defmacro! if-match ((match-regex str) then &optional else)\n (let* ((dollars (remove-duplicates\n (remove-if-not #'dollar-symbol-p\n (flatten then))))\n (top (or (car (sort (mapcar #'dollar-symbol-p dollars) #'>))\n 0)))\n `(multiple-value-bind (,g!matches ,g!captures) (,match-regex ,str)\n (declare (ignorable ,g!matches ,g!captures))\n (let ((,g!captures-len (length ,g!captures)))\n (declare (ignorable ,g!captures-len))\n (symbol-macrolet ,(mapcar #`(,(symb \"$\" a1)\n (if (< ,g!captures-len ,a1)\n (error \"Too few matchs: ~a unbound.\" ,(mkstr \"$\" a1))\n (aref ,g!captures ,(1- a1))))\n (loop for i from 1 to top collect i))\n (if ,g!matches\n ,then\n ,else))))))", "category": "control-flow", "technique": "symbol-macrolet,gensym,code-walking", "complexity": "advanced", "quality_score": 1.0} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(some-> nil (progn))\n\nIssue: Macro call that should be transformed by SOME->", "input": "(some-> nil (progn))", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond-let nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by COND-LET", "input": "(cond-let nil\n (progn))", "output": "(defmacro cond-let (var &body body)\n \"Like COND. VAR will be bound to the passed COND test.\"\n `(let (,var)\n (cond\n ,@(mapcar #``((setf ,var ,(car %)) ,(cadr %))\n ;; uses the fact, that SETF returns the value set\n body))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(collect-max nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by COLLECT-MAX", "input": "(collect-max nil :key nil)", "output": "(defmacro COLLECT-MAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(removef nil nil)\n\nWhat needs to change: Macro call that should be transformed by REMOVEF", "input": "(removef nil nil)", "output": "(defmacro REMOVEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(xor nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by XOR", "input": "(xor nil (progn))", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(none-of nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NONE-OF", "input": "(none-of nil)", "output": "(defmacro NONE-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ps-html nil nil)\n\nWhat needs to change: Macro call that should be transformed by PS-HTML", "input": "(ps-html nil nil)", "output": "(defmacro PS-HTML ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(set-handler nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by SET-HANDLER", "input": "(set-handler nil :key nil)", "output": "(defmacro SET-HANDLER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(rotatef nil nil)\n\nPattern to recognize: Macro call that should be transformed by ROTATEF", "input": "(rotatef nil nil)", "output": "(defmacro ROTATEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(json-bind nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by JSON-BIND", "input": "(json-bind nil\n nil)", "output": "(defmacro json-bind ((&rest vars) json-source &body body)\n (let-gensyms (decoder validator value-handler key-handler pass)\n (let ((vars-tmp (loop repeat (length vars) collect (gensym))))\n `(let (,@vars-tmp (,pass (constantly t)))\n (let ((,validator\n (custom-decoder\n :beginning-of-object ,pass :object-key ,pass\n :object-value ,pass :end-of-object ,pass\n :beginning-of-array ,pass :array-member ,pass\n :end-of-array ,pass :beginning-of-string ,pass\n :string-char ,pass :end-of-string ,pass\n :internal-decoder 'decode-json))\n (,decoder (current-decoder))\n (,key-handler *object-key-handler*)\n (,value-handler *object-value-handler*))\n (declare (ignorable ,decoder ,key-handler ,value-handler))\n ,(if (null vars)\n `(decode-json-from-source ,json-source ,validator)\n `(bind-custom-vars\n (,@(json-bind-level-customizations\n (loop for var in vars for var-tmp in vars-tmp\n collect (cons var-tmp (symbol-name var)))\n nil decoder validator\n key-handler value-handler pass)\n :aggregate-scope\n (union *aggregate-scope-variables*\n '(*object-key-handler*\n *object-value-handler*\n *internal-decoder*)))\n (decode-json-from-source ,json-source))))\n (let ,(mapcar #'list vars vars-tmp)\n ,@body)))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(mvlet 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by MVLET", "input": "(mvlet 'lol-gen::some-name)", "output": "(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))))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cmatch* 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by CMATCH*", "input": "(cmatch* 'lol-gen::some-name)", "output": "(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))))))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-delete-hook 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-DELETE-HOOK", "input": "(define-delete-hook 'lol-gen::some-name)", "output": "(defmacro define-delete-hook ((modulevar &optional identifier) &body body)\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (delete-hook\n (or ,identifier\n (intern (package-name *package*) \"KEYWORD\")))\n (lambda (,modulevar) ,@body))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(xhtml nil nil)\n\nProblem: Macro call that should be transformed by XHTML", "input": "(xhtml nil nil)", "output": "(defmacro xhtml (&rest tags)\n `(with-doctype :xhtml\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-hook-restart\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-HOOK-RESTART", "input": "(with-hook-restart\n 'lol-gen::some-name)", "output": "(defmacro with-hook-restart (&body body)\n `(with-simple-restart (continue \"Call next function in hook ~s\" *hook*)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(eval-always\n nil\n (progn))\n\nProblem: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n nil\n (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(aif nil :key nil)\n\nProblem: Macro call that should be transformed by AIF", "input": "(aif nil :key nil)", "output": "(defmacro AIF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fm-otherx nil)\n\nPattern to recognize: Macro call that should be transformed by FM-OTHERX", "input": "(fm-otherx nil)", "output": "(defmacro fm-otherx (md-name &key (starting 'self) skip-tree)\n (if (eql starting 'self)\n `(or (fm-find-one ,starting ,(if (consp md-name)\n `(list ',(car md-name) ,(cadr md-name))\n `',md-name)\n :must-find t\n :skip-tree ,skip-tree\n :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 t\n :skip-tree ,skip-tree\n :global-search t)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(resolve)\n\nProblem: Macro call that should be transformed by RESOLVE", "input": "(resolve)", "output": "(defmacro RESOLVE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(mvlet* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by MVLET*", "input": "(mvlet* nil\n (progn))", "output": "(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))))))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(on-conflict-do-nothing)\n\nProblem: Macro call that should be transformed by ON-CONFLICT-DO-NOTHING", "input": "(on-conflict-do-nothing)", "output": "(defmacro on-conflict-do-nothing (&optional (conflict-target nil))\n `(make-clause :on-conflict-do-nothing ,conflict-target))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(alter-table nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by ALTER-TABLE", "input": "(alter-table nil\n (progn))", "output": "(defmacro alter-table (table &body clauses)\n `(make-statement :alter-table\n ,(expand-expression table) ,@clauses))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda-ematch\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LAMBDA-EMATCH", "input": "(lambda-ematch\n common-lisp:nil)", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defpsmacro nil\n nil)\n\nIssue: Macro call that should be transformed by DEFPSMACRO", "input": "(defpsmacro nil\n nil)", "output": "(defmacro DEFPSMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(skip nil\n (progn))\n\nIssue: Macro call that should be transformed by SKIP", "input": "(skip nil\n (progn))", "output": "(defmacro skip (desc &body tests)\n `(with-forced-status (:skipped ,@(if (listp desc) desc (list desc)))\n ,@tests))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(match2 common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by MATCH2", "input": "(match2 common-lisp:nil\n common-lisp:nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(eko nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by EKO", "input": "(eko nil :key nil)", "output": "(defmacro eko ((&rest trcargs) &rest body)\n (let ((result (gensym)))\n `(let ((,result ,@body))\n ,(if (stringp (car trcargs))\n `(trc ,(car trcargs) :=> ,result ,@(cdr trcargs))\n `(trc ,(car trcargs) ,(cadr trcargs) :=> ,result ,@(cddr trcargs)))\n ,result)))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(finishes\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by FINISHES", "input": "(finishes\n nil\n (progn))", "output": "(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\"))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cond->\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COND->", "input": "(cond->\n 'lol-gen::some-name)", "output": "(defmacro COND-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(when nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WHEN", "input": "(when nil)", "output": "(defmacro WHEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(push nil nil)\n\nPattern to recognize: Macro call that should be transformed by PUSH", "input": "(push nil nil)", "output": "(defmacro PUSH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(u^ nil)\n\nPattern to recognize: Macro call that should be transformed by U^", "input": "(u^ nil)", "output": "(defmacro u^ (type)\n `(upper self ,type))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(accase nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by ACCASE", "input": "(accase nil\n :key\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defiter nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFITER", "input": "(defiter nil\n (progn))", "output": "(defmacro DEFITER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(deftype nil (progn))\n\nIssue: Macro call that should be transformed by DEFTYPE", "input": "(deftype nil (progn))", "output": "(defmacro DEFTYPE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(export-slots\n common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by EXPORT-SLOTS", "input": "(export-slots\n common-lisp:nil\n common-lisp:nil)", "output": "(defmacro EXPORT-SLOTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cardinality-case nil)\n\nWhat needs to change: Macro call that should be transformed by CARDINALITY-CASE", "input": "(cardinality-case nil)", "output": "(defmacro CARDINALITY-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-standard-input-syntax\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-STANDARD-INPUT-SYNTAX", "input": "(with-standard-input-syntax\n 'lol-gen::some-name)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(acond\n nil\n (progn))\n\nIssue: Macro call that should be transformed by ACOND", "input": "(acond\n nil\n (progn))", "output": "(defmacro ACOND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(for-all* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by FOR-ALL*", "input": "(for-all* nil\n (progn))", "output": "(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))))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-yield)\n\nProblem: Macro call that should be transformed by WITH-YIELD", "input": "(with-yield)", "output": "(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)))))))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(letrec nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LETREC", "input": "(letrec nil\n :key\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(modf-eval 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by MODF-EVAL", "input": "(modf-eval 'lol-gen::some-name)", "output": "(defmacro modf-eval (&rest args)\n `(progn ,@args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make-instance* nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-INSTANCE*", "input": "(make-instance* nil nil)", "output": "(defmacro make-instance* (class &rest arguments)\n \"Convenience macro on top of `make-instance'.\n\nConveniences:\n\n- First argument can be a (possibly empty) list of shortcut symbols,\n which is automatically converted into a KEYWORD+SYMBOL pairs where\n - KEYWORD is the same as shortcut name, but interned as keyword.\n - And SYMBOL is the same as shortcut.\n\n- The last argument can be an apply argument---arbitrary\n list-producing form, which will be used as the last argument\n to (apply #'make-instance ...) idiom.\n\nNote that using a singular shortcut list of apply argument is an\nambiguous case that will be interpreted in favor of apply argument. To\nforce either of interpretations, provide shortcuts and apply arguments\nexplicitly:\n(make-instance* 'class (a b c)) ;; BAD\n(make-instance* 'class (a b c) nil) ;; GOOD\n(make-instance* 'class (when t nil)) ;; BAD\n(make-instance* 'class () (when t nil)) ;; GOOD\n\nOtherwise, the behavior is equivalent to `make-instance'.\n\nExamples:\n\nShortcut args:\n\\(make-instance* 'class (a b c))\n=>\n\\(make-instance 'class :a a :b b :c c)\n\nLast form converted into `apply' argument:\n\\(make-instance* 'class :c c :b b (when something (list :a a)))\n=>\n\\(apply #'make-instance 'class :c c :b b (when something (list :a a)))\n\nShortcut arguments, regular arguments, and form for `apply':\n\\(make-instance* 'class (b c) :x x (when something (list :a a)))\n=>\n\\(apply #'make-instance 'class :b b :c c :x x (when something (list :a a)))\n\nForm for `apply' (notice the empty shortcuts---these are required for\nunambiguous parsing):\n\\(make-instance* 'class () (when something (list :a a)))\n=>\n\\(apply #'make-instance 'class (when something (list :a a)))\n\nRegular `make-instance'-like use:\n\\(make-instance* 'class :a a-value :b b-value)\n=>\n\\(make-instance 'class :a a-value :b b-value)\"\n (when (and (= 1 (length arguments))\n (listp (first arguments)))\n (style-warn \"Body of MAKE-INSTANCE* contains a single list-like form ~a.\n\nIf you meant APPLY args, add empty shortcuts list:\n(make-instance* 'class () (apply-form))\n\nIf you meant shortcut list, add empty APPLY args:\n(make-instance* 'class (shortcuts) nil)\n\nInterpreting as APPLY args for now, but this behavior may change in\nthe future.\" arguments))\n (let* ((shortcuts-p (and (listp (first arguments))\n (> (length arguments) 1)))\n (shortcuts (when shortcuts-p\n (first arguments)))\n (arguments (if shortcuts-p\n (rest arguments)\n arguments))\n (last-appendable-form-p (oddp (length arguments)))\n (last-appendable-form (when last-appendable-form-p\n (first (last arguments))))\n (arguments (if last-appendable-form-p\n (butlast arguments)\n arguments)))\n `(,@(if last-appendable-form-p\n `(apply #'make-instance)\n `(make-instance))\n ,class\n ,@(loop for shortcut in shortcuts\n append (list (intern (symbol-name shortcut) :keyword)\n shortcut))\n ,@arguments\n ,@(when last-appendable-form-p\n (list last-appendable-form)))))", "category": "anaphoric", "technique": "nested-backquote,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "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", "input": "(without-dependency-capture\n nil\n (progn))", "output": "(defmacro WITHOUT-DEPENDENCY-CAPTURE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-macro nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by DEFINE-MACRO", "input": "(define-macro nil\n :key\n nil)", "output": "(defmacro DEFINE-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(f-plusp nil :key nil)\n\nProblem: Macro call that should be transformed by F-PLUSP", "input": "(f-plusp nil :key nil)", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(case nil (progn))\n\nPattern to recognize: Macro call that should be transformed by CASE", "input": "(case nil (progn))", "output": "(defmacro CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(and-let* nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by AND-LET*", "input": "(and-let* nil\n :key\n nil)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(right 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by RIGHT", "input": "(right 'lol-gen::some-name)", "output": "(defmacro right (parser &rest parsers)\n \"Combination of parsers yielding the result of the rightmost one.\"\n `(*> ,parser ,@parsers))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(pass nil :key nil)\n\nProblem: Macro call that should be transformed by PASS", "input": "(pass nil :key nil)", "output": "(defmacro pass (&rest message-args)\n \"Simply generate a PASS.\"\n `(add-result 'test-passed\n :test-expr ',message-args\n ,@(when message-args\n `(:reason (format nil ,@message-args)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(remove-from-plistf nil)\n\nProblem: Macro call that should be transformed by REMOVE-FROM-PLISTF", "input": "(remove-from-plistf nil)", "output": "(defmacro REMOVE-FROM-PLISTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nconcf 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by NCONCF", "input": "(nconcf 'lol-gen::some-name)", "output": "(defmacro NCONCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(c?n-dbg\n nil\n :key\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-cc nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-CC", "input": "(with-cc nil\n nil)", "output": "(defmacro with-cc (id &body body)\n `(with-integrity (:change ,id)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(whichever nil (progn))\n\nIssue: Macro call that should be transformed by WHICHEVER", "input": "(whichever nil (progn))", "output": "(defmacro whichever (&rest possibilities &environment env)\n \"Evaluates exactly one of POSSIBILITIES, chosen at random.\"\n (setf possibilities (mapcar (lambda (p) (macroexpand p env)) possibilities))\n (let ((length (length possibilities)))\n (cond\n ((= 1 length)\n (first possibilities))\n ((every #'constantp possibilities)\n `(svref (load-time-value (vector ,@possibilities)) \n (random ,length)))\n (T\n (labels ((expand (possibilities position random-number)\n (if (null (cdr possibilities))\n (car possibilities)\n (let* ((length (length possibilities))\n (half (truncate length 2))\n (second-half (nthcdr half possibilities))\n (first-half (butlast possibilities (- length half))))\n `(if (< ,random-number ,(+ position half))\n ,(expand first-half position random-number)\n ,(expand second-half (+ position half) random-number))))))\n (with-gensyms (random-number)\n `(let ((,random-number (random ,length)))\n ,(expand possibilities 0 random-number))))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(subtest nil)\n\nIssue: Macro call that should be transformed by SUBTEST", "input": "(subtest nil)", "output": "(defmacro subtest (desc &body body)\n `(%subtest ,desc (lambda () ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(batch\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by BATCH", "input": "(batch\n 'lol-gen::some-name)", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-explicit-encoder)\n\nProblem: Macro call that should be transformed by WITH-EXPLICIT-ENCODER", "input": "(with-explicit-encoder)", "output": "(defmacro with-explicit-encoder (&body body)\n `(with-local-encoder (use-explicit-encoder)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(dynamic-let* nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by DYNAMIC-LET*", "input": "(dynamic-let* nil\n :key\n nil)", "output": "(defmacro DYNAMIC-LET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "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->>", "input": "(some->> nil)", "output": "(defmacro SOME->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(mvlet* nil)\n\nWhat needs to change: Macro call that should be transformed by MVLET*", "input": "(mvlet* nil)", "output": "(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))))))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8274999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nunionf nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NUNIONF", "input": "(nunionf nil :key nil)", "output": "(defmacro NUNIONF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dlet 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DLET", "input": "(dlet 'lol-gen::some-name)", "output": "(defmacro DLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(notinline)\n\nProblem: Macro call that should be transformed by NOTINLINE", "input": "(notinline)", "output": "(defmacro NOTINLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(isnt-values nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by ISNT-VALUES", "input": "(isnt-values nil\n nil)", "output": "(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)))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defconstant nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFCONSTANT", "input": "(defconstant nil (progn))", "output": "(defmacro DEFCONSTANT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-special-initargs* 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WITH-SPECIAL-INITARGS*", "input": "(with-special-initargs* 'lol-gen::some-name)", "output": "(defmacro WITH-SPECIAL-INITARGS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(make-method 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by MAKE-METHOD", "input": "(make-method 'lol-gen::some-name)", "output": "(defmacro MAKE-METHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(->> nil nil)\n\nIssue: Macro call that should be transformed by ->>", "input": "(->> nil nil)", "output": "(defmacro ->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(mvlet* 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by MVLET*", "input": "(mvlet* 'lol-gen::some-name)", "output": "(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))))))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(unless nil)\n\nIssue: Macro call that should be transformed by UNLESS", "input": "(unless nil)", "output": "(defmacro UNLESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(make-simple-collector-to-place 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by MAKE-SIMPLE-COLLECTOR-TO-PLACE", "input": "(make-simple-collector-to-place 'lol-gen::some-name)", "output": "(defmacro MAKE-SIMPLE-COLLECTOR-TO-PLACE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-stream nil :key nil)\n\nIssue: Macro call that should be transformed by COLLECT-STREAM", "input": "(collect-stream nil :key nil)", "output": "(defmacro COLLECT-STREAM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(removef nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by REMOVEF", "input": "(removef nil :key nil)", "output": "(defmacro REMOVEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fm? nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FM?", "input": "(fm? nil :key nil)", "output": "(defmacro fm? (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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(-<>> nil :key nil)\n\nIssue: Macro call that should be transformed by -<>>", "input": "(-<>> nil :key nil)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(in-readtable nil)\n\nProblem: Macro call that should be transformed by IN-READTABLE", "input": "(in-readtable nil)", "output": "(defmacro in-readtable (name)\n \"Set *READTABLE* to the readtable referred to by the symbol NAME and\n return the readtable. This may signal READTABLE-DOES-NOT-EXIST.\n\n - Everything IN-READTABLE does is also performed at [compile time][\n pax:clhs] if the call appears as a [top level form][ pax:clhs].\n\n - The effects of IN-READTABLE are file-local since both COMPILE-FILE\n and LOAD rebind *READTABLE*.\"\n (check-type name symbol)\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n ;; NB. The :LOAD-TOPLEVEL is needed for cases like (DEFVAR *FOO*\n ;; (GET-MACRO-CHARACTER #\\\"))\n (setf *readtable* (ensure-readtable ',name))\n (when (or (find-package :swank) (find-package :slynk))\n (%frob-swank-readtable-alist *package* *readtable*))\n *readtable*))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(declare-deprecated-operators nil)\n\nIssue: Macro call that should be transformed by DECLARE-DEPRECATED-OPERATORS", "input": "(declare-deprecated-operators nil)", "output": "(defmacro DECLARE-DEPRECATED-OPERATORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(when nil (progn))\n\nProblem: Macro call that should be transformed by WHEN", "input": "(when nil (progn))", "output": "(defmacro WHEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-tokens nil)\n\nIssue: Macro call that should be transformed by WITH-TOKENS", "input": "(with-tokens nil)", "output": "(defmacro with-tokens (tokens &body body)\n `(let ((*tokens* ,tokens)\n (*toplevel* nil))\n (trivial-with-current-source-form:with-current-source-form (*tokens*)\n ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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", "input": "(defdata nil\n nil)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dispatch-caseql nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DISPATCH-CASEQL", "input": "(dispatch-caseql nil\n nil)", "output": "(defmacro dispatch-caseql ((&rest exprs-and-types) &body clauses)\n \"Like `dispatch-case', but types in clauses are implicitly wrapped in `eql'.\nThe syntax of `dispatch-caseql' is tohus closer to `case' than to\n`typecase'.\"\n (expect-form-list\n `(dispatch-case ,exprs-and-types\n ,@(expand-dispatch-caseql-clauses clauses))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(dynamic-relet nil\n nil)\n\nProblem: Macro call that should be transformed by DYNAMIC-RELET", "input": "(dynamic-relet nil\n nil)", "output": "(defmacro DYNAMIC-RELET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(and nil :key nil)\n\nProblem: Macro call that should be transformed by AND", "input": "(and nil :key nil)", "output": "(defmacro AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n($send nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by $SEND", "input": "($send nil :key nil)", "output": "(defmacro $SEND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(multiple-value-cmatch 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by MULTIPLE-VALUE-CMATCH", "input": "(multiple-value-cmatch 'lol-gen::some-name)", "output": "(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))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c_in\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by C_IN", "input": "(c_in\n nil\n nil)", "output": "(defmacro c_in (&body body)\n `(c-input (:lazy :once-asked) (progn ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(c?n-dbg\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by C?N-DBG", "input": "(c?n-dbg\n nil\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-unique-js-names 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-UNIQUE-JS-NAMES", "input": "(with-unique-js-names 'lol-gen::some-name)", "output": "(defmacro WITH-UNIQUE-JS-NAMES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(decf nil nil)\n\nProblem: Macro call that should be transformed by DECF", "input": "(decf nil nil)", "output": "(defmacro DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(decf nil nil)\n\nPattern to recognize: Macro call that should be transformed by DECF", "input": "(decf nil nil)", "output": "(defmacro DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fsetf nil (progn))\n\nPattern to recognize: Macro call that should be transformed by FSETF", "input": "(fsetf nil (progn))", "output": "(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)))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(multiple-value-match 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by MULTIPLE-VALUE-MATCH", "input": "(multiple-value-match 'lol-gen::some-name)", "output": "(defmacro multiple-value-match (values-form &body clauses)\n \"Matches the multiple values of VALUES-FORM with CLAUSES. Unlike\nMATCH, CLAUSES have to have the form of (PATTERNS . BODY), where\nPATTERNS is a list of patterns. The number of values that will be used\nto match is determined by the maximum arity of PATTERNS among CLAUSES.\n\nExamples:\n\n (multiple-value-match (values 1 2)\n ((2) 1)\n ((1 y) y))\n => 2\"\n (compile-multiple-value-match values-form clauses nil))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(deftest nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFTEST", "input": "(deftest nil\n (progn))", "output": "(defmacro deftest (name &body test-forms)\n (let ((tests (gensym \"TESTS\"))\n (test (gensym \"TEST\"))\n (test-fn (gensym \"TEST-FN\")))\n `(progn\n (unless (nth-value 1 (gethash *package* *package-tests*))\n (setf (gethash *package* *package-tests*) '()))\n (let* ((,tests (gethash *package* *package-tests*))\n (,test (assoc ',name ,tests :test #'string=))\n (,test-fn (lambda ()\n (subtest (princ-to-string ',name)\n ,@test-forms))))\n (if ,test\n (rplacd ,test ,test-fn)\n (push (cons ',name ,test-fn) (gethash *package* *package-tests*)))\n ',name))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defmacro nil ())\n\nProblem: Macro call that should be transformed by DEFMACRO", "input": "(defmacro nil ())", "output": "(defmacro DEFMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-packages-unlocked nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-PACKAGES-UNLOCKED", "input": "(with-packages-unlocked nil\n :key\n nil)", "output": "(defmacro WITH-PACKAGES-UNLOCKED ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(collecting\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECTING", "input": "(collecting\n nil\n :key\n nil)", "output": "(defmacro collecting (&body body)\n \"Like `with-collector', with the collector bound to the result of\ninterning `collect' in the current package.\"\n (with-current-package-symbols (collect)\n `(with-collector (,collect)\n ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(all-values)\n\nProblem: Macro call that should be transformed by ALL-VALUES", "input": "(all-values)", "output": "(defmacro ALL-VALUES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(c-envalue\n nil\n (progn))\n\nIssue: Macro call that should be transformed by C-ENVALUE", "input": "(c-envalue\n nil\n (progn))", "output": "(defmacro c-envalue (&body body)\n `(make-c-envaluer\n :envalue-rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cmatch 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by CMATCH", "input": "(cmatch 'lol-gen::some-name)", "output": "(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))))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(f nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by F", "input": "(f nil\n :key\n nil)", "output": "(defmacro F ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(iterate\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by ITERATE", "input": "(iterate\n nil\n nil)", "output": "(defmacro ITERATE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(in-optimizer common-lisp:nil (common-lisp:progn))\n\nProblem: Macro call that should be transformed by IN-OPTIMIZER", "input": "(in-optimizer common-lisp:nil (common-lisp:progn))", "output": "(defmacro in-optimizer (name &optional verbose)\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n ,@(when verbose\n `((when ,verbose (format *trace-output* \"~&Switching to the ~A optimizer~%\" ',name))))\n (setf *optimizer* ',name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-savepoint nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-SAVEPOINT", "input": "(with-savepoint nil\n (progn))", "output": "(defmacro with-savepoint (name &body body)\n \"Can only be used within a transaction. Establishes a savepoint with the given\nname at the start of body, and binds the same name to a handle for that savepoint.\nThe body is executed and, at the end of body, the savepoint is released, unless a\ncondition is thrown, in which case it is rolled back. Execute the body within a\nsavepoint, releasing savepoint when the body exits normally, and rolling back\notherwise. NAME is both the variable that can be used to release or rolled back\nbefore the body unwinds, and the SQL name of the savepoint.\n\nAn example might look like this:\n\n(defun test12 (x &optional (y nil))\n (with-logical-transaction (lt1 :read-committed-rw)\n (execute (:insert-into 'test-data :set 'value 0))\n (with-savepoint sp1\n (execute (:insert-into 'test-data :set 'value 1))\n (if (< x 0)\n (rollback-savepoint sp1)\n (release-savepoint sp1)))\n (with-savepoint sp2\n (execute (:insert-into 'test-data :set 'value 2))\n (with-savepoint sp3\n (execute (:insert-into 'test-data :set 'value 3))\n (if (> x 0)\n (rollback-savepoint sp3)\n (release-savepoint sp3))\n (when y (rollback-savepoint sp2)))\n (if (= x 0)\n (rollback-savepoint sp2)\n (release-savepoint sp2)))\n (when (string= y \\\"abrt\\\")\n (abort-transaction lt1))))\"\n\n `(call-with-savepoint ',name (lambda (,name)\n (declare (ignorable ,name)) ,@body)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(prog2 nil :key nil)\n\nIssue: Macro call that should be transformed by PROG2", "input": "(prog2 nil :key nil)", "output": "(defmacro PROG2 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(accumulating-to nil)\n\nIssue: Macro call that should be transformed by ACCUMULATING-TO", "input": "(accumulating-to nil)", "output": "(defmacro ACCUMULATING-TO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(op\n nil\n nil)\n\nProblem: Macro call that should be transformed by OP", "input": "(op\n nil\n nil)", "output": "(defmacro op (&body body &environment env)\n \"GOO's simple macro for positional lambdas.\n\nAn OP is like a lambda without an argument list. Within the body of the OP\nform, an underscore introduces a new argument.\n\n (reduce (op (set-intersection _ _ :test #'equal))\n sets)\n\nYou can refer back to each argument by number, starting with _1.\n\n (funcall (op (+ _ _1)) 2) => 4\n\nYou can also use positional arguments directly:\n\n (reduce (op (funcall _2 _1)) ...)\n\nArgument lists can be sparse:\n\n (apply (op (+ _1 _3 _5)) '(1 2 3 4 5)) => 9\n\nNote that OP with a single argument is equivalent to CONSTANTLY:\n\n (funcall (op 1)) => 1\n\nand that OP with a single placeholder is equivalent to IDENTITY:\n\n (funcall (op _) 1) => 1\n\nOP can also be used to define variadic functions by using _* as the\nplaceholder. It is not necessary to use APPLY.\n\n (apply (op (+ _*)) '(1 2 3 4)) => 10\n\nOP is intended for simple functions -- one-liners. Parameters are\nextracted according to a depth-first walk of BODY. Macro expansion\nmay, or may not, be done depending on the implementation; it should\nnot be relied on. Lexical bindings may, or may not, shadow\nplaceholders -- again, it depends on the implementation. (This means,\namong other things, that nested use of `op' is not a good idea.)\nBecause of the impossibility of a truly portable code walker, `op'\nwill never be a true replacement for `lambda'. But even if it were\npossible to do better, `op' would still only be suited for one-liners.\nIf you need more than a one-liner, then you should be giving your\nparameters names.\n\n\\(One thing you *can* count on is the ability to use `op' with\nquasiquotes. If using placeholders inside quasiquotes does not work on\nyour Lisp implementation, that's a bug, not a limitation.)\"\n (let ((env (extract-op-env body env)))\n (op-env-lambda env)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(when-let* nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WHEN-LET*", "input": "(when-let* nil\n :key\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(eval-when-load\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by EVAL-WHEN-LOAD", "input": "(eval-when-load\n 'lol-gen::some-name)", "output": "(defmacro EVAL-WHEN-LOAD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(continue-whopper nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by CONTINUE-WHOPPER", "input": "(continue-whopper nil :key nil)", "output": "(defmacro CONTINUE-WHOPPER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(void 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by VOID", "input": "(void 'lol-gen::some-name)", "output": "(defmacro void (place)\n \"Nullify PLACE.\"\n `(setf ,place nil))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(handler-bind 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by HANDLER-BIND", "input": "(handler-bind 'lol-gen::some-name)", "output": "(defmacro HANDLER-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c?once\n nil)\n\nProblem: Macro call that should be transformed by C?ONCE", "input": "(c?once\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(pprint-coalton-codegen\n common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by PPRINT-COALTON-CODEGEN", "input": "(pprint-coalton-codegen\n common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro PPRINT-COALTON-CODEGEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-transaction nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-TRANSACTION", "input": "(with-transaction nil\n :key\n nil)", "output": "(defmacro with-transaction ((&optional name isolation-level) &body body)\n \"Execute the given body within a database transaction, committing it when the\nbody exits normally, and aborting otherwise. An optional name and/or\nisolation-level can be given to the transaction. The name can be used to force\na commit or abort before the body unwinds. The isolation-level will set the\nisolation-level used by the 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 quoted\nor a string) and ... simply indicates other statements would be expected here:\n\n (with-transaction ()\n (execute (:insert-into 'test-data :set 'value 77))\n ...)\n\n (with-transaction (george)\n (execute (:insert-into 'test-data :set 'value 22))\n ...)\n\n (with-transaction (george :read-committed-rw)\n (execute (:insert-into 'test-data :set 'value 33))\n (query (:select '* :from 'test-data))\n ...)\n\n (with-transaction (:serializable)\n (execute (:insert-into 'test-data :set 'value 44))\n ...)\n\nFurther discussion of transactions and isolation levels can found in the\nisolation notes file in the doc folder.\"\n (let ((transaction-name (or (when (not (isolation-level-p name))\n name)\n (gensym \"anonymous-transaction\"))))\n (when (and name (isolation-level-p name))\n (setf isolation-level name))\n `(call-with-transaction (lambda (,transaction-name)\n (declare (ignorable ,transaction-name)) ,@body)\n ,isolation-level)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(without-dependency-capture\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITHOUT-DEPENDENCY-CAPTURE", "input": "(without-dependency-capture\n 'lol-gen::some-name)", "output": "(defmacro WITHOUT-DEPENDENCY-CAPTURE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(f_)\n\nPattern to recognize: Macro call that should be transformed by F_", "input": "(f_)", "output": "(defmacro F_ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(gen-lambda nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by GEN-LAMBDA", "input": "(gen-lambda nil\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(-<>\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by -<>", "input": "(-<>\n nil\n :key\n nil)", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-method-combination nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-METHOD-COMBINATION", "input": "(define-method-combination nil :key nil)", "output": "(defmacro DEFINE-METHOD-COMBINATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-form-binding nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-FORM-BINDING", "input": "(define-form-binding nil\n (progn))", "output": "(defmacro define-form-binding (name (var &rest args) &body body)\n (emit-binding-definition name var args body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(group-by 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by GROUP-BY", "input": "(group-by 'lol-gen::some-name)", "output": "(defmacro group-by (&rest expressions)\n `(apply #'make-clause :group-by ',expressions))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(upper 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by UPPER", "input": "(upper 'lol-gen::some-name)", "output": "(defmacro upper (self &optional (type t))\n `(container-typed ,self ',type))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(raw)\n\nProblem: Macro call that should be transformed by RAW", "input": "(raw)", "output": "(defmacro raw (&rest forms)\n `(list ,@forms))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defguarantee nil\n nil)\n\nProblem: Macro call that should be transformed by DEFGUARANTEE", "input": "(defguarantee nil\n nil)", "output": "(defmacro defguarantee (name (&rest lambda-list) &body body)\n \"Adds a postcondition to the NAMEd function. It can be either a generic or\n non-generic function. If it's the former, then use a specialized lambda list,\n otherwise use an ordinary lambda list. The docstring, if any, will be used in\n failure reports.\"\n #+qpq-postcondition-checks-disabled\n (declare (ignore name lambda-list body))\n #+qpq-postcondition-checks-disabled\n (values)\n #-qpq-postcondition-checks-disabled\n (multiple-value-bind (remaining-forms declarations doc-string)\n (parse-body body :documentation t)\n (declare (ignore declarations))\n (let* ((stripped-ll (strip-lambda-list lambda-list))\n (lambda-vars (remove-if (rcurry #'member\n '(&optional &rest\n &key &allow-other-keys &aux))\n stripped-ll))\n (method `(progn\n (ensure-contracted-function ',name ',stripped-ll)\n (defmethod ,name\n :guarantee\n ,(or doc-string\n (format nil \"~A\"\n (description<-remaining-forms\n remaining-forms)))\n ,lambda-list\n (declare (ignorable ,@lambda-vars))\n ,@body))))\n (if (every #'symbolp lambda-list)\n `(if (and (fboundp ',name)\n (not (typep (fdefinition ',name) 'generic-function)))\n (defcontract ,name :guarantee ,lambda-list\n (declare (ignorable ,@lambda-vars))\n ,@body)\n ,method)\n method))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(export-structure\n common-lisp:nil\n (common-lisp:progn))\n\nPattern to recognize: Macro call that should be transformed by EXPORT-STRUCTURE", "input": "(export-structure\n common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro EXPORT-STRUCTURE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(when-it nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WHEN-IT", "input": "(when-it nil\n :key\n nil)", "output": "(defmacro when-it (test &body body)\n \"Like WHEN. IT is bound to TEST.\"\n `(let ((it ,test))\n (when it\n ,@body)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cond-every\n nil)\n\nIssue: Macro call that should be transformed by COND-EVERY", "input": "(cond-every\n nil)", "output": "(defmacro cond-every (&body clauses)\n \"Like `cond', but instead of stopping after the first clause that\nsucceeds, run all the clauses that succeed.\n\nReturn the value of the last successful clause.\n\nIf a clause begins with `cl:otherwise', it runs only if no preceding\nform has succeeded.\n\nNote that this does *not* do the same thing as a series of `when'\nforms: `cond-every' evaluates *all* the tests *before* it evaluates\nany of the forms.\n\nFrom Zetalisp.\"\n (let* ((otherwise-clause (find 'otherwise clauses :key #'car))\n (test-clauses (remove otherwise-clause clauses))\n (temps (make-gensym-list (length test-clauses))))\n `(let* ,(loop for temp in temps\n for (test . nil) in test-clauses\n collect `(,temp ,test))\n ;; Work around Iterate bug. See\n ;; .\n (if (or ,@temps)\n ,(with-gensyms (ret)\n `(let (,ret)\n ,@(loop for temp in temps\n for (nil . body) in test-clauses\n collect `(when ,temp\n (setf ,ret\n ,(if (null body)\n temp\n `(progn ,@body)))))\n ,ret))\n (progn ,@(rest otherwise-clause))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(local\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LOCAL", "input": "(local\n nil\n :key\n nil)", "output": "(defmacro LOCAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(^k-last)\n\nProblem: Macro call that should be transformed by ^K-LAST", "input": "(^k-last)", "output": "(defmacro ^k-last () `(last-kid self))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(update 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by UPDATE", "input": "(update 'lol-gen::some-name)", "output": "(defmacro update (table &body clauses)\n `(make-statement :update\n ,(expand-expression table) ,@clauses))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(match* common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MATCH*", "input": "(match* common-lisp:nil)", "output": "(defmacro match* (whats &body clauses)\n #.+match*-doc+ \n `(match2* ,whats\n ,@clauses\n (_ nil)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(~>> nil)\n\nProblem: Macro call that should be transformed by ~>>", "input": "(~>> nil)", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7775} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(all-values\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ALL-VALUES", "input": "(all-values\n nil\n :key\n nil)", "output": "(defmacro ALL-VALUES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(return)\n\nWrite a macro that addresses: Macro call that should be transformed by RETURN", "input": "(return)", "output": "(defmacro RETURN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(insert-into nil)\n\nPattern to recognize: Macro call that should be transformed by INSERT-INTO", "input": "(insert-into nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH", "input": "(with 'lol-gen::some-name)", "output": "(defmacro WITH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ccase-let 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by CCASE-LET", "input": "(ccase-let 'lol-gen::some-name)", "output": "(defmacro ccase-let ((var expr) &body cases)\n \"Like (let ((VAR EXPR)) (ccase VAR ...)), with VAR correctable.\"\n `(let ((,var ,expr))\n (ccase ,var\n ,@cases)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(without-symbol-access\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITHOUT-SYMBOL-ACCESS", "input": "(without-symbol-access\n 'lol-gen::some-name)", "output": "(defmacro WITHOUT-SYMBOL-ACCESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(pass nil nil)\n\nPattern to recognize: Macro call that should be transformed by PASS", "input": "(pass nil nil)", "output": "(defmacro pass (&rest message-args)\n \"Simply generate a PASS.\"\n `(add-result 'test-passed\n :test-expr ',message-args\n ,@(when message-args\n `(:reason (format nil ,@message-args)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(~>> nil (progn))\n\nProblem: Macro call that should be transformed by ~>>", "input": "(~>> nil (progn))", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(tree-case nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by TREE-CASE", "input": "(tree-case nil\n nil)", "output": "(defmacro TREE-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(export-only-always 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by EXPORT-ONLY-ALWAYS", "input": "(export-only-always 'lol-gen::some-name)", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(psib 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by PSIB", "input": "(psib 'lol-gen::some-name)", "output": "(defmacro psib (&optional (self-form 'self))\n (let ((self (gensym)))\n `(bwhen (,self ,self-form)\n (find-prior ,self (kids (fm-parent ,self))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond-<>\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by COND-<>", "input": "(cond-<>\n 'lol-gen::some-name)", "output": "(defmacro COND-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(gen-lambda-with-sticky-stop nil)\n\nWhat needs to change: Macro call that should be transformed by GEN-LAMBDA-WITH-STICKY-STOP", "input": "(gen-lambda-with-sticky-stop nil)", "output": "(defmacro gen-lambda-with-sticky-stop (&rest rest)\n `(make-instance \n 'basic-generator \n :function (sticky-stop-lambda ,@rest)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n;; Closure variables are opaque - can't inspect or modify them\n(let ((acc 0) (mul 1))\n (lambda (n)\n (incf acc n)\n (setf mul (* mul n))))\n\n;; To access acc/mul: must add specific getter/setter methods\n;; This doesn't scale - every variable needs its own accessor\n\nPattern to recognize: Closure internals are opaque \u2014 want a general protocol for reading/writing any closed-over variable", "input": ";; Closure variables are opaque - can't inspect or modify them\n(let ((acc 0) (mul 1))\n (lambda (n)\n (incf acc n)\n (setf mul (* mul n))))\n\n;; To access acc/mul: must add specific getter/setter methods\n;; This doesn't scale - every variable needs its own accessor", "output": "(defun pandoriclet-get (letargs)\n `(case sym\n ,@(mapcar #`((,(car a1)) ,(car a1))\n letargs)\n (t (error\n \"Unknown pandoric get: ~a\"\n sym))))\n\n(defun pandoriclet-set (letargs)\n `(case sym\n ,@(mapcar #`((,(car a1))\n (setq ,(car a1) val))\n letargs)\n (t (error\n \"Unknown pandoric set: ~a\"\n sym val))))\n\n(defmacro pandoriclet (letargs &rest body)\n (let ((letargs (cons\n '(this)\n (let-binding-transform\n letargs))))\n `(let (,@letargs)\n (setq this ,@(last body))\n ,@(butlast body)\n (dlambda\n (:pandoric-get (sym)\n ,(pandoriclet-get letargs))\n (:pandoric-set (sym val)\n ,(pandoriclet-set letargs))\n (t (&rest args)\n (apply this args))))))", "category": "dispatch", "technique": "dlambda,nested-backquote,anaphor", "complexity": "advanced", "quality_score": 0.975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(^fm-next-sib)\n\nWhat needs to change: Macro call that should be transformed by ^FM-NEXT-SIB", "input": "(^fm-next-sib)", "output": "(defmacro ^fm-next-sib (&optional (self 'self))\n (let ((s (gensym)))\n `(let ((,s ,self))\n (car (cdr (member ,s (kids (fm-parent ,s))))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(summing\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SUMMING", "input": "(summing\n nil)", "output": "(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))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(collect-first nil (progn))\n\nProblem: Macro call that should be transformed by COLLECT-FIRST", "input": "(collect-first nil (progn))", "output": "(defmacro COLLECT-FIRST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(dispatch-caseql-let nil)\n\nPattern to recognize: Macro call that should be transformed by DISPATCH-CASEQL-LET", "input": "(dispatch-caseql-let nil)", "output": "(defmacro dispatch-caseql-let ((&rest bindings) &body clauses)\n \"Like `dispatch-case-let', but using the clause syntax of `dispatch-caseql'.\"\n `(dispatch-case-let ,bindings\n ,@(expand-dispatch-caseql-clauses clauses)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(drelet* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DRELET*", "input": "(drelet* nil\n (progn))", "output": "(defmacro DRELET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c-input-dbg nil)\n\nProblem: Macro call that should be transformed by C-INPUT-DBG", "input": "(c-input-dbg nil)", "output": "(defmacro c-input-dbg (&optional (value nil valued-p))\n `(make-cell\n :inputp t\n :debug t\n :value-state ,(if valued-p :valid :unbound)\n :value ,value))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(without-dependency-capture\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITHOUT-DEPENDENCY-CAPTURE", "input": "(without-dependency-capture\n nil\n :key\n nil)", "output": "(defmacro WITHOUT-DEPENDENCY-CAPTURE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(eif-let nil\n nil)\n\nProblem: Macro call that should be transformed by EIF-LET", "input": "(eif-let nil\n nil)", "output": "(defmacro eif-let (&whole whole binds &body (then &optional (else nil else?)))\n \"Like `alexandria:if-let', but expects two branches.\nCompare `eif'.\"\n (unless else?\n (warn \"Missing else-branch in eif-let form:~%~a\"\n whole))\n `(if-let ,binds ,then ,else))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(secase nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by SECASE", "input": "(secase nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-port-value-slot nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-PORT-VALUE-SLOT", "input": "(define-port-value-slot nil nil)", "output": "(defmacro DEFINE-PORT-VALUE-SLOT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "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", "input": "(with-condition-restarts nil\n (progn))", "output": "(defmacro WITH-CONDITION-RESTARTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-iterators nil)\n\nIssue: Macro call that should be transformed by WITH-ITERATORS", "input": "(with-iterators nil)", "output": "(defmacro with-iterators (seqs &body forms &environment env)\n \"Create static iterators for one or more sequence.\n\n This macro attempts to determine the type of each sequence, and calls\n MAKE-DOSEQ to generate optimal static iterator code for the given\n sequence types, rather than creating dynamic iterator objects.\n\n SEQS:\n\n A list where each element is of the form (ITER SEQUENCE . ARGS)\n where ITER is a symbol identifying the iterator for the sequence,\n SEQUENCE is the form which evaluates to a sequence, and ARGS are\n the remaining iteration arguments, interpreted as they are to the\n ITERATOR function.\n\n Each iterator identifier (ITER) can be passed to\n WITH-ITER-VALUE, within the body forms of WITH-ITERATORS, to\n retrieve the values of the elements of the sequence.\n\n The iterator identifiers are in a namespace of their own that is\n they do not name lexical variables/symbol-macros nor functions/macros.\n\n\n FORMS:\n\n A list of forms evaluated in an implicit TAGBODY, thus symbols\n are interpreted as tag names.\n\n The WITH-ITER-VALUE macro can be used, within FORMS, to retrieve\n the current element of the sequence and advance the iterator to\n the next position.\n\n The WITH-ITER-PLACE macro can be used, within FORMS, both to\n retrieve and set the value of the current element of the\n sequence, and advance the iterator to the next position.\n\n NOTE: The value of the last form is not returned, due to it being\n evaluated in a TAGBODY, instead NIL is returned. RETURN-FROM, to\n an outer BLOCK, should be used to return a value from this form.\n\n NOTE: Whilst the intended use of WITH-ITERATORS is to implement\n iteration macros, such as DOSEQ, the FORMS are only evaluated\n once. It is up to the user to implement the actual loop, using\n the provided TAGBODY facility.\"\n\n (with-gensyms (end-tag)\n (labels ((expand-doseq (seq args body env)\n (-> (nth-form-type seq env)\n (make-doseq seq args end-tag body env)\n multiple-value-list))\n\n (make-form (bindings get-values places body)\n (->> (make-macros get-values places body)\n (make-bindings bindings)))\n\n (make-macros (get-values places body)\n `(symbol-macrolet\n ((iter-value-macros\n ,(append get-values (iter-value-macros env)))\n\n (iter-place-macros\n ,(append places (iter-place-macros env))))\n\n ,@body))\n\n ;; Tagbody\n\n (make-tagbody (body)\n `((tagbody\n ,@body\n ,end-tag)))\n\n\n ;; Bindings\n\n (make-bindings (bindings body)\n (loop\n for binding in bindings\n for (init constant?) = (multiple-value-list (make-binding binding))\n if constant? collect init into constants\n else collect init into vars\n finally\n (return\n `(symbol-macrolet ,constants\n (let* ,vars ,body)))))\n\n (make-binding (binding)\n (destructuring-bind (var init &key constant) binding\n (if constant\n (multiple-value-bind (value constant?)\n (constant-form-value init env)\n\n (values\n `(,var ,value)\n constant?))\n\n (values\n `(,var ,init)\n nil)))))\n\n (loop\n for (var seq . args) in seqs\n for (bindings body value place) =\n (expand-doseq seq args (make-tagbody forms) env) then\n (expand-doseq seq args form-body env)\n\n for iter-value = (gensym \"ITER-VALUE\")\n for iter-place = (gensym \"ITER-PLACE\")\n for form-body = `((macrolet ((,iter-value ,@value)\n (,iter-place\n ,@(or place\n `((&rest args)\n (declare (ignore args))\n (error \"In WITH-ITER-PLACE: Iterator ~s points to immutable sequence.\" ',var)))))\n ,@body))\n\n append bindings into all-bindings\n collect (cons var iter-value) into get-values\n collect (cons var iter-place) into places\n\n finally\n (return\n (make-form all-bindings get-values places form-body))))))", "category": "anaphoric", "technique": "symbol-macrolet,macrolet,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.83} {"instruction": "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", "input": "(defgeneric nil :key nil)", "output": "(defmacro DEFGENERIC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(necessarily?)\n\nProblem: Macro call that should be transformed by NECESSARILY?", "input": "(necessarily?)", "output": "(defmacro NECESSARILY? ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(count-failures\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by COUNT-FAILURES", "input": "(count-failures\n nil\n :key\n nil)", "output": "(defmacro COUNT-FAILURES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c-in-lazy\n nil)\n\nProblem: Macro call that should be transformed by C-IN-LAZY", "input": "(c-in-lazy\n nil)", "output": "(defmacro c-in-lazy (&body body)\n `(c-input (:lazy :once-asked) (progn ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(select-dao nil\n (progn))\n\nProblem: Macro call that should be transformed by SELECT-DAO", "input": "(select-dao nil\n (progn))", "output": "(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))))))))))", "category": "capture-management", "technique": "macrolet,once-only,gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ok nil)\n\nProblem: Macro call that should be transformed by OK", "input": "(ok nil)", "output": "(defmacro ok (test &optional desc)\n (with-gensyms (duration result)\n (once-only (test desc)\n `(with-catching-errors (:expected T :description ,desc)\n (with-duration ((,duration ,result) ,test)\n (test ,result t ,desc\n :duration ,duration\n :test-fn (lambda (x y)\n (eq (not (null x)) y))\n :got-form ,test))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(compiler-macro-lambda nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by COMPILER-MACRO-LAMBDA", "input": "(compiler-macro-lambda nil\n (progn))", "output": "(defmacro compiler-macro-lambda (lambda-list &body body)\n (introspect-environment:parse-compiler-macro (gensym \"COMPILER-MACRO-LAMBDA\")\n lambda-list\n body))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(enable-quasiquote-2.0)\n\nWrite a macro that addresses: Macro call that should be transformed by ENABLE-QUASIQUOTE-2.0", "input": "(enable-quasiquote-2.0)", "output": "(defmacro ENABLE-QUASIQUOTE-2.0 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(nest common-lisp:nil (common-lisp:progn))\n\nPattern to recognize: Macro call that should be transformed by NEST", "input": "(nest common-lisp:nil (common-lisp:progn))", "output": "(defmacro nest (cl:&rest items)\n \"A syntactic convenience for function application. Transform\n\n (nest f g h x)\n\nto\n\n (f (g (h x))).\"\n (cl:assert (cl:<= 2 (cl:list-length items)))\n (cl:let ((last (cl:last items))\n (butlast (cl:butlast items)))\n (cl:reduce (cl:lambda (x acc)\n (cl:list x acc))\n butlast :from-end cl:t :initial-value (cl:first last))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(-<> 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by -<>", "input": "(-<> 'lol-gen::some-name)", "output": "(defmacro -<> (init &body exps) (diamond-wand init exps))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fn nil nil)\n\nProblem: Macro call that should be transformed by FN", "input": "(fn nil nil)", "output": "(defmacro fn (name type)\n \"A shorthand for declaiming function types.\"\n `(declaim (ftype ,type ,name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-script-symbol-macro nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-SCRIPT-SYMBOL-MACRO", "input": "(define-script-symbol-macro nil\n nil)", "output": "(defmacro DEFINE-SCRIPT-SYMBOL-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-context-variables nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-CONTEXT-VARIABLES", "input": "(with-context-variables nil\n (progn))", "output": "(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))", "category": "dispatch", "technique": "symbol-macrolet", "complexity": "basic", "quality_score": 0.8825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(export-slots)\n\nIssue: Macro call that should be transformed by EXPORT-SLOTS", "input": "(export-slots)", "output": "(defmacro EXPORT-SLOTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(some-<>> 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by SOME-<>>", "input": "(some-<>> 'lol-gen::some-name)", "output": "(defmacro some-<>> (init &body exps) (diamond-wand init exps t t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(acond\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ACOND", "input": "(acond\n 'lol-gen::some-name)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-proxynodes nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-PROXYNODES", "input": "(with-proxynodes nil)", "output": "(defmacro with-proxynodes (proxy-nodes &body body)\n \"define proxy nodes for local usage\"\n (if (not (listp proxy-nodes))\n (setf proxy-nodes (list proxy-nodes)))\n (if proxy-nodes\n (let ((tmp (gensym (format nil \"~:@(proxy-~a-~)\" (first proxy-nodes)))))\n\t;(format t \"Symbol:: ~s\" tmp)\n\t(setf (gethash (first proxy-nodes) *proxy-node*) tmp)\n\t;;for debug/swank, else comment out\n\t;;(eval `(defnode ,tmp (proxy) ()))\n\t;;\n\t`(let ((,(first proxy-nodes) ',tmp))\n\n\t ;(defnode ,tmp (proxy) ())\n\t (defproxy ,tmp)\n\t \n\t (with-proxynodes ,(rest proxy-nodes) ,@body)))\n `(progn ,@body)))", "category": "dsl", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8274999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(flet* nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by FLET*", "input": "(flet* nil\n :key\n nil)", "output": "(defmacro FLET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(do-ast-links 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DO-AST-LINKS", "input": "(do-ast-links 'lol-gen::some-name)", "output": "(defmacro DO-AST-LINKS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(->*\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ->*", "input": "(->*\n nil\n nil)", "output": "(defmacro ->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-foreign-library 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DEFINE-FOREIGN-LIBRARY", "input": "(define-foreign-library 'lol-gen::some-name)", "output": "(defmacro define-foreign-library (name-and-options &body pairs)\n \"Defines a foreign library NAME that can be posteriorly used with\nthe USE-FOREIGN-LIBRARY macro.\"\n (destructuring-bind (name . options)\n (ensure-list name-and-options)\n (check-type name symbol)\n `(register-foreign-library ',name ',pairs ,@options)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-live-scope\n nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-LIVE-SCOPE", "input": "(with-live-scope\n nil\n nil)", "output": "(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))))))", "category": "anaphoric", "technique": "macrolet,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.81} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-fixture-restore nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFINE-FIXTURE-RESTORE", "input": "(define-fixture-restore nil\n :key\n nil)", "output": "(defmacro define-fixture-restore (name args &body body)\n `(progn (setf (gethash ',name *fixture-restores*)\n (lambda ,args ,@body))\n ',name))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(->\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ->", "input": "(->\n 'lol-gen::some-name)", "output": "(defmacro -> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-train nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFINE-TRAIN", "input": "(define-train nil\n (progn))", "output": "(defmacro define-train (name args &body body)\n \"Define a higher-order function and its compiler macro at once.\n\nWhen defining a higher-order function it is often a good idea to\nwrite a compiler macro so compilers can inline the resulting lambda\nform.\n\nFor the special case of a fixed-arity function that only takes other\nfunctions as arguments, you can use `define-train' to define the\nfunction and the compiler macro in one go. The catch is that you have\nto write the single definition as a macro.\n\nE.g., if `complement' did not exist, you could define it like so:\n\n (define-train complement (fn)\n `(lambda (&rest args)\n (not (apply ,fn args))))\n\nBesides providing an implicit compiler macro, `define-train' also\ninserts the proper declarations to ensure the compiler recognizes the\nfunction arguments as functions, avoiding runtime type checks.\n\nThe term \\\"train\\\" is from J.\"\n (multiple-value-bind (body decls docstring)\n (parse-body body :documentation t)\n `(progn\n (define-compiler-macro ,name ,args\n ,@decls\n (rebinding-functions ,args\n ,@body))\n (defun ,name ,args\n ,@(unsplice docstring)\n (macrolet ((,name ,args\n ,@decls\n (rebinding-functions ,args\n ,@body)))\n (,name ,@args))))))", "category": "anaphoric", "technique": "compiler-macro,macrolet,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9299999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-decoder-simple-clos-semantics\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-DECODER-SIMPLE-CLOS-SEMANTICS", "input": "(with-decoder-simple-clos-semantics\n 'lol-gen::some-name)", "output": "(defmacro with-decoder-simple-clos-semantics (&body body)\n \"Execute BODY in a dynamic environement where the decoder semantics\nis such as set by SET-DECODER-SIMPLE-CLOS-SEMANTICS.\"\n `(with-shadowed-custom-vars\n (set-decoder-simple-clos-semantics)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(atypecase 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ATYPECASE", "input": "(atypecase 'lol-gen::some-name)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c_?dbg\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by C_?DBG", "input": "(c_?dbg\n nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-modularize-hook 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-MODULARIZE-HOOK", "input": "(define-modularize-hook 'lol-gen::some-name)", "output": "(defmacro define-modularize-hook ((modulevar &optional identifier) &body body)\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (modularize-hook\n (or ,identifier\n (intern (package-name *package*) \"KEYWORD\")))\n (lambda (,modulevar) ,@body))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(function-call nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FUNCTION-CALL", "input": "(function-call nil nil)", "output": "(defmacro FUNCTION-CALL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-gensyms nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-GENSYMS", "input": "(with-gensyms nil\n nil)", "output": "(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))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(untrace)\n\nWhat needs to change: Macro call that should be transformed by UNTRACE", "input": "(untrace)", "output": "(defmacro UNTRACE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(use-foreign-library nil)\n\nIssue: Macro call that should be transformed by USE-FOREIGN-LIBRARY", "input": "(use-foreign-library nil)", "output": "(defmacro use-foreign-library (name)\n `(load-foreign-library ',name))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(to-boolean common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by TO-BOOLEAN", "input": "(to-boolean common-lisp:nil)", "output": "(defmacro TO-BOOLEAN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(ensure2 nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by ENSURE2", "input": "(ensure2 nil\n (progn))", "output": "(defmacro ensure2 (place &body newval &environment env)\n \"Like `ensure', but specifically for accessors that return a second\nvalue like `gethash'.\"\n (multiple-value-bind (vars vals stores setter getter)\n (get-setf-expansion place env)\n (with-gensyms (old presentp)\n `(let* ,(mapcar #'list vars vals)\n (multiple-value-bind (,old ,presentp)\n ,getter\n (if ,presentp\n ,old\n (multiple-value-bind ,stores\n (progn ,@newval)\n ,setter)))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defmacro* nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFMACRO*", "input": "(defmacro* nil\n (progn))", "output": "(defmacro DEFMACRO* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(returning nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by RETURNING", "input": "(returning nil :key nil)", "output": "(defmacro returning (&rest expressions)\n `(apply #'make-clause :returning\n (list ,@(mapcar (lambda (expr)\n (if (and (listp expr)\n (keywordp (car expr)))\n (expand-op expr)\n `,expr))\n expressions))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(enable-quasi-quoted-bivalent-to-binary-emitting-form-syntax\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BIVALENT-TO-BINARY-EMITTING-FORM-SYNTAX", "input": "(enable-quasi-quoted-bivalent-to-binary-emitting-form-syntax\n 'lol-gen::some-name)", "output": "(defmacro ENABLE-QUASI-QUOTED-BIVALENT-TO-BINARY-EMITTING-FORM-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "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", "input": "(wait-on nil\n :key\n nil)", "output": "(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))))))", "category": "anaphoric", "technique": "once-only,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-vector-dispatch nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-VECTOR-DISPATCH", "input": "(with-vector-dispatch nil\n nil)", "output": "(defmacro with-vector-dispatch ((&rest types) var &body body)\n \"Like `with-subtype-dispatch' with an overall type of `vector'.\"\n ;; Always specialize for simple vectors.\n `(with-subtype-dispatch vector (simple-vector ,@types) ,var\n ,@body))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n($send nil nil)\n\nProblem: Macro call that should be transformed by $SEND", "input": "($send nil nil)", "output": "(defmacro $SEND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(jand)\n\nProblem: Macro call that should be transformed by JAND", "input": "(jand)", "output": "(defmacro jand (&rest args)\n \"JSON-aware version of `cl:and'.\"\n `(and ,@(loop for arg in args\n collecting `(jwhen ,arg ,arg))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(<*> nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by <*>", "input": "(<*> nil :key nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defsyntax 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFSYNTAX", "input": "(defsyntax 'lol-gen::some-name)", "output": "(defmacro defsyntax (name &body options)\n `(progn\n (setf (get ',name :options) ',options)\n (defvar ,name (defreadtable ,name ,@options))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dictq nil (progn))\n\nIssue: Macro call that should be transformed by DICTQ", "input": "(dictq nil (progn))", "output": "(defmacro dictq (&rest keys-and-values)\n \"A literal hash table.\nLike `dict', but the keys and values are implicitly quoted, and the\nhash table is inlined as a literal object.\"\n (apply #'dict keys-and-values))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(matrix-case nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MATRIX-CASE", "input": "(matrix-case nil)", "output": "(defmacro MATRIX-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-explicit-encoder\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-EXPLICIT-ENCODER", "input": "(with-explicit-encoder\n nil\n (progn))", "output": "(defmacro with-explicit-encoder (&body body)\n `(with-local-encoder (use-explicit-encoder)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(letmatch nil\n (progn))\n\nProblem: Macro call that should be transformed by LETMATCH", "input": "(letmatch nil\n (progn))", "output": "(defmacro LETMATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(make-list common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by MAKE-LIST", "input": "(make-list common-lisp:nil)", "output": "(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)))", "category": "control-flow", "technique": "nested-backquote", "complexity": "advanced", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(builder nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by BUILDER", "input": "(builder nil :key nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(some->> nil :key nil)\n\nIssue: Macro call that should be transformed by SOME->>", "input": "(some->> nil :key nil)", "output": "(defmacro SOME->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(shift-decf nil)\n\nPattern to recognize: Macro call that should be transformed by SHIFT-DECF", "input": "(shift-decf nil)", "output": "(defmacro SHIFT-DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(pprint-coalton-codegen-types\n common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-TYPES", "input": "(pprint-coalton-codegen-types\n common-lisp:nil\n common-lisp:nil)", "output": "(defmacro PPRINT-COALTON-CODEGEN-TYPES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(producing 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by PRODUCING", "input": "(producing 'lol-gen::some-name)", "output": "(defmacro PRODUCING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(dotree 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DOTREE", "input": "(dotree 'lol-gen::some-name)", "output": "(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))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "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*", "input": "(defmethod* nil\n :key\n nil)", "output": "(defmacro DEFMETHOD* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(the-part)\n\nWhat needs to change: Macro call that should be transformed by THE-PART", "input": "(the-part)", "output": "(defmacro THE-PART ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(set=)\n\nPattern to recognize: Macro call that should be transformed by SET=", "input": "(set=)", "output": "(defmacro set= (&rest args)\n `(make-clause :set= ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-unique-names nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-UNIQUE-NAMES", "input": "(with-unique-names nil\n :key\n nil)", "output": "(defmacro with-unique-names (names &body forms)\n \"Alias for WITH-GENSYMS.\"\n `(with-gensyms ,names ,@forms))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(ps-to-stream nil)\n\nPattern to recognize: Macro call that should be transformed by PS-TO-STREAM", "input": "(ps-to-stream nil)", "output": "(defmacro PS-TO-STREAM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c?dbg\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by C?DBG", "input": "(c?dbg\n 'lol-gen::some-name)", "output": "(defmacro c?dbg (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :debug t\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defconst nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFCONST", "input": "(defconst nil :key nil)", "output": "(defmacro defconst (symbol init &optional docstring)\n \"Define a constant, lexically.\n\n`defconst' defines a constant using a strategy similar to `def', so\nyou don\u2019t have to +cage+ your constants.\n\nThe constant is only redefined on re-evaluation if INIT has a\ndifferent literal representation than the old value.\n\nA constant defined with `defconst' is guaranteed to be available as\nsoon as it has been defined (for example, for use with reader macros\nlater in the same file). This is not guaranteed to be portably true\nfor `defconstant'.\n\nThe name is from Emacs Lisp.\"\n (let ((backing-var (symbolicate '#:+storage-for-deflex-var- symbol '+)))\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (define-constant ,backing-var ,init\n :test 'same-literal-p\n :documentation ,docstring)\n (define-symbol-macro ,symbol ,backing-var))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-fixtures nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-FIXTURES", "input": "(with-fixtures nil\n :key\n nil)", "output": "(defmacro with-fixtures (fixtures &body body)\n `(call-with-fixtures (lambda () ,@body) ,fixtures))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(newq nil nil)\n\nProblem: Macro call that should be transformed by NEWQ", "input": "(newq nil nil)", "output": "(defmacro NEWQ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(create-table nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by CREATE-TABLE", "input": "(create-table nil\n (progn))", "output": "(defmacro create-table (table column-definitions &body options)\n `(make-statement :create-table\n ',(expand-expression table)\n ,(if (listp (car column-definitions))\n `(list ,@(if column-definitions\n (mapcar\n (lambda (column)\n `(make-column-definition-clause ',(car column) ,@(cdr column)))\n column-definitions)\n nil))\n `,column-definitions)\n ,@(if (and (null (cdr options))\n (null (car options)))\n nil\n options)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defproxyprint nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFPROXYPRINT", "input": "(defproxyprint nil\n :key\n nil)", "output": "(defmacro defproxyprint (qualifier node &body body)\n \"define a pretty-print method for a proxy node\"\n `(defproxymethod ,qualifier (pp pretty-printer) ,node ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(custom-decoder nil nil)\n\nWhat needs to change: Macro call that should be transformed by CUSTOM-DECODER", "input": "(custom-decoder nil nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(initially)\n\nWhat needs to change: Macro call that should be transformed by INITIALLY", "input": "(initially)", "output": "(defmacro INITIALLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(rg? nil)\n\nIssue: Macro call that should be transformed by RG?", "input": "(rg? nil)", "output": "(defmacro rg? (id)\n `(fm-find-registered ,id self nil))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(growf nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by GROWF", "input": "(growf nil nil)", "output": "(defmacro GROWF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dolines 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DOLINES", "input": "(dolines 'lol-gen::some-name)", "output": "(defmacro dolines ((line src &optional result) &body body)\n \"Iterate over each LINE in SRC (a stream or path to a file) as in DOLIST.\"\n (let ((in (gensym)))\n (once-only (src)\n `(if (streamp ,src)\n (loop :for ,line := (read-line ,src nil nil) :while ,line :do\n (progn ,@body)\n :finally (return ,result))\n (with-open-file (,in ,src)\n (loop :for ,line := (read-line ,in nil nil) :while ,line :do\n (progn ,@body)\n :finally (return ,result)))))))", "category": "dsl", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(callback 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by CALLBACK", "input": "(callback 'lol-gen::some-name)", "output": "(defmacro callback (name)\n `(%callback ',name))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(setf nil nil)\n\nProblem: Macro call that should be transformed by SETF", "input": "(setf nil nil)", "output": "(defmacro SETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-type-dispatch nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-TYPE-DISPATCH", "input": "(define-type-dispatch nil\n (progn))", "output": "(defmacro DEFINE-TYPE-DISPATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fm-collect 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by FM-COLLECT", "input": "(fm-collect 'lol-gen::some-name)", "output": "(defmacro fm-collect (md-name &key (must-find t))\n `(fm-find-all self ',md-name :must-find ,must-find))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(bind nil)\n\nWrite a macro that addresses: Macro call that should be transformed by BIND", "input": "(bind nil)", "output": "(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)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.815} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(prog1 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by PROG1", "input": "(prog1 'lol-gen::some-name)", "output": "(defmacro PROG1 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(minf nil)\n\nProblem: Macro call that should be transformed by MINF", "input": "(minf nil)", "output": "(defmacro MINF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(.< 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by .<", "input": "(.< 'lol-gen::some-name)", "output": "(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))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(-<>\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by -<>", "input": "(-<>\n nil\n nil)", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(string-case 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by STRING-CASE", "input": "(string-case 'lol-gen::some-name)", "output": "(defmacro STRING-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ecase-using nil\n nil)\n\nProblem: Macro call that should be transformed by ECASE-USING", "input": "(ecase-using nil\n nil)", "output": "(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)))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(when nil (progn))\n\nPattern to recognize: Macro call that should be transformed by WHEN", "input": "(when nil (progn))", "output": "(defmacro WHEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(deletef nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DELETEF", "input": "(deletef nil (progn))", "output": "(defmacro DELETEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(select-dao nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SELECT-DAO", "input": "(select-dao nil)", "output": "(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))))", "category": "efficiency", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(tree-ecase nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by TREE-ECASE", "input": "(tree-ecase nil\n (progn))", "output": "(defmacro TREE-ECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(match* common-lisp:nil\n (common-lisp:progn))\n\nWrite a macro that addresses: Macro call that should be transformed by MATCH*", "input": "(match* common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro match* (whats &body clauses)\n #.+match*-doc+ \n `(match2* ,whats\n ,@clauses\n (_ nil)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(aand nil (progn))\n\nIssue: Macro call that should be transformed by AAND", "input": "(aand nil (progn))", "output": "(defmacro aand (first &rest rest)\n \"Like AND, except binds the first argument to IT (via LET) for the\nscope of the rest of the arguments.\"\n `(anaphoric and ,first ,@rest))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-took-usec nil)\n\nProblem: Macro call that should be transformed by WITH-TOOK-USEC", "input": "(with-took-usec nil)", "output": "(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))))))))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(def-launched-iter nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEF-LAUNCHED-ITER", "input": "(def-launched-iter nil\n :key\n nil)", "output": "(defmacro DEF-LAUNCHED-ITER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(return)\n\nProblem: Macro call that should be transformed by RETURN", "input": "(return)", "output": "(defmacro RETURN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-dispatch nil\n nil)\n\nIssue: Macro call that should be transformed by DEFINE-DISPATCH", "input": "(define-dispatch nil\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(declare-deprecated-operators nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DECLARE-DEPRECATED-OPERATORS", "input": "(declare-deprecated-operators nil (progn))", "output": "(defmacro DECLARE-DEPRECATED-OPERATORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ensure2 nil\n nil)\n\nProblem: Macro call that should be transformed by ENSURE2", "input": "(ensure2 nil\n nil)", "output": "(defmacro ensure2 (place &body newval &environment env)\n \"Like `ensure', but specifically for accessors that return a second\nvalue like `gethash'.\"\n (multiple-value-bind (vars vals stores setter getter)\n (get-setf-expansion place env)\n (with-gensyms (old presentp)\n `(let* ,(mapcar #'list vars vals)\n (multiple-value-bind (,old ,presentp)\n ,getter\n (if ,presentp\n ,old\n (multiple-value-bind ,stores\n (progn ,@newval)\n ,setter)))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do-iter-values nil\n (progn))\n\nIssue: Macro call that should be transformed by DO-ITER-VALUES", "input": "(do-iter-values nil\n (progn))", "output": "(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))))", "category": "anaphoric", "technique": "tagbody-go,gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond-<>)\n\nWhat needs to change: Macro call that should be transformed by COND-<>", "input": "(cond-<>)", "output": "(defmacro COND-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defpattern common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by DEFPATTERN", "input": "(defpattern common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro defpattern (name args &body body)\n \"Adds a new derived pattern.\nThe default value of &optional arguments are '_, instead of nil.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (symbol-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 '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))))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(f_\n nil\n (progn))\n\nIssue: Macro call that should be transformed by F_", "input": "(f_\n nil\n (progn))", "output": "(defmacro F_ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(dispatch nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by DISPATCH", "input": "(dispatch nil :key nil)", "output": "(defmacro dispatch (generic-function qualifier specialized-lambda-list)\n \"dispatch the hooks using the default dispatcher for the given qualified specific method.\n\nSee define-dispatch\nSee dispatch-function\nSee set-dispatch-for-qualifier\"\n (destructure-specialized-lambda-list descriptive-lambda-list vanilla-lambda-list type-list specialized-lambda-list\n `(funcall (dispatch-function (dispatch-for-qualifier ',qualifier))\n (list ,@vanilla-lambda-list)\n (mapcar #'hook-name\n (specific-hooks-for-generic ',type-list ',generic-function ',qualifier)))))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(implies nil (progn))\n\nProblem: Macro call that should be transformed by IMPLIES", "input": "(implies nil (progn))", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(enable-quasi-quoted-string-syntax)\n\nWhat needs to change: Macro call that should be transformed by ENABLE-QUASI-QUOTED-STRING-SYNTAX", "input": "(enable-quasi-quoted-string-syntax)", "output": "(defmacro ENABLE-QUASI-QUOTED-STRING-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(eval-when-execute\n common-lisp:nil\n :key\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by EVAL-WHEN-EXECUTE", "input": "(eval-when-execute\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro EVAL-WHEN-EXECUTE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(count-of nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by COUNT-OF", "input": "(count-of nil\n :key\n nil)", "output": "(defmacro COUNT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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 ->", "input": "(-> nil :key nil)", "output": "(defmacro -> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is-true nil (progn))\n\nProblem: Macro call that should be transformed by IS-TRUE", "input": "(is-true nil (progn))", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(declaim nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DECLAIM", "input": "(declaim nil\n :key\n nil)", "output": "(defmacro DECLAIM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(econd nil (progn))\n\nIssue: Macro call that should be transformed by ECOND", "input": "(econd nil (progn))", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(inline common-lisp:nil\n (common-lisp:progn))\n\nWrite a macro that addresses: Macro call that should be transformed by INLINE", "input": "(inline common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro INLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-custom-decoder-level nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-CUSTOM-DECODER-LEVEL", "input": "(with-custom-decoder-level nil\n (progn))", "output": "(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)))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(sctypecase nil)\n\nIssue: Macro call that should be transformed by SCTYPECASE", "input": "(sctypecase nil)", "output": "(defmacro sctypecase (keyform &body cases)\n \"Like CTYPECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for\nthe scope of the cases. IT can be set with SETF.\"\n `(symbolic ctypecase ,keyform ,@cases))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(econd 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ECOND", "input": "(econd 'lol-gen::some-name)", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(alt nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ALT", "input": "(alt nil :key nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(multiple-value-ematch common-lisp:nil\n (common-lisp:progn))\n\nIssue: Macro call that should be transformed by MULTIPLE-VALUE-EMATCH", "input": "(multiple-value-ematch common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro multiple-value-ematch (values-form &body clauses)\n #.+multiple-value-match-doc+\n (call-with-mvb-temp-vars\n clauses\n (lambda (clauses temps)\n `(multiple-value-bind ,temps ,values-form\n (match* ,temps\n ,@clauses\n (,temps\n (error 'match-error :pattern ',clauses :values (list ,@temps))))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(is-traced$method 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by IS-TRACED$METHOD", "input": "(is-traced$method 'lol-gen::some-name)", "output": "(defmacro IS-TRACED$METHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with)\n\nIssue: Macro call that should be transformed by WITH", "input": "(with)", "output": "(defmacro WITH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ensure nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by ENSURE", "input": "(ensure nil\n (progn))", "output": "(defmacro ensure (place &body newval\n &environment env)\n \"Essentially (or place (setf place newval)).\n\nPLACE is treated as unbound if it returns `nil', signals\n`unbound-slot', or signals `unbound-variable'.\n\nNote that ENSURE is `setf'-able, so you can do things like\n (incf (ensure x 0))\n\nCf. `ensure2'.\"\n (multiple-value-bind (vars vals stores setter getter)\n (get-setf-expansion place env)\n `(let* ,(mapcar #'list vars vals)\n (or (ignore-some-conditions (unbound-slot unbound-variable)\n ,getter)\n (multiple-value-bind ,stores\n (progn ,@newval)\n (when ,(first stores)\n ,setter))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-special-initargs nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-SPECIAL-INITARGS", "input": "(with-special-initargs nil)", "output": "(defmacro WITH-SPECIAL-INITARGS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(form-attribute nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FORM-ATTRIBUTE", "input": "(form-attribute nil :key nil)", "output": "(defmacro FORM-ATTRIBUTE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(and nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by AND", "input": "(and nil (progn))", "output": "(defmacro AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defpackage nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFPACKAGE", "input": "(defpackage nil (progn))", "output": "(defmacro DEFPACKAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(make* nil nil)\n\nPattern to recognize: Macro call that should be transformed by MAKE*", "input": "(make* nil nil)", "output": "(defmacro MAKE* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fields nil (progn))\n\nProblem: Macro call that should be transformed by FIELDS", "input": "(fields nil (progn))", "output": "(defmacro fields (&rest fields)\n `(make-clause :fields ,@(mapcar #'expand-op fields)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(prog* () :key nil)\n\nWhat needs to change: Macro call that should be transformed by PROG*", "input": "(prog* () :key nil)", "output": "(defmacro PROG* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ignorable common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by IGNORABLE", "input": "(ignorable common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro IGNORABLE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defgeneric* nil\n nil)\n\nProblem: Macro call that should be transformed by DEFGENERIC*", "input": "(defgeneric* nil\n nil)", "output": "(defmacro DEFGENERIC* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fm? 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by FM?", "input": "(fm? 'lol-gen::some-name)", "output": "(defmacro fm? (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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(finally)\n\nIssue: Macro call that should be transformed by FINALLY", "input": "(finally)", "output": "(defmacro FINALLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond-<>>\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by COND-<>>", "input": "(cond-<>>\n nil\n :key\n nil)", "output": "(defmacro COND-<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-walker-handler-lexical-environment\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT", "input": "(with-walker-handler-lexical-environment\n nil\n :key\n nil)", "output": "(defmacro WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(set= 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by SET=", "input": "(set= 'lol-gen::some-name)", "output": "(defmacro set= (&rest args)\n `(make-clause :set= ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-language nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-LANGUAGE", "input": "(define-language nil nil)", "output": "(defmacro DEFINE-LANGUAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(awhen nil)\n\nProblem: Macro call that should be transformed by AWHEN", "input": "(awhen nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-global-var nil nil)\n\nIssue: Macro call that should be transformed by DEFINE-GLOBAL-VAR", "input": "(define-global-var nil nil)", "output": "(defmacro DEFINE-GLOBAL-VAR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(export-always nil)\n\nWhat needs to change: Macro call that should be transformed by EXPORT-ALWAYS", "input": "(export-always nil)", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(list-of nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by LIST-OF", "input": "(list-of nil\n :key\n nil)", "output": "(defmacro LIST-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(pccase nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by PCCASE", "input": "(pccase nil :key nil)", "output": "(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))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(f-sensitivity nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by F-SENSITIVITY", "input": "(f-sensitivity nil\n (progn))", "output": "(defmacro f-sensitivity (synapse-id (sensitivity &optional subtypename) &body body)\n `(call-f-sensitivity ,synapse-id ,sensitivity ,subtypename (lambda () ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(as~> nil :key nil)\n\nIssue: Macro call that should be transformed by AS~>", "input": "(as~> nil :key nil)", "output": "(defmacro as~> (expr name &rest exprs)\n \"Like `~>' or `~>', but instead of threading by position, threading is\ndone based on NAME.\"\n `(let* ,(loop for expr in (cons expr exprs)\n collect (list name expr))\n ,name))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defvariant nil)\n\nProblem: Macro call that should be transformed by DEFVARIANT", "input": "(defvariant nil)", "output": "(defmacro DEFVARIANT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(who-ps-html nil)\n\nProblem: Macro call that should be transformed by WHO-PS-HTML", "input": "(who-ps-html nil)", "output": "(defmacro WHO-PS-HTML ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(execute nil nil)\n\nWhat needs to change: Macro call that should be transformed by EXECUTE", "input": "(execute nil nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defstruct-read-only 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DEFSTRUCT-READ-ONLY", "input": "(defstruct-read-only 'lol-gen::some-name)", "output": "(defmacro defstruct-read-only (name-and-opts &body slots\n &environment env)\n \"Easily define a defstruct with no mutable slots.\n\nThe syntax of `defstruct-read-only' is as close as possible to that of\n`defstruct'. Given an existing structure definition, you can usually\nmake it immutable simply by switching out `defstruct' for\n`defstruct-read-only'.\n\nThere are only a few syntactic differences:\n\n1. To prevent accidentally inheriting mutable slots, and preserve its\n own usefulness as a marker of the programmer's intent,\n `defstruct-read-only' only allows inheritance from other classes\n defined using `defstruct-read-only'.\n\n2. The `:type' option may not be used.\n\n3. The `:copier' option is disabled, because it would be useless.\n\n4. Slot definitions can use slot options without having to provide an\n initform. In this case, any attempt to make an instance of the\n struct without providing a value for that slot will signal an\n error.\n\n (my-slot :type string)\n \u2261 (my-slot (required-argument 'my-slot) :read-only t :type string)\n\nThe idea here is simply that an unbound slot in an immutable data\nstructure does not make sense.\n\nA read-only struct is always externalizable; it has an implicit\ndefinition for `make-load-form'.\n\nOn Lisps that support it, the structure is also marked as \\\"pure\\\":\nthat is, instances may be moved into read-only memory.\n\n`defstruct-read-only' is designed to stay as close to the syntax of\n`defstruct' as possible. The idea is to make it easy to flag data as\nimmutable, whether in your own code or in code you are refactoring. In\nnew code, however, you may sometimes prefer `defconstructor', which is\ndesigned to facilitate working with immutable data.\"\n (flet ((car-safe (x) (if (consp x) (car x) nil)))\n (let ((docstring (and (stringp (first slots)) (pop slots))))\n (destructuring-bind (name . opts) (ensure-list name-and-opts)\n (when-let (copier (find :copier opts :key #'ensure-car))\n (if (null (second copier))\n (removef opts copier)\n (error \"Read only struct ~a does not need a copier.\"\n name)))\n (when-let (clause (find :type opts :key #'car-safe))\n (error \"Read-only structs may not use the ~s option: ~a\"\n :type clause))\n (multiple-value-bind (include-clause opts)\n (include+opts opts)\n (let* ((slot-defs (mapcar #'read-only-slotdef slots))\n (slot-names (mapcar #'first slot-defs)))\n `(progn\n (defstruct (,name (:copier nil)\n ;; Mark as OK to save in pure memory.\n #+(or sbcl cmucl) (:pure t)\n ,@opts\n ,(read-only-include-clause name include-clause env))\n ,@(unsplice docstring)\n ,@slot-defs)\n (defmethod read-only-struct-slot-names append ((self ,name))\n ',slot-names)\n ',name)))))))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dletf* nil)\n\nWhat needs to change: Macro call that should be transformed by DLETF*", "input": "(dletf* nil)", "output": "(defmacro DLETF* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "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", "input": "(let-match common-lisp:nil\n (common-lisp:progn))", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(finishes\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by FINISHES", "input": "(finishes\n 'lol-gen::some-name)", "output": "(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\"))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-standard-io-syntax nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-STANDARD-IO-SYNTAX", "input": "(with-standard-io-syntax nil nil)", "output": "(defmacro WITH-STANDARD-IO-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(on nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ON", "input": "(on nil\n nil)", "output": "(defmacro on (hook args &body body)\n \"Attach a handler with ARGS and BODY to the HOOK.\n\nARGS can be\n- A symbol if there's only one argument to the callback.\n- A list of arguments.\n- An empty list, if the hook handlers take no argument.\"\n (let ((handler-name (gensym \"on-hook-handler\"))\n (args (alexandria:ensure-list args)))\n `(add-hook\n ,hook (make-instance 'handler\n :fn (lambda ,args\n (declare (ignorable ,@args))\n ,@body)\n :name (quote ,handler-name)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(prog1 nil)\n\nProblem: Macro call that should be transformed by PROG1", "input": "(prog1 nil)", "output": "(defmacro PROG1 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(untrace$method 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by UNTRACE$METHOD", "input": "(untrace$method 'lol-gen::some-name)", "output": "(defmacro UNTRACE$METHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cond-> nil)\n\nProblem: Macro call that should be transformed by COND->", "input": "(cond-> nil)", "output": "(defmacro COND-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-method-combination nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-METHOD-COMBINATION", "input": "(define-method-combination nil)", "output": "(defmacro define-method-combination (name &rest args)\n `(progn\n (define-method-combination% ,name ,@args)\n (c2mop:define-method-combination ,name ,@args)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(v-deftype nil :key nil)\n\nProblem: Macro call that should be transformed by V-DEFTYPE", "input": "(v-deftype nil :key nil)", "output": "(defmacro v-deftype (name args type-form\n &key valid-metadata-kinds)\n `(define-vari-type ,name ,args ,type-form :valid-metadata-kinds ,valid-metadata-kinds))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(raw nil)\n\nWhat needs to change: Macro call that should be transformed by RAW", "input": "(raw nil)", "output": "(defmacro raw (&rest forms)\n `(list ,@forms))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defsyntax nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFSYNTAX", "input": "(defsyntax nil\n (progn))", "output": "(defmacro defsyntax (name &body options)\n `(progn\n (setf (get ',name :options) ',options)\n (defvar ,name (defreadtable ,name ,@options))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(drop-view nil)\n\nIssue: Macro call that should be transformed by DROP-VIEW", "input": "(drop-view nil)", "output": "(defmacro drop-view (view-name)\n `(make-statement :drop-view ,view-name))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(deftest 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DEFTEST", "input": "(deftest 'lol-gen::some-name)", "output": "(defmacro deftest (name &body test-forms)\n (let ((tests (gensym \"TESTS\"))\n (test (gensym \"TEST\"))\n (test-fn (gensym \"TEST-FN\")))\n `(progn\n (unless (nth-value 1 (gethash *package* *package-tests*))\n (setf (gethash *package* *package-tests*) '()))\n (let* ((,tests (gethash *package* *package-tests*))\n (,test (assoc ',name ,tests :test #'string=))\n (,test-fn (lambda ()\n (subtest (princ-to-string ',name)\n ,@test-forms))))\n (if ,test\n (rplacd ,test ,test-fn)\n (push (cons ',name ,test-fn) (gethash *package* *package-tests*)))\n ',name))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-shadowed-custom-vars\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-SHADOWED-CUSTOM-VARS", "input": "(with-shadowed-custom-vars\n nil\n nil)", "output": "(defmacro with-shadowed-custom-vars (&body body)\n `(let ,(loop for (var) in *custom-vars*\n collect `(,var (if (boundp ',var) ,var)))\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(nunionf nil nil)\n\nProblem: Macro call that should be transformed by NUNIONF", "input": "(nunionf nil nil)", "output": "(defmacro NUNIONF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(growf nil (progn))\n\nIssue: Macro call that should be transformed by GROWF", "input": "(growf nil (progn))", "output": "(defmacro GROWF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(export\n common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by EXPORT", "input": "(export\n common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro EXPORT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c?n-dbg\n nil)\n\nWhat needs to change: Macro call that should be transformed by C?N-DBG", "input": "(c?n-dbg\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dynamic-progv nil\n (progn))\n\nIssue: Macro call that should be transformed by DYNAMIC-PROGV", "input": "(dynamic-progv nil\n (progn))", "output": "(defmacro DYNAMIC-PROGV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(jor nil nil)\n\nIssue: Macro call that should be transformed by JOR", "input": "(jor nil nil)", "output": "(defmacro jor (&rest args)\n \"JSON-aware version of `cl:or'.\"\n `(or ,@(loop for arg in args\n collecting `(jwhen ,arg ,arg))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(do+\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DO+", "input": "(do+\n 'lol-gen::some-name)", "output": "(defmacro do+ (&body body)\n \"High-level, extensible iteration construct. Refer to the manual for syntax and semantics.\"\n `(do+/internal nil ,@body))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(deftable 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DEFTABLE", "input": "(deftable 'lol-gen::some-name)", "output": "(defmacro deftable (name &body definitions)\n \"Define a table. name can be either a symbol or a (symbol string) list. In the\nfirst case, the table name is derived from the symbol by S-SQL's rules, in the\nsecond case, the name is given explicitly. The body of definitions can contain\nanything that evaluates to a string, as well as S-SQL expressions. In this body,\nthe variables *table-name* and *table-symbol* are bound to the relevant values.\nNote that the evaluation of the definition is ordered, so you will generally\nwant to create your table first and then define indices on it.\"\n (multiple-value-bind (symbol name)\n (if (consp name) (values-list name) (values name (to-sql-name name nil)))\n (flet ((check-s-sql (form)\n (if (and (consp form) (keywordp (car form))) (list 'sql form) form)))\n `(add-table-definition\n ',symbol\n (lambda ()\n (let ((*table-name* ,name) (*table-symbol* ',symbol))\n (dolist (stat (list ,@(mapcar #'check-s-sql definitions)))\n (execute stat))))))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "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 =>", "input": "(=> nil :key nil)", "output": "(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))))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "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", "input": "(with-destructured-lambda-form nil\n (progn))", "output": "(defmacro WITH-DESTRUCTURED-LAMBDA-FORM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defclause 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DEFCLAUSE", "input": "(defclause 'lol-gen::some-name)", "output": "(defmacro defclause (clause-template &body body)\n \"Macro for defining iterate clauses (with DEFUN).\"\n (define-clause 'defun clause-template body nil))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(nearest nil (progn))\n\nWhat needs to change: Macro call that should be transformed by NEAREST", "input": "(nearest nil (progn))", "output": "(defmacro nearest (self-form type)\n (let ((self (gensym)))\n `(bwhen (,self ,self-form)\n (if (typep ,self ',type) ,self (upper ,self ,type)))))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ensure-transaction-with-isolation-level nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by ENSURE-TRANSACTION-WITH-ISOLATION-LEVEL", "input": "(ensure-transaction-with-isolation-level nil\n nil)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(set= nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SET=", "input": "(set= nil nil)", "output": "(defmacro set= (&rest args)\n `(make-clause :set= ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(cell-let nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by CELL-LET", "input": "(cell-let nil\n :key\n nil)", "output": "(defmacro cell-let ((&rest bindings) &body body &environment env)\n \"Define cells that are visible only to the forms in BODY.\n\nBINDINGS is a list of cell bindings to establish, similar to\nLET*. Each item in BINDINGS is a list of the form\n\n.. code-block::\n\n (NAME VALUE-FORM)\n\nwhere NAME is the symbol identifying the cell and VALUE-FORM is the\nvalue form of the cell. The cell can then be referenced within the\nforms in BODY by the symbol NAME.\n\nThe cells defined in BINDINGS lexcially shadow those in the\nenvironment defined with DEFCELL or by an enclosing CELL-LET\nform. Like LET* and unlike LET, each cell definition may reference the\ncells defined earlier in the same CELL-LET.\n\nThe forms in BODY are evaluated in an implicit PROGN. The value\nreturned by the last form is returned by the CELL-LET form.\"\n\n (flet ((make-cell-binding (binding form)\n (destructuring-bind (name &optional initform)\n (ensure-list binding)\n\n (if (constantp initform env)\n `(mutable-cell-let% (,name ,initform) ,form)\n `(computed-cell-let% (,name ,initform) ,form)))))\n\n (->> `(progn ,@body)\n (reduce #'make-cell-binding bindings :from-end t :initial-value))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(psetq nil (progn))\n\nPattern to recognize: Macro call that should be transformed by PSETQ", "input": "(psetq nil (progn))", "output": "(defmacro PSETQ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(continue-whopper nil)\n\nPattern to recognize: Macro call that should be transformed by CONTINUE-WHOPPER", "input": "(continue-whopper nil)", "output": "(defmacro CONTINUE-WHOPPER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-attributes nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-ATTRIBUTES", "input": "(with-attributes nil\n (progn))", "output": "(defmacro WITH-ATTRIBUTES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ensure-gethash nil nil)\n\nIssue: Macro call that should be transformed by ENSURE-GETHASH", "input": "(ensure-gethash nil nil)", "output": "(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))))))", "category": "anaphoric", "technique": "once-only,anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda-ematch*\n common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by LAMBDA-EMATCH*", "input": "(lambda-ematch*\n common-lisp:nil\n common-lisp:nil)", "output": "(defmacro lambda-ematch* (&body body)\n \"Equivalent to (lambda (args...) (ematch* (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 (ematch* ,gensyms\n ,@clauses)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Generate a defmacro form that transforms code like this:\n(select nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by SELECT", "input": "(select nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(restart-bind nil)\n\nProblem: Macro call that should be transformed by RESTART-BIND", "input": "(restart-bind nil)", "output": "(defmacro RESTART-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(-<>>\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by -<>>", "input": "(-<>>\n nil\n :key\n nil)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(deftest nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFTEST", "input": "(deftest nil\n nil)", "output": "(defmacro deftest (name &body test-forms)\n (let ((tests (gensym \"TESTS\"))\n (test (gensym \"TEST\"))\n (test-fn (gensym \"TEST-FN\")))\n `(progn\n (unless (nth-value 1 (gethash *package* *package-tests*))\n (setf (gethash *package* *package-tests*) '()))\n (let* ((,tests (gethash *package* *package-tests*))\n (,test (assoc ',name ,tests :test #'string=))\n (,test-fn (lambda ()\n (subtest (princ-to-string ',name)\n ,@test-forms))))\n (if ,test\n (rplacd ,test ,test-fn)\n (push (cons ',name ,test-fn) (gethash *package* *package-tests*)))\n ',name))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-special-initargs* nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-SPECIAL-INITARGS*", "input": "(with-special-initargs* nil\n (progn))", "output": "(defmacro WITH-SPECIAL-INITARGS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c?+n)\n\nWrite a macro that addresses: Macro call that should be transformed by C?+N", "input": "(c?+n)", "output": "(defmacro c?+n (&body body)\n `(make-c-dependent\n :inputp t\n :code ',body\n :value-state :unevaluated\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(while nil\n (progn))\n\nIssue: Macro call that should be transformed by WHILE", "input": "(while nil\n (progn))", "output": "(defmacro WHILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(select-dao nil (progn))\n\nWhat needs to change: Macro call that should be transformed by SELECT-DAO", "input": "(select-dao nil (progn))", "output": "(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))))", "category": "efficiency", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(select nil\n nil)\n\nProblem: Macro call that should be transformed by SELECT", "input": "(select nil\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dlet* nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by DLET*", "input": "(dlet* nil\n :key\n nil)", "output": "(defmacro DLET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(list-of nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by LIST-OF", "input": "(list-of nil\n (progn))", "output": "(defmacro LIST-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is-false nil)\n\nProblem: Macro call that should be transformed by IS-FALSE", "input": "(is-false nil)", "output": "(defmacro is-false (condition &rest reason-args)\n \"Generates a pass if CONDITION returns false, generates a\n failure otherwise. Like IS-TRUE, and unlike IS, IS-FALSE does\n not inspect CONDITION to determine what reason to give it case\n of test failure\"\n (with-gensyms (value)\n `(let ((,value ,condition))\n (if ,value\n (process-failure ',condition\n ,@(or reason-args\n `(\"~S returned the value ~S, which is true\" ',condition ,value)))\n (add-result 'test-passed :test-expr ',condition)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(block-compile nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by BLOCK-COMPILE", "input": "(block-compile nil\n (progn))", "output": "(defmacro block-compile ((&key entry-points\n (block-compile t))\n &body body)\n \"Shorthand for block compilation with `local*'.\n\nOnly the functions in ENTRY-POINTS will have global definitions. All\nother functions in BODY will be compiled as purely local functions,\nand all of their calls to one another will be compiled as local calls.\nThis includes calls to the entry points, and even self-calls from\nwithin the entry points.\n\nNote that `declaim' forms occuring inside of BODY will be translated\ninto local `declare' forms.\n\nIf you pass `:block-compile nil', this macro is equivalent to progn.\nThis may be useful during development.\"\n (if (not block-compile) `(progn ,@body)\n `(local*\n ,@body\n (progn\n ,@(loop for entry-point in entry-points\n collect `(defalias ,entry-point #',entry-point))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(number-literal 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by NUMBER-LITERAL", "input": "(number-literal 'lol-gen::some-name)", "output": "(defmacro NUMBER-LITERAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(destructuring-bind () :key nil)\n\nProblem: Macro call that should be transformed by DESTRUCTURING-BIND", "input": "(destructuring-bind () :key nil)", "output": "(defmacro DESTRUCTURING-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(optimize common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by OPTIMIZE", "input": "(optimize common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro OPTIMIZE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(-> nil\n nil)\n\nIssue: Macro call that should be transformed by ->", "input": "(-> nil\n nil)", "output": "(defmacro -> (init &body exps) (arrow-macro init exps))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n;; Building a closure with mutable behavior requires manual forwarding\n(let ((counter 0)\n (impl (lambda (n) (incf counter n))))\n (lambda (&rest args)\n (apply impl args)))\n\n;; To change behavior: build an entirely new closure\n\nProblem: Need mutable closure behavior changeable at runtime, with implicit 'this' pointing to current implementation", "input": ";; Building a closure with mutable behavior requires manual forwarding\n(let ((counter 0)\n (impl (lambda (n) (incf counter n))))\n (lambda (&rest args)\n (apply impl args)))\n\n;; To change behavior: build an entirely new closure", "output": "(defmacro alet (letargs &rest body)\n `(let ((this) ,@letargs)\n (setq this ,@(last body))\n ,@(butlast body)\n (lambda (&rest params)\n (apply this params))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.95} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(modf nil nil)\n\nIssue: Macro call that should be transformed by MODF", "input": "(modf nil nil)", "output": "(defmacro modf (place value &rest more &environment env)\n \"Make a new object \\(which may use some of the old object) such that PLACE\nevaluates to VALUE.\n\nMORE should have the form...\n\nMORE : NIL\n | (TEMPORARY-BINDING ANOTHER-MODF-PLACE ANOTHER-VALUE . MORE)\n\nUse it to specify a temporary binding for the new object created which will be\nused in the subsequence MODF-PLACE NEW-VALUE pairs until the end of the MODF\nform.\"\n (if more\n (destructuring-bind (next-symbol next-place next-value &rest next-more) more\n `(let ((,next-symbol ,(modf-expand value place nil env)))\n (modf ,next-place ,next-value ,@next-more)))\n (modf-expand value place nil env)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(<$ nil nil)\n\nPattern to recognize: Macro call that should be transformed by <$", "input": "(<$ nil nil)", "output": "(defmacro <$ (item parser)\n \"Run some parser, but substitute its inner value with some `item' if parsing was\n successful.\"\n (let ((offset (gensym \"<$-OFFSET\"))\n (res (gensym \"<$-RES\"))\n (next (gensym \"<$-NEXT\")))\n `(lambda (,offset)\n (multiple-value-bind (,res ,next) (funcall ,parser ,offset)\n (if (failure? ,res)\n (fail ,next)\n (values ,item ,next))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(minimizing nil)\n\nWhat needs to change: Macro call that should be transformed by MINIMIZING", "input": "(minimizing nil)", "output": "(defmacro MINIMIZING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(pprint-coalton-codegen\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by PPRINT-COALTON-CODEGEN", "input": "(pprint-coalton-codegen\n 'lol-gen::some-name)", "output": "(defmacro PPRINT-COALTON-CODEGEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(slet nil\n nil)\n\nProblem: Macro call that should be transformed by SLET", "input": "(slet nil\n nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n;; Depth-first search with manual backtracking\n(defun search (node)\n (if (goal-p node)\n node\n (let ((children (expand node)))\n (when children\n (let ((result (search (car children))))\n (if result\n result\n (when (cdr children)\n (search (cadr children)))))))))\n;; Manual backtracking is error-prone and obscures the search logic\n\nIssue: Search/backtracking algorithms require manual state management \u2014 want implicit backtracking via nondeterministic choice", "input": ";; Depth-first search with manual backtracking\n(defun search (node)\n (if (goal-p node)\n node\n (let ((children (expand node)))\n (when children\n (let ((result (search (car children))))\n (if result\n result\n (when (cdr children)\n (search (cadr children)))))))))\n;; Manual backtracking is error-prone and obscures the search logic", "output": "(defparameter *paths* nil)\n(defconstant failsym '@)\n\n(defmacro choose (&rest choices)\n (if choices\n `(progn\n ,@(mapcar #'(lambda (c)\n `(push #'(lambda () ,c) *paths*))\n (reverse (cdr choices)))\n ,(car choices))\n '(fail)))\n\n(defmacro choose-bind (var choices &body body)\n `(cb #'(lambda (,var) ,@body) ,choices))\n\n(defun cb (fn choices)\n (if choices\n (progn\n (if (cdr choices)\n (push #'(lambda () (cb fn (cdr choices)))\n *paths*))\n (funcall fn (car choices)))\n (fail)))\n\n(defun fail ()\n (if *paths*\n (funcall (pop *paths*))\n failsym))", "category": "control-flow", "technique": "nested-backquote", "complexity": "advanced", "quality_score": 0.975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(aetypecase nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AETYPECASE", "input": "(aetypecase nil\n :key\n nil)", "output": "(defmacro aetypecase (keyform &body cases)\n \"Like ETYPECASE, except binds the result of the keyform to IT (via LET) for\nthe scope of the cases.\"\n `(anaphoric etypecase ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-global-parameter* nil :key nil)\n\nProblem: Macro call that should be transformed by DEFINE-GLOBAL-PARAMETER*", "input": "(define-global-parameter* nil :key nil)", "output": "(defmacro DEFINE-GLOBAL-PARAMETER* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(v-defstruct nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by V-DEFSTRUCT", "input": "(v-defstruct nil\n :key\n nil)", "output": "(defmacro v-defstruct (name context &body slots)\n `(define-vari-struct ,name ,context ,@slots))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ignore-errors)\n\nProblem: Macro call that should be transformed by IGNORE-ERRORS", "input": "(ignore-errors)", "output": "(defmacro IGNORE-ERRORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(defmethod nil (progn))", "output": "(defmacro defmethod (name &rest args)\n (handler-case\n (multiple-value-bind (qualifiers specializers lambda-list body)\n (parse-method args)\n\n (declare (ignore qualifiers))\n\n (with-gensyms (method)\n (let ((fn-name (gentemp (symbol-name (block-name name)) *method-function-package*)))\n `(progn\n ,(make-method-function name fn-name lambda-list body)\n\n (let ((,method\n (walk-environment\n (c2mop:defmethod ,name ,@args))))\n\n (when (combination-options ',name)\n ,(make-add-method-info name method fn-name body)\n ,(make-static-dispatch name lambda-list specializers))\n\n ,method)))))\n\n (error (e)\n (simple-style-warning \"Error parsing DEFMETHOD form:~%~2T~a\" e)\n `(walk-environment\n (c2mop:defmethod ,name ,@args)))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(with* 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH*", "input": "(with* 'lol-gen::some-name)", "output": "(defmacro WITH* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c_?\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by C_?", "input": "(c_?\n nil\n nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(wtrc nil\n nil)\n\nIssue: Macro call that should be transformed by WTRC", "input": "(wtrc nil\n nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(returning nil nil)\n\nWhat needs to change: Macro call that should be transformed by RETURNING", "input": "(returning nil nil)", "output": "(defmacro RETURNING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c-input-dbg)\n\nWrite a macro that addresses: Macro call that should be transformed by C-INPUT-DBG", "input": "(c-input-dbg)", "output": "(defmacro c-input-dbg (&optional (value nil valued-p))\n `(make-cell\n :inputp t\n :debug t\n :value-state ,(if valued-p :valid :unbound)\n :value ,value))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(some-<>>\n nil\n nil)\n\nProblem: Macro call that should be transformed by SOME-<>>", "input": "(some-<>>\n nil\n nil)", "output": "(defmacro SOME-<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c?n-dbg)\n\nWrite a macro that addresses: Macro call that should be transformed by C?N-DBG", "input": "(c?n-dbg)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-forced-status 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-FORCED-STATUS", "input": "(with-forced-status 'lol-gen::some-name)", "output": "(defmacro with-forced-status ((status &optional description &rest format-args) &body tests)\n `(eval-in-context\n *context*\n (make-instance 'controlling-result\n :expression ,status\n :child-status ,status\n :body (lambda () ,@tests)\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-access nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-ACCESS", "input": "(with-access nil\n nil)", "output": "(defmacro with-access ((&rest keys) val-form &body body)\n \"Similar to with-accessors except using the access functions\"\n (let* ((gval (gensym \"val\"))\n (forms\n (iter (for k in keys)\n (for (k-to k-from) = (if (listp k) k (list k k)))\n (collect `(,k-to (access ,gval ',k-from))))))\n `(let ((,gval ,val-form))\n (declare (ignorable ,gval))\n (symbol-macrolet (,@forms)\n ,@body\n ))))", "category": "dispatch", "technique": "symbol-macrolet,gensym", "complexity": "intermediate", "quality_score": 0.88} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-yield\n nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-YIELD", "input": "(with-yield\n nil\n nil)", "output": "(defmacro WITH-YIELD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(in-package nil)\n\nWhat needs to change: Macro call that should be transformed by IN-PACKAGE", "input": "(in-package nil)", "output": "(defmacro IN-PACKAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(is-expand nil (progn))\n\nIssue: Macro call that should be transformed by IS-EXPAND", "input": "(is-expand nil (progn))", "output": "(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))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defgenerator nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFGENERATOR", "input": "(defgenerator nil\n nil)", "output": "(defmacro defgenerator (name arguments &body body)\n (multiple-value-bind (remaining-forms declarations doc-string)\n (alexandria:parse-body body :documentation t)\n `(defun ,name ,arguments\n ,doc-string\n ,@declarations\n (with-yield\n\t ,@remaining-forms))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(set= nil (progn))\n\nWhat needs to change: Macro call that should be transformed by SET=", "input": "(set= nil (progn))", "output": "(defmacro set= (&rest args)\n `(make-clause :set= ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-boolean 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-BOOLEAN", "input": "(with-boolean 'lol-gen::some-name)", "output": "(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)))))))))", "category": "anaphoric", "technique": "symbol-macrolet,macrolet,anaphor", "complexity": "intermediate", "quality_score": 0.9075} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(maybe-once-only nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by MAYBE-ONCE-ONLY", "input": "(maybe-once-only nil\n (progn))", "output": "(defmacro MAYBE-ONCE-ONLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(finally nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FINALLY", "input": "(finally nil)", "output": "(defmacro FINALLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-gensyms nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-GENSYMS", "input": "(with-gensyms nil\n :key\n nil)", "output": "(defmacro with-gensyms (names &body forms)\n \"Binds a set of variables to gensyms and evaluates the implicit progn FORMS.\n\nEach element within NAMES is either a symbol SYMBOL or a pair (SYMBOL\nSTRING-DESIGNATOR). Bare symbols are equivalent to the pair (SYMBOL SYMBOL).\n\nEach pair (SYMBOL STRING-DESIGNATOR) specifies that the variable named by SYMBOL\nshould be bound to a symbol constructed using GENSYM with the string designated\nby STRING-DESIGNATOR being its first argument.\"\n `(let ,(mapcar (lambda (name)\n (multiple-value-bind (symbol string)\n (etypecase name\n (symbol\n (values name (symbol-name name)))\n ((cons symbol (cons string-designator null))\n (values (first name) (string (second name)))))\n `(,symbol (gensym ,string))))\n names)\n ,@forms))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(incf-pointer nil)\n\nIssue: Macro call that should be transformed by INCF-POINTER", "input": "(incf-pointer nil)", "output": "(defmacro INCF-POINTER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-savepoint nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-SAVEPOINT", "input": "(with-savepoint nil\n :key\n nil)", "output": "(defmacro with-savepoint (conn &body body)\n (let ((ok (gensym \"SAVEPOINT-OK\"))\n (state-var (gensym \"STATE-VAR\"))\n (ident-var (gensym \"SAVEPOINT-IDENTIFIER-VAR\")))\n `(let* ((,state-var (make-instance 'savepoint-state\n :conn ,conn))\n (,ident-var (get-identifier ,state-var))\n (*transaction-state*\n (cons ,state-var\n *transaction-state*))\n ,ok)\n\n (savepoint ,conn ,ident-var)\n (unwind-protect\n (multiple-value-prog1\n (progn ,@body)\n (setf ,ok t))\n (when (eql (get-state ,state-var)\n :in-progress)\n (if ,ok\n (release-savepoint ,conn ,ident-var)\n (rollback-savepoint ,conn ,ident-var)))))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(defaction nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFACTION", "input": "(defaction nil\n nil)", "output": "(defmacro DEFACTION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ensure2 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ENSURE2", "input": "(ensure2 'lol-gen::some-name)", "output": "(defmacro ensure2 (place &body newval &environment env)\n \"Like `ensure', but specifically for accessors that return a second\nvalue like `gethash'.\"\n (multiple-value-bind (vars vals stores setter getter)\n (get-setf-expansion place env)\n (with-gensyms (old presentp)\n `(let* ,(mapcar #'list vars vals)\n (multiple-value-bind (,old ,presentp)\n ,getter\n (if ,presentp\n ,old\n (multiple-value-bind ,stores\n (progn ,@newval)\n ,setter)))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(modf-eval nil)\n\nProblem: Macro call that should be transformed by MODF-EVAL", "input": "(modf-eval nil)", "output": "(defmacro modf-eval (&rest args)\n `(progn ,@args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(pop 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by POP", "input": "(pop 'lol-gen::some-name)", "output": "(defmacro POP ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(ensure-transaction)\n\nPattern to recognize: Macro call that should be transformed by ENSURE-TRANSACTION", "input": "(ensure-transaction)", "output": "(defmacro ensure-transaction (&body body)\n \"Ensures that body is executed within a transaction, but does not begin a new\ntransaction if one is already in progress.\"\n `(call-with-ensured-transaction (lambda () ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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", "input": "(modf-eval nil :key nil)", "output": "(defmacro modf-eval (&rest args)\n `(progn ,@args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(make-method nil)\n\nProblem: Macro call that should be transformed by MAKE-METHOD", "input": "(make-method nil)", "output": "(defmacro make-method (form)\n `(cl:make-method ,form))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cll-outer nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by CLL-OUTER", "input": "(cll-outer nil\n :key\n nil)", "output": "(defmacro cll-outer (val &body body)\n `(let ((outer-val ,val))\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(count-failures)\n\nIssue: Macro call that should be transformed by COUNT-FAILURES", "input": "(count-failures)", "output": "(defmacro COUNT-FAILURES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(some->> 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by SOME->>", "input": "(some->> 'lol-gen::some-name)", "output": "(defmacro some->> (init &body exps) (arrow-macro init exps t t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(try-as common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by TRY-AS", "input": "(try-as common-lisp:nil)", "output": "(defmacro try-as (type cl:&optional (expr cl:nil expr-supplied-p))\n \"A syntactic convenience for type casting.\n\n (try-as )\n\nis equivalent to\n\n (the (Optional ) (tryInto ))\n\nand\n\n (try-as )\n\nis equivalent to\n\n (fn (expr) (the (Optional ) (tryInto expr))).\n\nNote that this may copy the object or allocate memory.\"\n\n (cl:let ((try-into (cl:ignore-errors (cl:find-symbol \"TRYINTO\" \"COALTON/CLASSES\")))\n (Optional (cl:ignore-errors (cl:find-symbol \"OPTIONAL\" \"COALTON/CLASSES\"))))\n (cl:assert try-into () \"`try-as` macro does not have access to `try-into` yet.\")\n (cl:assert Optional () \"`try-as` macro does not have access to `Optional` yet.\")\n (cl:if expr-supplied-p\n `(the (,Optional ,type) (,try-into ,expr))\n (alexandria:with-gensyms (lexpr)\n `(fn (,lexpr)\n (the (,Optional ,type) (,try-into ,lexpr)))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defmethod nil (progn))\n\nIssue: Macro call that should be transformed by DEFMETHOD", "input": "(defmethod nil (progn))", "output": "(defmacro DEFMETHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda* nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by LAMBDA*", "input": "(lambda* nil\n :key\n nil)", "output": "(defmacro LAMBDA* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-method-combination nil (progn))\n\nIssue: Macro call that should be transformed by DEFINE-METHOD-COMBINATION", "input": "(define-method-combination nil (progn))", "output": "(defmacro define-method-combination (name &rest args)\n `(progn\n (define-method-combination% ,name ,@args)\n (c2mop:define-method-combination ,name ,@args)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ignorable common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by IGNORABLE", "input": "(ignorable common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro IGNORABLE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-proxynodes nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-PROXYNODES", "input": "(with-proxynodes nil\n nil)", "output": "(defmacro with-proxynodes (proxy-nodes &body body)\n \"define proxy nodes for local usage\"\n (if (not (listp proxy-nodes))\n (setf proxy-nodes (list proxy-nodes)))\n (if proxy-nodes\n (let ((tmp (gensym (format nil \"~:@(proxy-~a-~)\" (first proxy-nodes)))))\n\t;(format t \"Symbol:: ~s\" tmp)\n\t(setf (gethash (first proxy-nodes) *proxy-node*) tmp)\n\t;;for debug/swank, else comment out\n\t;;(eval `(defnode ,tmp (proxy) ()))\n\t;;\n\t`(let ((,(first proxy-nodes) ',tmp))\n\n\t ;(defnode ,tmp (proxy) ())\n\t (defproxy ,tmp)\n\t \n\t (with-proxynodes ,(rest proxy-nodes) ,@body)))\n `(progn ,@body)))", "category": "dsl", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(maximizing 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by MAXIMIZING", "input": "(maximizing 'lol-gen::some-name)", "output": "(defmacro MAXIMIZING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(custom-decoder nil :key nil)\n\nIssue: Macro call that should be transformed by CUSTOM-DECODER", "input": "(custom-decoder nil :key nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-read-only-vars nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-READ-ONLY-VARS", "input": "(with-read-only-vars nil\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "symbol-macrolet,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8325} {"instruction": "Generate a defmacro form that transforms code like this:\n(defgeneric* nil nil)\n\nPattern to recognize: Macro call that should be transformed by DEFGENERIC*", "input": "(defgeneric* nil nil)", "output": "(defmacro DEFGENERIC* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(possibly?\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by POSSIBLY?", "input": "(possibly?\n nil\n :key\n nil)", "output": "(defmacro POSSIBLY? ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defun-match* common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by DEFUN-MATCH*", "input": "(defun-match* common-lisp:nil\n common-lisp:nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defun-cmatch common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by DEFUN-CMATCH", "input": "(defun-cmatch common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro defun-cmatch (name (arg) &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 (,arg)\n ,@preamble\n (cmatch ,arg\n ,@clauses))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(all nil (progn))\n\nPattern to recognize: Macro call that should be transformed by ALL", "input": "(all nil (progn))", "output": "(defmacro all (parser &rest parsers)\n \"Combination of parsers yielding all results as a list.\"\n `(<*> ,parser ,@parsers))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-min 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COLLECT-MIN", "input": "(collect-min 'lol-gen::some-name)", "output": "(defmacro COLLECT-MIN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(eko-if nil)\n\nIssue: Macro call that should be transformed by EKO-IF", "input": "(eko-if nil)", "output": "(defmacro eko-if ((&rest trcargs) &rest body)\n (let ((result (gensym)))\n `(let ((,result ,@body))\n (when ,result\n (trc ,(car trcargs) :res ,result ,@(cdr trcargs)))\n ,result)))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cll-outer nil\n nil)\n\nIssue: Macro call that should be transformed by CLL-OUTER", "input": "(cll-outer nil\n nil)", "output": "(defmacro cll-outer (val &body body)\n `(let ((outer-val ,val))\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(make 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by MAKE", "input": "(make 'lol-gen::some-name)", "output": "(defmacro MAKE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(when-let nil\n :key\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(letrec nil\n nil)\n\nIssue: Macro call that should be transformed by LETREC", "input": "(letrec nil\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-custom-decoder-level nil)\n\nProblem: Macro call that should be transformed by WITH-CUSTOM-DECODER-LEVEL", "input": "(with-custom-decoder-level nil)", "output": "(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)))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-vector-dispatch nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-VECTOR-DISPATCH", "input": "(with-vector-dispatch nil\n (progn))", "output": "(defmacro with-vector-dispatch ((&rest types) var &body body)\n \"Like `with-subtype-dispatch' with an overall type of `vector'.\"\n ;; Always specialize for simple vectors.\n `(with-subtype-dispatch vector (simple-vector ,@types) ,var\n ,@body))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cond->>\n nil\n nil)\n\nProblem: Macro call that should be transformed by COND->>", "input": "(cond->>\n nil\n nil)", "output": "(defmacro COND->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(and-it nil)\n\nIssue: Macro call that should be transformed by AND-IT", "input": "(and-it nil)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.815} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-generic nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-GENERIC", "input": "(define-generic nil\n (progn))", "output": "(defmacro define-generic (name (&rest arglist) &body body)\n \"Convenience macro to define generics as if they were methods.\nARGLIST can be a method arglist, in which case it's parsed into\ngeneric function arglist by removing method-specific args.\n\nBODY can be a list of `defgeneric' options (processed as-is, even\n:method ones) intermixed with other Lisp forms:\n- If there's a docstring as the first form, it's processed into\n :documentation option of `defgeneric'.\n- If there are non-option forms, they are put together into a separate\n :method option under ARGLIST.\n- If there's a `declare' form:\n - If it's generic-friendly (optimize for speed or space), then it's\n put into both generic body and :method body (if any).\n - Otherwise it's only put into :method (creating it if necessary).\n- If there's an `:export-generic-name-p' boolean option, export (T) or\n don't export (NIL) the generic symbol.\n\nExample:\n\n\\(define-generic add ((a integer) (b integer) &key coerce-to-fixnum &allow-other-keys)\n \\\"Adds A and B, coercing them to fixnum if the sum is too big.\\\"\n (if coerce-to-fixnum\n (coerce (+ a b) 'fixnum)\n (+ a b))\n (:method ((a string) (b integer))\n (error \\\"Cannot use `add' on strings!\\\")))\n=>\n\\(defgeneric add (a b &key &allow-other-keys)\n (:method ((a integer) (b integer) &key coerce-to-fixnum &allow-other-keys)\n (if coerce-to-fixnum\n (coerce (+ a b) 'fixnum)\n (+ a b)))\n (:method ((a string) (b integer))\n (error \\\"Cannot use `add' on strings!\\\"))\n (:documentation \\\"Adds A and B, coercing them to fixnum if the sum is too big.\\\"))\"\n (multiple-value-bind (body declarations documentation)\n (uiop:parse-body body :documentation t)\n (when (and (= 1 (length body))\n (stringp (first body)))\n (style-warn \"Body of DEFINE-GENERIC contains a single string:\n~s.\nIt's interpreted as a method body by default.\n\nIf you meant this string to be a generic docstring, and not a method\nbody, add an explicit NIL or some other body form:\n(define-generic name (arg1 arg2)\n \\\"Docstring\\\"\n 'body-form)\n\nIf you meant it as a body form, do nothing, or provide explicit\ndocumentation or any other option:\n(define-generic name (arg1 arg2)\n \\\"Docstring\\\"\n (:documentation \\\"Real docstring\\\"))\" (first body)))\n (let* ((generic-declarations (remove-if (lambda (d)\n (or (> (length d) 2)\n (not (eq 'optimize (first (second d))))\n (notevery (lambda (o)\n (let ((feature (first (uiop:ensure-list o))))\n (or (eq feature 'speed)\n (eq feature 'space))))\n (rest (second d)))))\n declarations))\n (options (remove-if-not (lambda (form)\n (keywordp (first (uiop:ensure-list form))))\n body))\n (method-body (remove-if (lambda (f) (member f options :test #'equal)) body))\n (export-generic-name-p (find :export-generic-name-p options :key #'first))\n (options (remove export-generic-name-p options :test #'equal))\n (export-p (if export-generic-name-p\n (second export-generic-name-p)\n *export-generic-name-p*))\n (generalized-arglist (generalize-arglist arglist)))\n (when (and (not (equal generalized-arglist arglist))\n (every #'null (list method-body options)))\n (style-warn \"Specialized arglist used without method body in define-generic: ~a\" arglist))\n `(prog1\n (defgeneric ,name ,generalized-arglist\n ,@generic-declarations\n ,@(when (or method-body\n (not (equal generic-declarations\n declarations)))\n `((:method ,arglist\n ,@declarations\n ,@method-body)))\n ,@options\n ,@(when documentation\n `((:documentation ,documentation))))\n ;; FIXME: Maybe only export if package of generic function name\n ;; matches *PACKAGE*?\n ,@(when export-p\n `((eval-when (:compile-toplevel :load-toplevel :execute)\n (export ',name ,(package-name *package*)))))\n ,@(let ((documentation (or documentation\n (second (first (member :documentation options :key #'first))))))\n (when documentation\n `((setf (documentation ',name 'function) ,documentation)\n (setf (documentation (fdefinition ',name) 'function) ,documentation))))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(inext-noexit nil)\n\nIssue: Macro call that should be transformed by INEXT-NOEXIT", "input": "(inext-noexit nil)", "output": "(defmacro INEXT-NOEXIT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(def-kid-slots nil :key nil)\n\nIssue: Macro call that should be transformed by DEF-KID-SLOTS", "input": "(def-kid-slots nil :key nil)", "output": "(defmacro def-kid-slots (&rest slot-defs)\n `(lambda (self)\n (declare (ignorable self))\n (list ,@slot-defs)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(some-<>> nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SOME-<>>", "input": "(some-<>> nil :key nil)", "output": "(defmacro SOME-<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-capped-stack nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-CAPPED-STACK", "input": "(with-capped-stack nil\n (progn))", "output": "(defmacro with-capped-stack (() &body body)\n `(stack-capper (lambda () ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-condition-restarts nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-CONDITION-RESTARTS", "input": "(with-condition-restarts nil\n nil)", "output": "(defmacro WITH-CONDITION-RESTARTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(optimize 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by OPTIMIZE", "input": "(optimize 'lol-gen::some-name)", "output": "(defmacro OPTIMIZE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nreversef 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by NREVERSEF", "input": "(nreversef 'lol-gen::some-name)", "output": "(defmacro NREVERSEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(pprint-coalton-codegen-ast\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-AST", "input": "(pprint-coalton-codegen-ast\n common-lisp:nil)", "output": "(defmacro PPRINT-COALTON-CODEGEN-AST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(defmacro/ps nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFMACRO/PS", "input": "(defmacro/ps nil\n nil)", "output": "(defmacro DEFMACRO/PS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(annotation nil (progn))\n\nWhat needs to change: Macro call that should be transformed by ANNOTATION", "input": "(annotation nil (progn))", "output": "(defmacro ANNOTATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(incf 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by INCF", "input": "(incf 'lol-gen::some-name)", "output": "(defmacro INCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(multiple-value-match common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by MULTIPLE-VALUE-MATCH", "input": "(multiple-value-match common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro multiple-value-match (values-form &body clauses)\n #.+multiple-value-match-doc+\n (call-with-mvb-temp-vars\n clauses\n (lambda (clauses temps)\n `(multiple-value-bind ,temps ,values-form\n (match* ,temps\n ,@clauses)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(setypecase nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by SETYPECASE", "input": "(setypecase nil\n (progn))", "output": "(defmacro setypecase (keyform &body cases)\n \"Like ETYPECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for\nthe scope of the cases. IT can be set with SETF.\"\n `(symbolic etypecase ,keyform ,@cases))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(inext-noexit nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by INEXT-NOEXIT", "input": "(inext-noexit nil (progn))", "output": "(defmacro INEXT-NOEXIT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(min-of nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by MIN-OF", "input": "(min-of nil\n (progn))", "output": "(defmacro MIN-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defwalker-handler nil)\n\nProblem: Macro call that should be transformed by DEFWALKER-HANDLER", "input": "(defwalker-handler nil)", "output": "(defmacro DEFWALKER-HANDLER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-walker-handler-lexical-environment\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT", "input": "(with-walker-handler-lexical-environment\n nil\n (progn))", "output": "(defmacro WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "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 -<>>", "input": "(-<>> nil nil)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n;; Manual dispatch by keyword with multiple lambdas is repetitive\n(let ((count 0))\n (setf (symbol-function 'counter)\n (lambda (&rest args)\n (case (car args)\n (:inc (apply (lambda (n) (incf count n)) (cdr args)))\n (:dec (apply (lambda (n) (decf count n)) (cdr args)))\n (:reset (progn (setf count 0) nil))\n (t (error \"Unknown: ~a\" (car args)))))))\n\n;; Every method: keyword, lambda wrapper, arg destructuring - repetitive\n\nWrite a macro that addresses: Repeated keyword-dispatch with automatic argument destructuring \u2014 each keyword maps to a lambda with its own parameter list", "input": ";; Manual dispatch by keyword with multiple lambdas is repetitive\n(let ((count 0))\n (setf (symbol-function 'counter)\n (lambda (&rest args)\n (case (car args)\n (:inc (apply (lambda (n) (incf count n)) (cdr args)))\n (:dec (apply (lambda (n) (decf count n)) (cdr args)))\n (:reset (progn (setf count 0) nil))\n (t (error \"Unknown: ~a\" (car args)))))))\n\n;; Every method: keyword, lambda wrapper, arg destructuring - repetitive", "output": "(defmacro! dlambda (&rest ds)\n `(lambda (&rest ,g!args)\n (case (car ,g!args)\n ,@(mapcar\n (lambda (d)\n `(,(if (eq t (car d))\n t\n (list (car d)))\n (apply (lambda ,@(cdr d))\n ,(if (eq t (car d))\n g!args\n `(cdr ,g!args)))))\n ds))))", "category": "dispatch", "technique": "dlambda,gensym", "complexity": "intermediate", "quality_score": 0.95} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(the-kids nil (progn))\n\nWhat needs to change: Macro call that should be transformed by THE-KIDS", "input": "(the-kids nil (progn))", "output": "(defmacro the-kids (&rest kids)\n `(let ((*parent* self))\n (packed-flat! ,@kids)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(right-join 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by RIGHT-JOIN", "input": "(right-join 'lol-gen::some-name)", "output": "(defmacro right-join (table &key on using)\n `(join ,table :kind :right :on ,on :using ,using))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(use-syntax nil)\n\nWhat needs to change: Macro call that should be transformed by USE-SYNTAX", "input": "(use-syntax nil)", "output": "(defmacro use-syntax (name)\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (%use-syntax ,name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(deletef nil (progn))\n\nIssue: Macro call that should be transformed by DELETEF", "input": "(deletef nil (progn))", "output": "(defmacro DELETEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(unionf nil nil)\n\nIssue: Macro call that should be transformed by UNIONF", "input": "(unionf nil nil)", "output": "(defmacro UNIONF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-global-var nil :key nil)\n\nProblem: Macro call that should be transformed by DEFINE-GLOBAL-VAR", "input": "(define-global-var nil :key nil)", "output": "(defmacro DEFINE-GLOBAL-VAR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond-> nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by COND->", "input": "(cond-> nil\n :key\n nil)", "output": "(defmacro cond-> (init &body exps) (cond-arrow-macro init exps))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(collect-min nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECT-MIN", "input": "(collect-min nil nil)", "output": "(defmacro COLLECT-MIN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-simple-definition-resolver nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFINE-SIMPLE-DEFINITION-RESOLVER", "input": "(define-simple-definition-resolver nil\n (progn))", "output": "(defmacro define-simple-definition-resolver (class lookup-function &body body)\n (let ((package (gensym \"PACKAGE\")))\n `(define-definition-resolver ,class (,class ,package)\n (when (ignore-errors ,(if body\n `(let ((,(first lookup-function) ,class))\n ,@body)\n `(,lookup-function ,class)))\n (list (make-instance ',class :designator ,class :package ,package))))))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(jmatch nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by JMATCH", "input": "(jmatch nil\n (progn))", "output": "(defmacro jmatch (form &body clauses)\n \"Similar to Trivia match macro, match the FORM (JSON value) against CLAUSES.\nCLAUSES are (PATTERN . BODY) forms, where\n- PATTERN is a `jbind' destructuring pattern.\n- And BODY is an implicit progn.\n\nIf PATTERN matches successfully in `jbind', then BODY is executed with\nthe variables from the PATTERN bound to the respective values, as per\n`jbind'.\n\nThe last clause could start with T, OTHERWISE, ELSE, or _, and it will\nbe invoked if other patterns don't match. If there's no such clause,\n`jmatch' will simply return NIL on no matching patterns.\"\n (let ((form-sym (gensym \"MATCH-FORM\")))\n `(let ((,form-sym ,form))\n (cond\n ,@(loop for (pattern . body) in clauses\n when (and (symbolp pattern)\n (member (symbol-name pattern) '(\"T\" \"_\" \"OTHERWISE\" \"ELSE\")\n :test #'string=))\n collect `(t ,@body)\n else\n collect `((ignore-errors (jbind ,pattern ,form-sym t))\n (jbind ,pattern ,form-sym ,@body)))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(collect 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECT", "input": "(collect 'lol-gen::some-name)", "output": "(defmacro COLLECT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(some-<> nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SOME-<>", "input": "(some-<> nil nil)", "output": "(defmacro SOME-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(without-dependency-capture\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITHOUT-DEPENDENCY-CAPTURE", "input": "(without-dependency-capture\n nil\n nil)", "output": "(defmacro WITHOUT-DEPENDENCY-CAPTURE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(enable-curly-syntax)\n\nIssue: Macro call that should be transformed by ENABLE-CURLY-SYNTAX", "input": "(enable-curly-syntax)", "output": "(defmacro ENABLE-CURLY-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(order-by nil nil)\n\nPattern to recognize: Macro call that should be transformed by ORDER-BY", "input": "(order-by nil nil)", "output": "(defmacro ORDER-BY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(gatherlet nil)\n\nIssue: Macro call that should be transformed by GATHERLET", "input": "(gatherlet nil)", "output": "(defmacro GATHERLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(node 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by NODE", "input": "(node 'lol-gen::some-name)", "output": "(defmacro NODE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-foreign-pointer-as-string 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-FOREIGN-POINTER-AS-STRING", "input": "(with-foreign-pointer-as-string 'lol-gen::some-name)", "output": "(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))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do-variables-in-lexenv 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DO-VARIABLES-IN-LEXENV", "input": "(do-variables-in-lexenv 'lol-gen::some-name)", "output": "(defmacro DO-VARIABLES-IN-LEXENV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(-<>> nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by -<>>", "input": "(-<>> nil\n :key\n nil)", "output": "(defmacro -<>> (init &body exps) (diamond-wand init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ignore-errors nil)\n\nIssue: Macro call that should be transformed by IGNORE-ERRORS", "input": "(ignore-errors nil)", "output": "(defmacro IGNORE-ERRORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(unwrap-as 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by UNWRAP-AS", "input": "(unwrap-as 'lol-gen::some-name)", "output": "(defmacro unwrap-as (type cl:&optional (expr cl:nil expr-supplied-p))\n \"A syntactic convenience for type casting.\n\n (unwrap-as )\n\nis equivalent to\n\n (the (uwrap (tryInto )))\n\nand\n\n (unwrap-as )\n\nis equivalent to\n\n (fn (expr) (the (unwrap (tryInto expr)))).\n\nNote that this may copy the object or allocate memory.\"\n\n (cl:let ((try-into (cl:ignore-errors (cl:find-symbol \"TRYINTO\" \"COALTON/CLASSES\")))\n (unwrap (cl:ignore-errors (cl:find-symbol \"UNWRAP\" \"COALTON/CLASSES\"))))\n (cl:assert try-into () \"`try-as` macro does not have access to `try-into` yet.\")\n (cl:assert unwrap () \"`unwrap` macro does not have access to `unwrap` yet.\")\n (cl:if expr-supplied-p\n `(the ,type (,unwrap (,try-into ,expr)))\n (alexandria:with-gensyms (lexpr)\n `(fn (,lexpr)\n (the ,type (,unwrap (,try-into ,lexpr))))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-properties nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-PROPERTIES", "input": "(with-properties nil\n (progn))", "output": "(defmacro WITH-PROPERTIES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda-match1 common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-MATCH1", "input": "(lambda-match1 common-lisp:nil)", "output": "(defmacro lambda-match1 (pattern &body body)\n \"Equivalent to (lambda (arg) (match arg (PATTERN BODY...))).\"\n `(lambda-match (,pattern ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(documentation common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by DOCUMENTATION", "input": "(documentation common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro DOCUMENTATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(-<> nil (progn))\n\nProblem: Macro call that should be transformed by -<>", "input": "(-<> nil (progn))", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fgathering nil\n (progn))\n\nProblem: Macro call that should be transformed by FGATHERING", "input": "(fgathering nil\n (progn))", "output": "(defmacro FGATHERING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(example\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by EXAMPLE", "input": "(example\n nil\n (progn))", "output": "(defmacro example (&body body)\n \"Like `comment'.\"\n `(comment ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(for nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by FOR", "input": "(for nil\n (progn))", "output": "(defmacro FOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(wtrc nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WTRC", "input": "(wtrc nil\n :key\n nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(letmatch nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by LETMATCH", "input": "(letmatch nil\n :key\n nil)", "output": "(defmacro LETMATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(match2* common-lisp:nil\n (common-lisp:progn))\n\nIssue: Macro call that should be transformed by MATCH2*", "input": "(match2* common-lisp:nil\n (common-lisp:progn))", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda-cmatch\n common-lisp:nil\n (common-lisp:progn))\n\nWrite a macro that addresses: Macro call that should be transformed by LAMBDA-CMATCH", "input": "(lambda-cmatch\n common-lisp:nil\n (common-lisp:progn))", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(possibly?\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by POSSIBLY?", "input": "(possibly?\n nil\n nil)", "output": "(defmacro POSSIBLY? ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-savepoint nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-SAVEPOINT", "input": "(with-savepoint nil\n (progn))", "output": "(defmacro with-savepoint (conn &body body)\n (let ((ok (gensym \"SAVEPOINT-OK\"))\n (state-var (gensym \"STATE-VAR\"))\n (ident-var (gensym \"SAVEPOINT-IDENTIFIER-VAR\")))\n `(let* ((,state-var (make-instance 'savepoint-state\n :conn ,conn))\n (,ident-var (get-identifier ,state-var))\n (*transaction-state*\n (cons ,state-var\n *transaction-state*))\n ,ok)\n\n (savepoint ,conn ,ident-var)\n (unwind-protect\n (multiple-value-prog1\n (progn ,@body)\n (setf ,ok t))\n (when (eql (get-state ,state-var)\n :in-progress)\n (if ,ok\n (release-savepoint ,conn ,ident-var)\n (rollback-savepoint ,conn ,ident-var)))))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nix nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NIX", "input": "(nix nil :key nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(xhtml 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by XHTML", "input": "(xhtml 'lol-gen::some-name)", "output": "(defmacro xhtml (&rest tags)\n `(with-doctype :xhtml\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(asif nil nil)\n\nPattern to recognize: Macro call that should be transformed by ASIF", "input": "(asif nil nil)", "output": "(defmacro asif (test then &optional else)\n \"Like IF, except binds the result of the test to IT (via LET) for\nthe the scope of the then-expression, and the test form to IT (via\nSYMBOL-MACROLET) for the scope of the else-expression. Within scope of\nthe else-expression, IT can be set with SETF.\"\n `(let ((it ,test))\n (if it\n\t ,then\n\t (symbolic ignore-first ,test ,else))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(collect-min nil :key nil)\n\nProblem: Macro call that should be transformed by COLLECT-MIN", "input": "(collect-min nil :key nil)", "output": "(defmacro COLLECT-MIN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(.< common-lisp:nil :key common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by .<", "input": "(.< common-lisp:nil :key common-lisp:nil)", "output": "(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))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(appendf 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by APPENDF", "input": "(appendf 'lol-gen::some-name)", "output": "(defmacro APPENDF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(alet nil\n (progn))\n\nIssue: Macro call that should be transformed by ALET", "input": "(alet nil\n (progn))", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-truncated-stack nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-TRUNCATED-STACK", "input": "(with-truncated-stack nil\n nil)", "output": "(defmacro with-truncated-stack (() &body body)\n `(stack-truncator (lambda () ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(handler-bind nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by HANDLER-BIND", "input": "(handler-bind nil\n :key\n nil)", "output": "(defmacro HANDLER-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(defun nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFUN", "input": "(defun nil (progn))", "output": "(defmacro DEFUN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(acond)\n\nProblem: Macro call that should be transformed by ACOND", "input": "(acond)", "output": "(defmacro ACOND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(gather-next nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by GATHER-NEXT", "input": "(gather-next nil nil)", "output": "(defmacro GATHER-NEXT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(f-plusp nil (progn))\n\nProblem: Macro call that should be transformed by F-PLUSP", "input": "(f-plusp nil (progn))", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(for-all* nil)\n\nPattern to recognize: Macro call that should be transformed by FOR-ALL*", "input": "(for-all* nil)", "output": "(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))))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(eif nil nil)\n\nProblem: Macro call that should be transformed by EIF", "input": "(eif nil nil)", "output": "(defmacro eif (&whole whole test then &optional (else nil else?))\n \"Like `cl:if', but expects two branches.\n\nIf there is only one branch a warning is signaled.\n\nThis macro is useful when writing explicit decision trees; it will\nwarn you if you forget a branch.\n\nShort for \u201cexhaustive if\u201d.\"\n (unless else?\n (warn \"Missing else-branch in eif form:~%~a\"\n whole))\n `(if ,test ,then ,else))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(defvar nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by DEFVAR", "input": "(defvar nil :key nil)", "output": "(defmacro DEFVAR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-symbol-access\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-SYMBOL-ACCESS", "input": "(with-symbol-access\n 'lol-gen::some-name)", "output": "(defmacro WITH-SYMBOL-ACCESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-html-string\n nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-HTML-STRING", "input": "(with-html-string\n nil\n nil)", "output": "(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)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(op)\n\nWrite a macro that addresses: Macro call that should be transformed by OP", "input": "(op)", "output": "(defmacro op (&body body &environment env)\n \"GOO's simple macro for positional lambdas.\n\nAn OP is like a lambda without an argument list. Within the body of the OP\nform, an underscore introduces a new argument.\n\n (reduce (op (set-intersection _ _ :test #'equal))\n sets)\n\nYou can refer back to each argument by number, starting with _1.\n\n (funcall (op (+ _ _1)) 2) => 4\n\nYou can also use positional arguments directly:\n\n (reduce (op (funcall _2 _1)) ...)\n\nArgument lists can be sparse:\n\n (apply (op (+ _1 _3 _5)) '(1 2 3 4 5)) => 9\n\nNote that OP with a single argument is equivalent to CONSTANTLY:\n\n (funcall (op 1)) => 1\n\nand that OP with a single placeholder is equivalent to IDENTITY:\n\n (funcall (op _) 1) => 1\n\nOP can also be used to define variadic functions by using _* as the\nplaceholder. It is not necessary to use APPLY.\n\n (apply (op (+ _*)) '(1 2 3 4)) => 10\n\nOP is intended for simple functions -- one-liners. Parameters are\nextracted according to a depth-first walk of BODY. Macro expansion\nmay, or may not, be done depending on the implementation; it should\nnot be relied on. Lexical bindings may, or may not, shadow\nplaceholders -- again, it depends on the implementation. (This means,\namong other things, that nested use of `op' is not a good idea.)\nBecause of the impossibility of a truly portable code walker, `op'\nwill never be a true replacement for `lambda'. But even if it were\npossible to do better, `op' would still only be suited for one-liners.\nIf you need more than a one-liner, then you should be giving your\nparameters names.\n\n\\(One thing you *can* count on is the ability to use `op' with\nquasiquotes. If using placeholders inside quasiquotes does not work on\nyour Lisp implementation, that's a bug, not a limitation.)\"\n (let ((env (extract-op-env body env)))\n (op-env-lambda env)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(gatherlet nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by GATHERLET", "input": "(gatherlet nil\n :key\n nil)", "output": "(defmacro GATHERLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c?_)\n\nWhat needs to change: Macro call that should be transformed by C?_", "input": "(c?_)", "output": "(defmacro c?_ (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :lazy t\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(quasiquote 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by QUASIQUOTE", "input": "(quasiquote 'lol-gen::some-name)", "output": "(defmacro quasiquote (x) (quasiquote-expand x))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "basic", "quality_score": 0.7925} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-special-initargs* nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-SPECIAL-INITARGS*", "input": "(with-special-initargs* nil)", "output": "(defmacro WITH-SPECIAL-INITARGS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(match2 common-lisp:nil)\n\nIssue: Macro call that should be transformed by MATCH2", "input": "(match2 common-lisp:nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-packages-unlocked 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-PACKAGES-UNLOCKED", "input": "(with-packages-unlocked 'lol-gen::some-name)", "output": "(defmacro WITH-PACKAGES-UNLOCKED ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(some-<> nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by SOME-<>", "input": "(some-<> nil\n nil)", "output": "(defmacro some-<> (init &body exps) (diamond-wand init exps nil t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defunwalker-handler nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFUNWALKER-HANDLER", "input": "(defunwalker-handler nil\n :key\n nil)", "output": "(defmacro DEFUNWALKER-HANDLER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(failure? nil)\n\nWhat needs to change: Macro call that should be transformed by FAILURE?", "input": "(failure? nil)", "output": "(defmacro failure? (x)\n \"Did parsing fail?\"\n `(eq :fail ,x))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(as-> nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by AS->", "input": "(as-> nil\n :key\n nil)", "output": "(defmacro as-> (init var &body exps)\n `(let ((,var ,init))\n ,var\n ,@(loop for (exp next-exp) on exps\n collect (if next-exp `(setf ,var ,exp) exp))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(accase nil\n nil)\n\nIssue: Macro call that should be transformed by ACCASE", "input": "(accase nil\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(wtrc nil\n (progn))\n\nIssue: Macro call that should be transformed by WTRC", "input": "(wtrc nil\n (progn))", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(and)\n\nIssue: Macro call that should be transformed by AND", "input": "(and)", "output": "(defmacro AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(sunless nil)\n\nProblem: Macro call that should be transformed by SUNLESS", "input": "(sunless nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(gathering nil)\n\nProblem: Macro call that should be transformed by GATHERING", "input": "(gathering nil)", "output": "(defmacro GATHERING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda* nil)\n\nProblem: Macro call that should be transformed by LAMBDA*", "input": "(lambda* nil)", "output": "(defmacro LAMBDA* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(in-package common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by IN-PACKAGE", "input": "(in-package common-lisp:nil)", "output": "(defmacro IN-PACKAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(->> nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by ->>", "input": "(->> nil (progn))", "output": "(defmacro ->> (x &rest forms)\n \"Threads the expr through FORMS. Inserts X as the\n last item in the first form, or in place of % if it is present in the form,\n making a list of it if it is not a list already.\n If there are more forms, inserts the first form\n as the last item in second form, etc.\"\n (if (first forms)\n (let* ((form (first forms))\n (threaded (if (listp form)\n (if (member '% form)\n `(funcall (lambda (%) ,form) ,x)\n `(,(first form) ,@(rest form) ,x))\n `(,form ,x))))\n `(->> ,threaded ,@(rest forms)))\n x))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-alternate-type-name nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-ALTERNATE-TYPE-NAME", "input": "(define-alternate-type-name nil (progn))", "output": "(defmacro define-alternate-type-name (current-type-name alternate-type-name)\n `(add-alternate-type-name ',alternate-type-name ',current-type-name))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(the nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by THE", "input": "(the nil (progn))", "output": "(defmacro THE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(-<>>\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by -<>>", "input": "(-<>>\n 'lol-gen::some-name)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(jbind nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by JBIND", "input": "(jbind nil\n (progn))", "output": "(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))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(generating nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by GENERATING", "input": "(generating nil (progn))", "output": "(defmacro GENERATING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defloop nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFLOOP", "input": "(defloop nil\n nil)", "output": "(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))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(local\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by LOCAL", "input": "(local\n nil\n (progn))", "output": "(defmacro LOCAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nunionf nil (progn))\n\nIssue: Macro call that should be transformed by NUNIONF", "input": "(nunionf nil (progn))", "output": "(defmacro NUNIONF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-unique-js-names nil nil)\n\nIssue: Macro call that should be transformed by WITH-UNIQUE-JS-NAMES", "input": "(with-unique-js-names nil nil)", "output": "(defmacro WITH-UNIQUE-JS-NAMES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(as-array-member nil)\n\nProblem: Macro call that should be transformed by AS-ARRAY-MEMBER", "input": "(as-array-member nil)", "output": "(defmacro as-array-member ((&optional (stream '*json-output*))\n &body body)\n \"BODY should be a program which encodes exactly one JSON datum to\nSTREAM. AS-ARRAY-MEMBER ensures that the datum is properly formatted\nas a Member of an Array, i. e. separated by comma from any preceding\nor following Member.\"\n `(progn\n (next-aggregate-member 'array ,stream)\n ,@body))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "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", "input": "(with-context-variables nil\n :key\n nil)", "output": "(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))", "category": "dispatch", "technique": "symbol-macrolet", "complexity": "basic", "quality_score": 0.8825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(possibly?)\n\nProblem: Macro call that should be transformed by POSSIBLY?", "input": "(possibly?)", "output": "(defmacro POSSIBLY? ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(from 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by FROM", "input": "(from 'lol-gen::some-name)", "output": "(defmacro from (&rest statements)\n `(make-clause :from ,@(mapcar #'expand-op statements)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(xhtml nil :key nil)\n\nIssue: Macro call that should be transformed by XHTML", "input": "(xhtml nil :key nil)", "output": "(defmacro xhtml (&rest tags)\n `(with-doctype :xhtml\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-simple-object-lookup nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-SIMPLE-OBJECT-LOOKUP", "input": "(define-simple-object-lookup nil\n nil)", "output": "(defmacro define-simple-object-lookup (class lookup-function &body body)\n `(defmethod object ((,class ,class))\n ,(if body\n `(let ((,(first lookup-function) ,class))\n ,@body)\n `(,lookup-function (designator ,class)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(vect-of nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by VECT-OF", "input": "(vect-of nil nil)", "output": "(defmacro VECT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(sctypecase nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SCTYPECASE", "input": "(sctypecase nil\n nil)", "output": "(defmacro sctypecase (keyform &body cases)\n \"Like CTYPECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for\nthe scope of the cases. IT can be set with SETF.\"\n `(symbolic ctypecase ,keyform ,@cases))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(f-plusp nil)\n\nWhat needs to change: Macro call that should be transformed by F-PLUSP", "input": "(f-plusp nil)", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(batch\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by BATCH", "input": "(batch\n nil\n nil)", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(fields)\n\nPattern to recognize: Macro call that should be transformed by FIELDS", "input": "(fields)", "output": "(defmacro fields (&rest fields)\n `(make-clause :fields ,@(mapcar #'expand-op fields)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(quasiquote nil (progn))\n\nIssue: Macro call that should be transformed by QUASIQUOTE", "input": "(quasiquote nil (progn))", "output": "(defmacro QUASIQUOTE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-file nil nil)\n\nIssue: Macro call that should be transformed by COLLECT-FILE", "input": "(collect-file nil nil)", "output": "(defmacro COLLECT-FILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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 ->*", "input": "(->* nil (progn))", "output": "(defmacro ->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(-> nil (progn))\n\nProblem: Macro call that should be transformed by ->", "input": "(-> nil (progn))", "output": "(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)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Generate a defmacro form that transforms code like this:\n(defmethods nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFMETHODS", "input": "(defmethods nil\n (progn))", "output": "(defmacro defmethods (class (self . slots) &body body)\n \"Concisely define methods that specialize on the same class.\n\nYou can already use `defgeneric' to define an arbitrary number of\nmethods on a single generic function without having to repeat the name\nof the function:\n\n (defgeneric fn (x)\n (:method ((x string)) ...)\n (:method ((x number)) ...))\n\nWhich is equivalent to:\n\n (defgeneric fn (x))\n\n (defmethod fn ((x string))\n ...)\n\n (defmethod fn ((x number))\n ...)\n\nSimilarly, you can use `defmethods' to define methods that specialize\non the same class, and access the same slots, without having to\nrepeat the names of the class or the slots:\n\n (defmethods my-class (self x y)\n (:method initialize-instance :after (self &key)\n ...)\n (:method print-object (self stream)\n ...)\n (:method some-method ((x string) self)\n ...))\n\nWhich is equivalent to:\n\n (defmethod initialize-instance :after ((self my-class) &key)\n (with-slots (x y) self\n ...))\n\n (defmethod print-object ((self my-class) stream)\n (with-slots (x y) self\n ...))\n\n (defmethod some-method ((x string) (self my-class))\n (with-slots (y) self ;!\n ...))\n\nNote in particular that `self' can appear in any position, and that\nyou can freely specialize the other arguments.\n\nJust as in `with-slots', slots can be renamed:\n\n (defmethods my-class (self (abscissa x) (ordinate y))\n ...)\n\nYou can also use `defmethods' in place of `with-accessors', by using a\nfunction-quote:\n\n (defmethods my-class (self (x #'my-class-x)\n (y #'my-class-y))\n ...)\n\n\\(The difference from using `with-slots' is the scope of the slot\nbindings: they are established *outside* of the method definition,\nwhich means argument bindings shadow slot bindings:\n\n (some-method \\\"foo\\\" (make 'my-class :x \\\"bar\\\"))\n => \\\"foo\\\"\n\nSince slot bindings are lexically outside the argument bindings, this\nis surely correct, even if it makes `defmethods' slightly harder to\nexplain in terms of simpler constructs.)\n\nIs `defmethods' trivial? Yes, in terms of its implementation. This\ndocstring is far longer than the code it documents. But you may find\nit does a lot to keep heavily object-oriented code readable and\norganized, without any loss of power.\n\nNote that `defmethods' may also be useful when converting state\nmachines written using `labels' into an object-oriented style.\n\nThis construct is very loosely inspired by impl blocks in Rust.\"\n (mvlet* ((slot-names slot-binds\n (loop for slot in slots\n if (listp slot)\n collect slot into slot-binds\n and collect (first slot) into slot-names\n else\n collect slot into slot-names\n and collect (list slot slot) into slot-binds\n finally (return (values slot-names slot-binds))))\n (body decls\n (parse-body body))\n (slot-decls decls\n (partition-declarations slot-names decls)))\n `(macrolet ((:method (name &body args)\n (mvlet* ((class ',class)\n (self ',self)\n (slot-binds ',slot-binds)\n (qualifiers lambda-list body\n (parse-defmethod-args args))\n (body decls docstring (parse-body body :documentation t))\n (ll-with-self (substitute (list self class) self lambda-list)))\n (when (equal ll-with-self lambda-list)\n (error \"No binding for ~s in ~s\" self lambda-list))\n `(symbol-macrolet ,(loop for (alias ref) in slot-binds\n collect (ematch ref\n ((and ref (type symbol))\n `(,alias (slot-value ,self ',ref)))\n ((list 'function fn)\n `(,alias (,fn ,self)))))\n ,@',slot-decls\n (defmethod ,name ,@qualifiers ,ll-with-self\n ,@(unsplice docstring)\n ,@decls\n ,@body)))))\n ,@decls\n ,@body)))", "category": "anaphoric", "technique": "symbol-macrolet,macrolet,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9299999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(inline)\n\nWhat needs to change: Macro call that should be transformed by INLINE", "input": "(inline)", "output": "(defmacro INLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(let-match* common-lisp:nil\n (common-lisp:progn))\n\nWrite a macro that addresses: Macro call that should be transformed by LET-MATCH*", "input": "(let-match* common-lisp:nil\n (common-lisp:progn))", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(export-constructors\n common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by EXPORT-CONSTRUCTORS", "input": "(export-constructors\n common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro EXPORT-CONSTRUCTORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(xor nil :key nil)\n\nProblem: Macro call that should be transformed by XOR", "input": "(xor nil :key nil)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ith-value nil (progn))\n\nIssue: Macro call that should be transformed by ITH-VALUE", "input": "(ith-value nil (progn))", "output": "(defmacro ITH-VALUE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fgatherlet nil\n (progn))\n\nIssue: Macro call that should be transformed by FGATHERLET", "input": "(fgatherlet nil\n (progn))", "output": "(defmacro FGATHERLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(distinct-on nil (progn))\n\nIssue: Macro call that should be transformed by DISTINCT-ON", "input": "(distinct-on nil (progn))", "output": "(defmacro distinct-on (columns &rest fields)\n `(make-clause :distinct-on (list ,@columns) ,@(mapcar #'expand-op fields)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-unknown-first-class-functions-allowed\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-UNKNOWN-FIRST-CLASS-FUNCTIONS-ALLOWED", "input": "(with-unknown-first-class-functions-allowed\n 'lol-gen::some-name)", "output": "(defmacro with-unknown-first-class-functions-allowed (&body body)\n `(let ((*allow-call-function-signature* t))\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(op\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by OP", "input": "(op\n nil\n :key\n nil)", "output": "(defmacro op (&body body &environment env)\n \"GOO's simple macro for positional lambdas.\n\nAn OP is like a lambda without an argument list. Within the body of the OP\nform, an underscore introduces a new argument.\n\n (reduce (op (set-intersection _ _ :test #'equal))\n sets)\n\nYou can refer back to each argument by number, starting with _1.\n\n (funcall (op (+ _ _1)) 2) => 4\n\nYou can also use positional arguments directly:\n\n (reduce (op (funcall _2 _1)) ...)\n\nArgument lists can be sparse:\n\n (apply (op (+ _1 _3 _5)) '(1 2 3 4 5)) => 9\n\nNote that OP with a single argument is equivalent to CONSTANTLY:\n\n (funcall (op 1)) => 1\n\nand that OP with a single placeholder is equivalent to IDENTITY:\n\n (funcall (op _) 1) => 1\n\nOP can also be used to define variadic functions by using _* as the\nplaceholder. It is not necessary to use APPLY.\n\n (apply (op (+ _*)) '(1 2 3 4)) => 10\n\nOP is intended for simple functions -- one-liners. Parameters are\nextracted according to a depth-first walk of BODY. Macro expansion\nmay, or may not, be done depending on the implementation; it should\nnot be relied on. Lexical bindings may, or may not, shadow\nplaceholders -- again, it depends on the implementation. (This means,\namong other things, that nested use of `op' is not a good idea.)\nBecause of the impossibility of a truly portable code walker, `op'\nwill never be a true replacement for `lambda'. But even if it were\npossible to do better, `op' would still only be suited for one-liners.\nIf you need more than a one-liner, then you should be giving your\nparameters names.\n\n\\(One thing you *can* count on is the ability to use `op' with\nquasiquotes. If using placeholders inside quasiquotes does not work on\nyour Lisp implementation, that's a bug, not a limitation.)\"\n (let ((env (extract-op-env body env)))\n (op-env-lambda env)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(unless nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by UNLESS", "input": "(unless nil :key nil)", "output": "(defmacro UNLESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(product-of nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by PRODUCT-OF", "input": "(product-of nil\n nil)", "output": "(defmacro PRODUCT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make-dispatcher 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by MAKE-DISPATCHER", "input": "(make-dispatcher 'lol-gen::some-name)", "output": "(defmacro make-dispatcher (function-constructor)\n `(make-instance 'dispatcher :dispatch-function-constructor ',function-constructor\n :dispatch-function ,function-constructor))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(walk-environment\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WALK-ENVIRONMENT", "input": "(walk-environment\n nil\n :key\n nil)", "output": "(defmacro WALK-ENVIRONMENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(wait-on nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WAIT-ON", "input": "(wait-on nil\n (progn))", "output": "(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))))))", "category": "anaphoric", "technique": "once-only,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Generate a defmacro form that transforms code like this:\n(re-setf nil)\n\nPattern to recognize: Macro call that should be transformed by RE-SETF", "input": "(re-setf nil)", "output": "(defmacro re-setf (var &rest clauses)\n \"SETFs VAR to the value of each clause subsequently.\n Re-uses the new value of VAR in subsequent clauses.\n Expects VAR to be a valid place for SETF.\"\n `(progn ,@(mapcar (lambda (clause)\n `(setf ,var ,clause))\n clauses)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Generate a defmacro form that transforms code like this:\n(once-only nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by ONCE-ONLY", "input": "(once-only nil\n :key\n nil)", "output": "(defmacro once-only (specs &body forms)\n \"Evaluate FORMS with names rebound to temporary variables, ensuring\n that each is evaluated only once.\n\n Each SPEC must be either a NAME, or a (NAME INITFORM), with plain\n NAME using the named variable as initform.\n\n Example:\n\n CL-USER> (defmacro cons1 (x)\n (once-only (x)\n `(cons ,x ,x)))\n CL-USER> (let ((y 0))\n (cons1 (incf y)))\n (1 . 1)\n\"\n (let ((gensyms (make-gensym-list (length specs) \"OO\"))\n (names-and-forms (mapcar (lambda (spec)\n (etypecase spec\n (list\n (destructuring-bind (name form) spec\n (cons name form)))\n (symbol\n (cons spec spec))))\n (remove-if-not #`(or (symbolp %) (listp %))\n specs))))\n ;; bind in user-macro\n `(let ,(mapcar #`(list % `(gensym ,(string (car %%))))\n gensyms names-and-forms)\n ;; bind in final expansion\n `(let (,,@(mapcar (lambda (g n) ``(,,g ,,(cdr n)))\n gensyms names-and-forms))\n ;; bind in user-macro\n ,(let ,(mapcar #`(list (car %) %%)\n names-and-forms gensyms)\n ,@forms)))))", "category": "control-flow", "technique": "once-only,gensym,nested-backquote,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(once-only 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by ONCE-ONLY", "input": "(once-only 'lol-gen::some-name)", "output": "(defmacro once-only (specs &body forms)\n \"Evaluate FORMS with names rebound to temporary variables, ensuring\n that each is evaluated only once.\n\n Each SPEC must be either a NAME, or a (NAME INITFORM), with plain\n NAME using the named variable as initform.\n\n Example:\n\n CL-USER> (defmacro cons1 (x)\n (once-only (x)\n `(cons ,x ,x)))\n CL-USER> (let ((y 0))\n (cons1 (incf y)))\n (1 . 1)\n\"\n (let ((gensyms (make-gensym-list (length specs) \"OO\"))\n (names-and-forms (mapcar (lambda (spec)\n (etypecase spec\n (list\n (destructuring-bind (name form) spec\n (cons name form)))\n (symbol\n (cons spec spec))))\n (remove-if-not #`(or (symbolp %) (listp %))\n specs))))\n ;; bind in user-macro\n `(let ,(mapcar #`(list % `(gensym ,(string (car %%))))\n gensyms names-and-forms)\n ;; bind in final expansion\n `(let (,,@(mapcar (lambda (g n) ``(,,g ,,(cdr n)))\n gensyms names-and-forms))\n ;; bind in user-macro\n ,(let ,(mapcar #`(list (car %) %%)\n names-and-forms gensyms)\n ,@forms)))))", "category": "control-flow", "technique": "once-only,gensym,nested-backquote,recursive-expansion", "complexity": "advanced", "quality_score": 0.9249999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(del-proxy 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DEL-PROXY", "input": "(del-proxy 'lol-gen::some-name)", "output": "(defmacro del-proxy (slot &key (node-name 'item))\n \"Remove proxy-node in slot\"\n (let ((val (gensym)) (node-list (gensym)))\n `(let ((,val (slot-value ,node-name ',slot)))\n (if (eql (find-class 'nodelist) (class-of (slot-value ,node-name ',slot)))\n \t (let ((,node-list (slot-value (slot-value ,node-name ',slot) 'nodes)))\n \t (setf (slot-value (slot-value ,node-name ',slot) 'nodes)\n \t\t (loop for i in ,node-list collect\n \t\t\t(slot-value i 'proxy-subnode))))\n \t (if ,val (setf (slot-value ,node-name ',slot)\n \t\t\t (slot-value ,val 'proxy-subnode)))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-logical-transaction 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-LOGICAL-TRANSACTION", "input": "(with-logical-transaction 'lol-gen::some-name)", "output": "(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)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(mapping 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by MAPPING", "input": "(mapping 'lol-gen::some-name)", "output": "(defmacro MAPPING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c?+n\n nil)\n\nWhat needs to change: Macro call that should be transformed by C?+N", "input": "(c?+n\n nil)", "output": "(defmacro c?+n (&body body)\n `(make-c-dependent\n :inputp t\n :code ',body\n :value-state :unevaluated\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(stop-when nil)\n\nIssue: Macro call that should be transformed by STOP-WHEN", "input": "(stop-when nil)", "output": "(defmacro STOP-WHEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(unless nil)\n\nIssue: Macro call that should be transformed by UNLESS", "input": "(unless nil)", "output": "(defmacro UNLESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-constant-inject-hook nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-CONSTANT-INJECT-HOOK", "input": "(with-constant-inject-hook nil\n :key\n nil)", "output": "(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)))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(collect-file nil (progn))\n\nProblem: Macro call that should be transformed by COLLECT-FILE", "input": "(collect-file nil (progn))", "output": "(defmacro COLLECT-FILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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->>", "input": "(cond->> nil\n nil)", "output": "(defmacro cond->> (init &body exps) (cond-arrow-macro init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-local-class-registry nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-LOCAL-CLASS-REGISTRY", "input": "(with-local-class-registry nil\n nil)", "output": "(defmacro with-local-class-registry ((&key inherit) &body body)\n \"Run BODY in a dynamic environment where *CLASS-REGISTRY* is a\ntemporary local list. If :INHERIT is non-null, the local registry\nshall initially have the same content as the exterior *CLASS-REGISTRY*, \notherwise it shall be NIL.\"\n `(let ((*class-registry*\n ,(if inherit\n `(copy-alist\n ,(if (eql inherit t) '*class-registry* inherit)))))\n ,@body))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(dcase nil)\n\nPattern to recognize: Macro call that should be transformed by DCASE", "input": "(dcase nil)", "output": "(defmacro dcase (keyform &body clauses)\n \"DCASE is a combination of CASE 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 CASE,\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 'case))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(-<>> nil :key nil)\n\nProblem: Macro call that should be transformed by -<>>", "input": "(-<>> nil :key nil)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-symbol-access\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-SYMBOL-ACCESS", "input": "(with-symbol-access\n nil\n (progn))", "output": "(defmacro WITH-SYMBOL-ACCESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defun nil ())\n\nWhat needs to change: Macro call that should be transformed by DEFUN", "input": "(defun nil ())", "output": "(defmacro DEFUN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(on nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ON", "input": "(on nil\n :key\n nil)", "output": "(defmacro on (hook args &body body)\n \"Attach a handler with ARGS and BODY to the HOOK.\n\nARGS can be\n- A symbol if there's only one argument to the callback.\n- A list of arguments.\n- An empty list, if the hook handlers take no argument.\"\n (let ((handler-name (gensym \"on-hook-handler\"))\n (args (alexandria:ensure-list args)))\n `(add-hook\n ,hook (make-instance 'handler\n :fn (lambda ,args\n (declare (ignorable ,@args))\n ,@body)\n :name (quote ,handler-name)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dispatch-case nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DISPATCH-CASE", "input": "(dispatch-case nil\n :key\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Generate a defmacro form that transforms code like this:\n(insert-into nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by INSERT-INTO", "input": "(insert-into nil\n nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-template nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-TEMPLATE", "input": "(define-template nil (progn))", "output": "(defmacro DEFINE-TEMPLATE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(as-array-member nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by AS-ARRAY-MEMBER", "input": "(as-array-member nil\n :key\n nil)", "output": "(defmacro as-array-member ((&optional (stream '*json-output*))\n &body body)\n \"BODY should be a program which encodes exactly one JSON datum to\nSTREAM. AS-ARRAY-MEMBER ensures that the datum is properly formatted\nas a Member of an Array, i. e. separated by comma from any preceding\nor following Member.\"\n `(progn\n (next-aggregate-member 'array ,stream)\n ,@body))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defsynonym nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEFSYNONYM", "input": "(defsynonym nil nil)", "output": "(defmacro DEFSYNONYM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(full-join 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by FULL-JOIN", "input": "(full-join 'lol-gen::some-name)", "output": "(defmacro full-join (table &key on using)\n `(join ,table :kind :full :on ,on :using ,using))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(aetypecase nil\n (progn))\n\nProblem: Macro call that should be transformed by AETYPECASE", "input": "(aetypecase nil\n (progn))", "output": "(defmacro aetypecase (keyform &body cases)\n \"Like ETYPECASE, except binds the result of the keyform to IT (via LET) for\nthe scope of the cases.\"\n `(anaphoric etypecase ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond->>\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by COND->>", "input": "(cond->>\n 'lol-gen::some-name)", "output": "(defmacro COND->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-global-var* nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-GLOBAL-VAR*", "input": "(define-global-var* nil :key nil)", "output": "(defmacro DEFINE-GLOBAL-VAR* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-standard-io-syntax)\n\nPattern to recognize: Macro call that should be transformed by WITH-STANDARD-IO-SYNTAX", "input": "(with-standard-io-syntax)", "output": "(defmacro WITH-STANDARD-IO-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(-<> nil\n nil)\n\nProblem: Macro call that should be transformed by -<>", "input": "(-<> nil\n nil)", "output": "(defmacro -<> (init &body exps) (diamond-wand init exps))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-generic nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-GENERIC", "input": "(define-generic nil\n nil)", "output": "(defmacro define-generic (name (&rest arglist) &body body)\n \"Convenience macro to define generics as if they were methods.\nARGLIST can be a method arglist, in which case it's parsed into\ngeneric function arglist by removing method-specific args.\n\nBODY can be a list of `defgeneric' options (processed as-is, even\n:method ones) intermixed with other Lisp forms:\n- If there's a docstring as the first form, it's processed into\n :documentation option of `defgeneric'.\n- If there are non-option forms, they are put together into a separate\n :method option under ARGLIST.\n- If there's a `declare' form:\n - If it's generic-friendly (optimize for speed or space), then it's\n put into both generic body and :method body (if any).\n - Otherwise it's only put into :method (creating it if necessary).\n- If there's an `:export-generic-name-p' boolean option, export (T) or\n don't export (NIL) the generic symbol.\n\nExample:\n\n\\(define-generic add ((a integer) (b integer) &key coerce-to-fixnum &allow-other-keys)\n \\\"Adds A and B, coercing them to fixnum if the sum is too big.\\\"\n (if coerce-to-fixnum\n (coerce (+ a b) 'fixnum)\n (+ a b))\n (:method ((a string) (b integer))\n (error \\\"Cannot use `add' on strings!\\\")))\n=>\n\\(defgeneric add (a b &key &allow-other-keys)\n (:method ((a integer) (b integer) &key coerce-to-fixnum &allow-other-keys)\n (if coerce-to-fixnum\n (coerce (+ a b) 'fixnum)\n (+ a b)))\n (:method ((a string) (b integer))\n (error \\\"Cannot use `add' on strings!\\\"))\n (:documentation \\\"Adds A and B, coercing them to fixnum if the sum is too big.\\\"))\"\n (multiple-value-bind (body declarations documentation)\n (uiop:parse-body body :documentation t)\n (when (and (= 1 (length body))\n (stringp (first body)))\n (style-warn \"Body of DEFINE-GENERIC contains a single string:\n~s.\nIt's interpreted as a method body by default.\n\nIf you meant this string to be a generic docstring, and not a method\nbody, add an explicit NIL or some other body form:\n(define-generic name (arg1 arg2)\n \\\"Docstring\\\"\n 'body-form)\n\nIf you meant it as a body form, do nothing, or provide explicit\ndocumentation or any other option:\n(define-generic name (arg1 arg2)\n \\\"Docstring\\\"\n (:documentation \\\"Real docstring\\\"))\" (first body)))\n (let* ((generic-declarations (remove-if (lambda (d)\n (or (> (length d) 2)\n (not (eq 'optimize (first (second d))))\n (notevery (lambda (o)\n (let ((feature (first (uiop:ensure-list o))))\n (or (eq feature 'speed)\n (eq feature 'space))))\n (rest (second d)))))\n declarations))\n (options (remove-if-not (lambda (form)\n (keywordp (first (uiop:ensure-list form))))\n body))\n (method-body (remove-if (lambda (f) (member f options :test #'equal)) body))\n (export-generic-name-p (find :export-generic-name-p options :key #'first))\n (options (remove export-generic-name-p options :test #'equal))\n (export-p (if export-generic-name-p\n (second export-generic-name-p)\n *export-generic-name-p*))\n (generalized-arglist (generalize-arglist arglist)))\n (when (and (not (equal generalized-arglist arglist))\n (every #'null (list method-body options)))\n (style-warn \"Specialized arglist used without method body in define-generic: ~a\" arglist))\n `(prog1\n (defgeneric ,name ,generalized-arglist\n ,@generic-declarations\n ,@(when (or method-body\n (not (equal generic-declarations\n declarations)))\n `((:method ,arglist\n ,@declarations\n ,@method-body)))\n ,@options\n ,@(when documentation\n `((:documentation ,documentation))))\n ;; FIXME: Maybe only export if package of generic function name\n ;; matches *PACKAGE*?\n ,@(when export-p\n `((eval-when (:compile-toplevel :load-toplevel :execute)\n (export ',name ,(package-name *package*)))))\n ,@(let ((documentation (or documentation\n (second (first (member :documentation options :key #'first))))))\n (when documentation\n `((setf (documentation ',name 'function) ,documentation)\n (setf (documentation (fdefinition ',name) 'function) ,documentation))))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(false 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by FALSE", "input": "(false 'lol-gen::some-name)", "output": "(defmacro false (form &optional description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(false ,form)\n :value-form ',form\n :body (lambda () ,form)\n :expected 'NIL\n :comparison 'geq\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-open-stream 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-OPEN-STREAM", "input": "(with-open-stream 'lol-gen::some-name)", "output": "(defmacro WITH-OPEN-STREAM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(compiler-macro-lambda 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by COMPILER-MACRO-LAMBDA", "input": "(compiler-macro-lambda 'lol-gen::some-name)", "output": "(defmacro compiler-macro-lambda (lambda-list &body body)\n (introspect-environment:parse-compiler-macro (gensym \"COMPILER-MACRO-LAMBDA\")\n lambda-list\n body))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(query-dao nil :key nil)\n\nProblem: Macro call that should be transformed by QUERY-DAO", "input": "(query-dao nil :key nil)", "output": "(defmacro query-dao (type query &rest args)\n \"Execute the given query (which can be either a string or an S-SQL expression)\nand return the result as DAOs of the given type. If the query contains\nplaceholders ($1, $2, etc) their values can be given as extra arguments. The\nnames of the fields returned by the query must either match slots in the DAO\nclass, or be bound through with-column-writers.\"\n `(query-dao% ,type ,(real-query query) (dao-row-reader (find-class ,type)) ,@args))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(create-view nil)\n\nIssue: Macro call that should be transformed by CREATE-VIEW", "input": "(create-view nil)", "output": "(defmacro create-view (view-name &key or-replace as)\n `(make-statement :create-view ,view-name\n :or-replace ,or-replace\n :as ,as))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(aand nil nil)\n\nProblem: Macro call that should be transformed by AAND", "input": "(aand nil nil)", "output": "(defmacro AAND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(some-<>)\n\nIssue: Macro call that should be transformed by SOME-<>", "input": "(some-<>)", "output": "(defmacro SOME-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda-match\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by LAMBDA-MATCH", "input": "(lambda-match\n nil\n :key\n nil)", "output": "(defmacro LAMBDA-MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(dreletf nil)\n\nPattern to recognize: Macro call that should be transformed by DRELETF", "input": "(dreletf nil)", "output": "(defmacro DRELETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defplace nil\n nil)\n\nProblem: Macro call that should be transformed by DEFPLACE", "input": "(defplace nil\n nil)", "output": "(defmacro defplace (name args &body body)\n \"Define NAME and (SETF NAME) in one go.\n\nBODY is a list of forms, starting with an optional docstring. The last\nform in BODY, however, must be a single, setf-able expression.\"\n (match body\n ((list (type string))\n (error \"No form for ~s: ~a\" 'defplace body))\n ((last (cons (type string) nil) 1)\n `(defplace ,name ,args ,@(reverse body)))\n (otherwise\n (with-gensyms (value)\n `(progn\n (defun ,name ,args\n ,@body)\n (defun (setf ,name) (,value ,@args)\n ,@(butlast body)\n (setf ,(lastcar body) ,value)))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(minf nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MINF", "input": "(minf nil :key nil)", "output": "(defmacro MINF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fail nil nil)\n\nProblem: Macro call that should be transformed by FAIL", "input": "(fail nil nil)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-contracts-disabled nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-CONTRACTS-DISABLED", "input": "(with-contracts-disabled nil\n nil)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(maximizing nil)\n\nPattern to recognize: Macro call that should be transformed by MAXIMIZING", "input": "(maximizing nil)", "output": "(defmacro MAXIMIZING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(live\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by LIVE", "input": "(live\n nil\n nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dovec 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DOVEC", "input": "(dovec 'lol-gen::some-name)", "output": "(defmacro dovec ((var vec &optional result-form) &body body)\n \"Iterates over a vector (like in DOLIST).\"\n (let ((index-var (gensym \"INDEX\")))\n (once-only (vec)\n `(dotimes (,index-var (length ,vec) ,result-form)\n (let ((,var (aref ,vec ,index-var)))\n ,@body)))))", "category": "control-flow", "technique": "once-only,gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(initially nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by INITIALLY", "input": "(initially nil nil)", "output": "(defmacro INITIALLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c_?\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by C_?", "input": "(c_?\n nil\n :key\n nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ignoring nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by IGNORING", "input": "(ignoring nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(handler-case 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by HANDLER-CASE", "input": "(handler-case 'lol-gen::some-name)", "output": "(defmacro HANDLER-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c_1\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by C_1", "input": "(c_1\n nil)", "output": "(defmacro c_1 (&body body)\n `(make-c-dependent\n :code '(without-c-dependency ,@body)\n :inputp nil\n :lazy t\n :value-state :unevaluated\n :rule (c-lambda (without-c-dependency ,@body))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(acase nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by ACASE", "input": "(acase nil\n :key\n nil)", "output": "(defmacro acase (keyform &body cases)\n \"Like CASE, except binds the result of the keyform to IT (via LET) for the\nscope of the cases.\"\n `(anaphoric case ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-local-class-registry nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-LOCAL-CLASS-REGISTRY", "input": "(with-local-class-registry nil\n (progn))", "output": "(defmacro with-local-class-registry ((&key inherit) &body body)\n \"Run BODY in a dynamic environment where *CLASS-REGISTRY* is a\ntemporary local list. If :INHERIT is non-null, the local registry\nshall initially have the same content as the exterior *CLASS-REGISTRY*, \notherwise it shall be NIL.\"\n `(let ((*class-registry*\n ,(if inherit\n `(copy-alist\n ,(if (eql inherit t) '*class-registry* inherit)))))\n ,@body))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-html\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-HTML", "input": "(with-html\n nil\n :key\n nil)", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(matrix-ccase 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by MATRIX-CCASE", "input": "(matrix-ccase 'lol-gen::some-name)", "output": "(defmacro MATRIX-CCASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(pcase nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PCASE", "input": "(pcase nil :key nil)", "output": "(defmacro pcase (pred keyform &rest clauses)\n \"Like CASE, but uses given PRED instead of EQL to select appropriate CLAUSE.\n\n Example usage:\n\n CL-USER> (pcase '< 1\n (0 (print \\\"Below zero\\\"))\n (2 (print \\\"OK\\\"))\n (otherwise (error \\\"Oops\\\")))\n\"\n (expand-predicate-case pred keyform clauses 'case))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(collect-last nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECT-LAST", "input": "(collect-last nil nil)", "output": "(defmacro COLLECT-LAST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(string-ecase nil)\n\nWhat needs to change: Macro call that should be transformed by STRING-ECASE", "input": "(string-ecase nil)", "output": "(defmacro STRING-ECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(count-of nil\n nil)\n\nProblem: Macro call that should be transformed by COUNT-OF", "input": "(count-of nil\n nil)", "output": "(defmacro COUNT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-pp\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-PP", "input": "(with-pp\n nil\n :key\n nil)", "output": "(defmacro with-pp (&body body)\n `(symbol-macrolet ((stream (get-stream-generic pp))\n\t\t (indent (get-indent-generic pp))\n\t\t (--indent (dec-indent-generic pp))\n\t\t (++indent (inc-indent-generic pp)))\n (macrolet ((push-sign (x) `(push-sign-generic pp ,x))\n\t\t(pop-sign () `(pop-sign-generic pp))\n\t\t(top-sign () `(top-sign-generic pp))\n\t\t(find-sign (x) `(find-sign-generic pp ,x))\n\t\t(push-info (x) `(push-info-generic pp ,x))\n\t\t(pop-info () `(pop-info-generic pp))\n\t\t(top-info () `(top-info-generic pp))\n\t\t(find-info (x) `(find-info-generic pp ,x))\n\t\t(info-size () `(info-size-generic pp))\n\t\t(node-slot (x) `(slot-value item ',x)))\n ,@body)))", "category": "anaphoric", "technique": "symbol-macrolet,macrolet,nested-backquote,anaphor", "complexity": "advanced", "quality_score": 0.9175} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(bind nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by BIND", "input": "(bind nil\n :key\n nil)", "output": "(defmacro bind ((&rest bindings) &body body)\n \"Bind is a replacement for let*, destructuring-bind, multiple-value-bind and more. \n\nAn example is probably the best way to describe its syntax:\n\n \\(bind \\(\\(a 2\\)\n \\(\\(b &rest args &key \\(c 2\\) &allow-other-keys\\) '\\(:a :c 5 :d 10 :e 54\\)\\)\n \\(\\(:values d e\\) \\(truncate 4.5\\)\\)\n \\(\\(:structure xxx- slot1 slot2\\) \\(make-xxx\\)\\)\n \\(\\(:flet name \\(arg1 arg2\\)\\) \\(+ arg1 arg2\\)\\)\\)\n \\(list a b c d e args\\)\\)\n\nSimple bindings are as in let*. Destructuring is done if the first item\nin a binding is a list. Multiple value binding is done if the first item\nin a binding is a list and the first item in the list is ':values'. Other\nforms have their own syntax. For example, :structure first has the conc\nname and then slot names whereas :flet has the function name and a list\nof arguments and then the function body (in an implicit progn).\"\n (let (declarations)\n (loop while (and (consp (car body)) (eq (caar body) 'declare)) do\n (push (first body) declarations)\n (setf body (rest body)))\n (if bindings\n\t(let ((*all-declarations* (bind-expand-declarations (nreverse declarations))))\n\t (prog1\n\t (bind-macro-helper bindings body)\n\t (check-for-unused-variable-declarations *all-declarations*)))\n `(locally\n ,@declarations\n ,@body))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-fixture-capture nil\n (progn))\n\nProblem: Macro call that should be transformed by DEFINE-FIXTURE-CAPTURE", "input": "(define-fixture-capture nil\n (progn))", "output": "(defmacro define-fixture-capture (name args &body body)\n `(progn (setf (gethash ',name *fixture-captures*)\n (lambda ,args ,@body))\n ',name))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(econd nil)\n\nWhat needs to change: Macro call that should be transformed by ECOND", "input": "(econd nil)", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda (quote lol-gen::some-name))\n\nProblem: Macro call that should be transformed by LAMBDA", "input": "(lambda (quote lol-gen::some-name))", "output": "(defmacro LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(undefmessage nil)\n\nPattern to recognize: Macro call that should be transformed by UNDEFMESSAGE", "input": "(undefmessage nil)", "output": "(defmacro UNDEFMESSAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(f_n\n nil)\n\nProblem: Macro call that should be transformed by F_N", "input": "(f_n\n nil)", "output": "(defmacro F_N ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(multiple-value-setq nil (progn))\n\nWhat needs to change: Macro call that should be transformed by MULTIPLE-VALUE-SETQ", "input": "(multiple-value-setq nil (progn))", "output": "(defmacro MULTIPLE-VALUE-SETQ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(min-of nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by MIN-OF", "input": "(min-of nil\n :key\n nil)", "output": "(defmacro MIN-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(the-kids nil :key nil)\n\nIssue: Macro call that should be transformed by THE-KIDS", "input": "(the-kids nil :key nil)", "output": "(defmacro the-kids (&rest kids)\n `(let ((*parent* self))\n (packed-flat! ,@kids)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(some-> 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by SOME->", "input": "(some-> 'lol-gen::some-name)", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(synchronized nil)\n\nWhat needs to change: Macro call that should be transformed by SYNCHRONIZED", "input": "(synchronized nil)", "output": "(defmacro synchronized ((&optional (object nil objectp)) &body body &environment env)\n \"Run BODY holding a unique lock associated with OBJECT.\nIf no OBJECT is provided, run BODY as an anonymous critical section.\n\nIf BODY begins with a literal string, attach the string to the lock\nobject created (as the argument to `bt:make-recursive-lock').\"\n (multiple-value-bind (string? body)\n (if (stringp (first body))\n (values (first body) (rest body))\n (values nil body))\n (let* ((form (lock-form object objectp env string?)))\n (with-gensyms (lock)\n `(let ((,lock ,form))\n (bt:with-recursive-lock-held (,lock)\n ;; On some Lisps this would return T if empty.\n ,@(or body '(nil))))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-hook-generic nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-HOOK-GENERIC", "input": "(define-hook-generic nil nil)", "output": "(defmacro define-hook-generic (name gf-lambda-list &rest options)\n \"utility to help with gf's with method combination by remembering the combination type\n\nby default the combination type becomes the default qualifier for any newly defined hooks\nthis can be overriden by not using this and using defgeneric or supplying\nthe option :default-qualifier.\n\nsupplying `:hook-point t` will create a method qualified with the default-qualifier\nso that the generic acts like an extensible hook point and will not signal\nno-applicable-method error when no hooks have been defined.\n\nSee defhook\"\n (let* ((combination-option (find :method-combination options :key #'car :test #'eql))\n (combination-type\n (cond ((null combination-option) 'progn)\n ((null (cadr combination-option)) :unqualified)\n ((eql 'standard (cadr combination-option)) :unqualified)\n (t (cadr combination-option))))\n (default-qualifier\n (let ((d (cadr (find :default-qualifier options :key #'car :test #'eql))))\n (if (null d) combination-type d)))\n (hook-point (find :hook-point options :key #'car)))\n\n (intern-hook-generic name combination-type default-qualifier)\n `(progn (intern-hook-generic ',name ',combination-type ',default-qualifier)\n (defgeneric ,name ,gf-lambda-list\n ,@ (remove-if (lambda (s) (or (eql s :method-combination)\n (eql s :default-qualifier)\n (eql s :hook-point)))\n options :key #'car)\n (:method-combination\n ,(if (eql :unqualified combination-type) 'standard combination-type)))\n\n ,(when hook-point\n (remove :unqualified `(defmethod ,name ,default-qualifier ,gf-lambda-list)\n :end 3)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "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", "input": "(defoptimizer common-lisp:nil\n :key\n common-lisp:nil)", "output": "(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))))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(abbr nil nil)\n\nProblem: Macro call that should be transformed by ABBR", "input": "(abbr nil nil)", "output": "(defmacro abbr (short long &optional lambda-list)\n \"Abbreviate LONG macro or function name as SHORT.\n If LAMBDA-LIST is present, also copy appropriate SETF-expander.\"\n `(eval-always\n ;; Lispworks signals error while abbreviating to keywords\n ;; SBCL has package locks when accessing built-in functionality\n ;; other similar things are probably possible in other implementations\n (handler-bind ((error (lambda (e)\n (let ((r (find-restart 'continue e)))\n (when r\n (warn 'rutils-style-warning\n :format-control\n \"Skipped error during abbreviation: ~A\"\n :format-arguments (list e))\n (invoke-restart r))))))\n (cond\n ((macro-function ',long)\n (setf (macro-function ',short) (macro-function ',long))\n #+ccl (setf (ccl:arglist ',short) (ccl:arglist ',long)))\n ((special-operator-p ',long)\n (error \"Can't abbreviate a special-operator ~a\" ',long))\n ((fboundp ',long)\n (setf (fdefinition ',short) (fdefinition ',long))\n #+ccl (setf (ccl:arglist ',short) (ccl:arglist ',long))\n ,(when lambda-list\n `(define-setf-expander ,short ,lambda-list\n (values ,@(multiple-value-bind\n (dummies vals store store-form access-form)\n (get-setf-expansion\n (cons long (remove-if (lambda (sym)\n (member sym '(&optional &key)))\n lambda-list)))\n (let ((expansion-vals (mapcar (lambda (x) `(quote ,x))\n (list dummies\n vals\n store\n store-form\n access-form))))\n (setf (second expansion-vals)\n (cons 'list vals))\n expansion-vals))))))\n (t\n (error \"Can't abbreviate ~a\" ',long)))\n (setf (documentation ',short 'function) (documentation ',long 'function))\n ',short)))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "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", "input": "(setf)", "output": "(defmacro SETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(delete-from-plistf 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DELETE-FROM-PLISTF", "input": "(delete-from-plistf 'lol-gen::some-name)", "output": "(defmacro DELETE-FROM-PLISTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(is-error nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IS-ERROR", "input": "(is-error nil :key nil)", "output": "(defmacro IS-ERROR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c-lambda\n nil\n (progn))\n\nProblem: Macro call that should be transformed by C-LAMBDA", "input": "(c-lambda\n nil\n (progn))", "output": "(defmacro c-lambda (&body body)\n `(c-lambda-var (slot-c) ,@body))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-hook-type nil (progn))\n\nIssue: Macro call that should be transformed by DEFINE-HOOK-TYPE", "input": "(define-hook-type nil (progn))", "output": "(defmacro define-hook-type (name type &optional documentation)\n \"Define hook class.\nType must be something like:\n\n (function (string) (values integer t))\n\nThe `handler-type' of the defined hook class has `:class' allocation\ntype, so that all hooks of such class have the same `handler-type'.\"\n (let* ((name (string name))\n (hook-class-name (intern (serapeum:concat \"HOOK-\" name))))\n `(defclass ,hook-class-name (hook)\n ((handler-type :initform ',type :allocation :class))\n (:metaclass closer-mop:funcallable-standard-class)\n ,@(when documentation\n `((:documentation ,documentation))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(declare-deprecated-operators nil nil)\n\nWhat needs to change: Macro call that should be transformed by DECLARE-DEPRECATED-OPERATORS", "input": "(declare-deprecated-operators nil nil)", "output": "(defmacro DECLARE-DEPRECATED-OPERATORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(sif nil nil)\n\nPattern to recognize: Macro call that should be transformed by SIF", "input": "(sif nil nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(acond\n nil)\n\nIssue: Macro call that should be transformed by ACOND", "input": "(acond\n nil)", "output": "(defmacro ACOND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(rg! 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by RG!", "input": "(rg! 'lol-gen::some-name)", "output": "(defmacro rg! (id)\n (if (eq id :coach)\n `(fm-other :coach)\n `(fm-find-registered ,id self)))", "category": "anaphoric", "technique": "nested-backquote,anaphor", "complexity": "intermediate", "quality_score": 0.8725} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(as-> nil :key nil)\n\nProblem: Macro call that should be transformed by AS->", "input": "(as-> nil :key nil)", "output": "(defmacro AS-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defun-ematch common-lisp:nil\n (common-lisp:progn))\n\nPattern to recognize: Macro call that should be transformed by DEFUN-EMATCH", "input": "(defun-ematch common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro defun-ematch (name (arg) &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 (,arg)\n ,@preamble\n (ematch ,arg\n ,@clauses))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(some->)\n\nPattern to recognize: Macro call that should be transformed by SOME->", "input": "(some->)", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(stypecase nil\n (progn))\n\nIssue: Macro call that should be transformed by STYPECASE", "input": "(stypecase nil\n (progn))", "output": "(defmacro stypecase (keyform &body cases)\n \"Like TYPECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for the\nscope of the cases. IT can be set with SETF.\"\n `(symbolic typecase ,keyform ,@cases))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make-instance* nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-INSTANCE*", "input": "(make-instance* nil :key nil)", "output": "(defmacro make-instance* (class &rest arguments)\n \"Convenience macro on top of `make-instance'.\n\nConveniences:\n\n- First argument can be a (possibly empty) list of shortcut symbols,\n which is automatically converted into a KEYWORD+SYMBOL pairs where\n - KEYWORD is the same as shortcut name, but interned as keyword.\n - And SYMBOL is the same as shortcut.\n\n- The last argument can be an apply argument---arbitrary\n list-producing form, which will be used as the last argument\n to (apply #'make-instance ...) idiom.\n\nNote that using a singular shortcut list of apply argument is an\nambiguous case that will be interpreted in favor of apply argument. To\nforce either of interpretations, provide shortcuts and apply arguments\nexplicitly:\n(make-instance* 'class (a b c)) ;; BAD\n(make-instance* 'class (a b c) nil) ;; GOOD\n(make-instance* 'class (when t nil)) ;; BAD\n(make-instance* 'class () (when t nil)) ;; GOOD\n\nOtherwise, the behavior is equivalent to `make-instance'.\n\nExamples:\n\nShortcut args:\n\\(make-instance* 'class (a b c))\n=>\n\\(make-instance 'class :a a :b b :c c)\n\nLast form converted into `apply' argument:\n\\(make-instance* 'class :c c :b b (when something (list :a a)))\n=>\n\\(apply #'make-instance 'class :c c :b b (when something (list :a a)))\n\nShortcut arguments, regular arguments, and form for `apply':\n\\(make-instance* 'class (b c) :x x (when something (list :a a)))\n=>\n\\(apply #'make-instance 'class :b b :c c :x x (when something (list :a a)))\n\nForm for `apply' (notice the empty shortcuts---these are required for\nunambiguous parsing):\n\\(make-instance* 'class () (when something (list :a a)))\n=>\n\\(apply #'make-instance 'class (when something (list :a a)))\n\nRegular `make-instance'-like use:\n\\(make-instance* 'class :a a-value :b b-value)\n=>\n\\(make-instance 'class :a a-value :b b-value)\"\n (when (and (= 1 (length arguments))\n (listp (first arguments)))\n (style-warn \"Body of MAKE-INSTANCE* contains a single list-like form ~a.\n\nIf you meant APPLY args, add empty shortcuts list:\n(make-instance* 'class () (apply-form))\n\nIf you meant shortcut list, add empty APPLY args:\n(make-instance* 'class (shortcuts) nil)\n\nInterpreting as APPLY args for now, but this behavior may change in\nthe future.\" arguments))\n (let* ((shortcuts-p (and (listp (first arguments))\n (> (length arguments) 1)))\n (shortcuts (when shortcuts-p\n (first arguments)))\n (arguments (if shortcuts-p\n (rest arguments)\n arguments))\n (last-appendable-form-p (oddp (length arguments)))\n (last-appendable-form (when last-appendable-form-p\n (first (last arguments))))\n (arguments (if last-appendable-form-p\n (butlast arguments)\n arguments)))\n `(,@(if last-appendable-form-p\n `(apply #'make-instance)\n `(make-instance))\n ,class\n ,@(loop for shortcut in shortcuts\n append (list (intern (symbol-name shortcut) :keyword)\n shortcut))\n ,@arguments\n ,@(when last-appendable-form-p\n (list last-appendable-form)))))", "category": "anaphoric", "technique": "nested-backquote,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(special-symbol-progv nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by SPECIAL-SYMBOL-PROGV", "input": "(special-symbol-progv nil\n :key\n nil)", "output": "(defmacro SPECIAL-SYMBOL-PROGV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(foreign-funcall-varargs nil nil)\n\nPattern to recognize: Macro call that should be transformed by FOREIGN-FUNCALL-VARARGS", "input": "(foreign-funcall-varargs nil nil)", "output": "(defmacro foreign-funcall-varargs (name-and-options fixed-args\n &rest varargs)\n \"Wrapper around %FOREIGN-FUNCALL that translates its arguments\nand does type promotion for the variadic arguments.\"\n (let ((name (car (ensure-list name-and-options)))\n (options (cdr (ensure-list name-and-options))))\n (foreign-funcall-varargs-form name options fixed-args varargs nil)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda-match)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-MATCH", "input": "(lambda-match)", "output": "(defmacro LAMBDA-MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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->>", "input": "(some->> nil)", "output": "(defmacro SOME->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond-let nil)\n\nPattern to recognize: Macro call that should be transformed by COND-LET", "input": "(cond-let nil)", "output": "(defmacro cond-let (var &body body)\n \"Like COND. VAR will be bound to the passed COND test.\"\n `(let (,var)\n (cond\n ,@(mapcar #``((setf ,var ,(car %)) ,(cadr %))\n ;; uses the fact, that SETF returns the value set\n body))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(sort-values nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SORT-VALUES", "input": "(sort-values nil nil)", "output": "(defmacro sort-values (pred &rest values)\n \"Sort VALUES with PRED and return as multiple values.\n\nEquivalent to\n\n (values-list (sort (list VALUES...) pred))\n\nBut with less consing, and potentially faster.\"\n ;; Remember to evaluate `pred' no matter what.\n (with-gensyms (gpred)\n `(let ((,gpred (ensure-function ,pred)))\n (declare (ignorable ,gpred)\n (function ,gpred)\n (optimize (safety 1) (debug 0) (compilation-speed 0)))\n ,(match values\n ((list) `(values))\n ((list x) `(values ,x))\n ;; The strategy here is to use a sorting network if the\n ;; inputs are few, and a stack-allocated vector if the\n ;; inputs are many.\n (otherwise\n (if (<= (length values) 8)\n `(sort-values/network ,gpred ,@values)\n `(sort-values/temp-vector ,gpred ,@values)))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "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", "input": "(ps-html nil (progn))", "output": "(defmacro PS-HTML ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(unionf nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by UNIONF", "input": "(unionf nil (progn))", "output": "(defmacro UNIONF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-inference-rule nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-INFERENCE-RULE", "input": "(define-inference-rule nil\n (progn))", "output": "(defmacro DEFINE-INFERENCE-RULE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(destructuring-match 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DESTRUCTURING-MATCH", "input": "(destructuring-match 'lol-gen::some-name)", "output": "(defmacro DESTRUCTURING-MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(finally nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by FINALLY", "input": "(finally nil :key nil)", "output": "(defmacro FINALLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ematch nil)\n\nProblem: Macro call that should be transformed by EMATCH", "input": "(ematch nil)", "output": "(defmacro ematch (arg &body clauses)\n \"Same as MATCH, except MATCH-ERROR will be raised if not matched.\"\n (once-only (arg)\n (let ((else `(error 'match-error\n :values (list ,arg)\n :patterns ',(mapcar (lambda (c) (list (car c))) clauses))))\n (compile-match-1 arg clauses else))))", "category": "control-flow", "technique": "once-only", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-gensyms nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITH-GENSYMS", "input": "(with-gensyms nil\n :key\n nil)", "output": "(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))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-abstract-class nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-ABSTRACT-CLASS", "input": "(define-abstract-class nil :key nil)", "output": "(defmacro DEFINE-ABSTRACT-CLASS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(iterate\n nil)\n\nProblem: Macro call that should be transformed by ITERATE", "input": "(iterate\n nil)", "output": "(defmacro iterate (&body body)\n \"Jonathan Amsterdam's powerful iteration facility\"\n `(iter .,body))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(necessarily?\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NECESSARILY?", "input": "(necessarily?\n nil\n :key\n nil)", "output": "(defmacro NECESSARILY? ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(matrix-typecase 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by MATRIX-TYPECASE", "input": "(matrix-typecase 'lol-gen::some-name)", "output": "(defmacro MATRIX-TYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(aif nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AIF", "input": "(aif nil :key nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(eval-and-compile\n nil\n nil)\n\nIssue: Macro call that should be transformed by EVAL-AND-COMPILE", "input": "(eval-and-compile\n nil\n nil)", "output": "(defmacro eval-and-compile (&body body)\n \"Emacs's `eval-and-compile'.\nAlias for `eval-always'.\"\n `(eval-always\n ,@body))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITH", "input": "(with nil\n :key\n nil)", "output": "(defmacro WITH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(f_\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by F_", "input": "(f_\n nil\n nil)", "output": "(defmacro F_ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-html)\n\nPattern to recognize: Macro call that should be transformed by WITH-HTML", "input": "(with-html)", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(sunless 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by SUNLESS", "input": "(sunless 'lol-gen::some-name)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nest nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NEST", "input": "(nest nil nil)", "output": "(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))", "category": "dsl", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8274999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(enable-interpol-syntax nil nil)\n\nWhat needs to change: Macro call that should be transformed by ENABLE-INTERPOL-SYNTAX", "input": "(enable-interpol-syntax nil nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(var nil (progn))\n\nIssue: Macro call that should be transformed by VAR", "input": "(var nil (progn))", "output": "(defmacro VAR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(-> 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ->", "input": "(-> 'lol-gen::some-name)", "output": "(defmacro -> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(sctypecase 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by SCTYPECASE", "input": "(sctypecase 'lol-gen::some-name)", "output": "(defmacro sctypecase (keyform &body cases)\n \"Like CTYPECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for\nthe scope of the cases. IT can be set with SETF.\"\n `(symbolic ctypecase ,keyform ,@cases))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(splice-seqf 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by SPLICE-SEQF", "input": "(splice-seqf 'lol-gen::some-name)", "output": "(defmacro SPLICE-SEQF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defparameter nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFPARAMETER", "input": "(defparameter nil (progn))", "output": "(defmacro DEFPARAMETER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(destructuring-ecase nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DESTRUCTURING-ECASE", "input": "(destructuring-ecase nil)", "output": "(defmacro destructuring-ecase (keyform &body clauses)\n (expand-destructuring-case keyform clauses 'ecase))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(distinct-on nil nil)\n\nIssue: Macro call that should be transformed by DISTINCT-ON", "input": "(distinct-on nil nil)", "output": "(defmacro distinct-on (columns &rest fields)\n `(make-clause :distinct-on (list ,@columns) ,@(mapcar #'expand-op fields)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(alambda nil\n :key\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ignore 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by IGNORE", "input": "(ignore 'lol-gen::some-name)", "output": "(defmacro IGNORE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(-> nil (progn))\n\nPattern to recognize: Macro call that should be transformed by ->", "input": "(-> nil (progn))", "output": "(defmacro -> (x &rest forms)\n \"Threads the expr through FORMS. Inserts X as the\n second item in the first form, or in place of % if it is present in the form,\n making a list of it if it is not a list already.\n If there are more forms, inserts the first form\n as the second item in second form, etc.\"\n (if (first forms)\n (let* ((form (first forms))\n (threaded (if (listp form)\n (if (member '% form)\n `(funcall (lambda (%) ,form) ,x)\n `(,(first form) ,x ,@(rest form)))\n `(,form ,x))))\n `(-> ,threaded ,@(rest forms)))\n x))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defun* nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFUN*", "input": "(defun* nil\n :key\n nil)", "output": "(defmacro DEFUN* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(case nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by CASE", "input": "(case nil (progn))", "output": "(defmacro CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(boolean-when nil)\n\nWrite a macro that addresses: Macro call that should be transformed by BOOLEAN-WHEN", "input": "(boolean-when nil)", "output": "(defmacro boolean-when (branch &body body &environment env)\n \"Includes some forms based on whether a macroexpand-time branch is true. The\nfirst argument must be a symbol naming a branch in the lexically enclosing\nWITH-BOOLEAN form.\n\\\nIt is an error to use this macro outside the lexical environment established by\nWITH-BOOLEAN.\"\n (cond (*boolean-bypass*\n `(when ,branch ,@body))\n ((not (member branch (macroexpand-1 '%all-branches% env)))\n (missing-branch branch))\n ((not (macroexpand-1 '%in-branching% env))\n (conditional-error 'when))\n ((not (member branch (macroexpand-1 '%true-branches% env)))\n `(progn))\n ((= 0 (length body))\n `(progn))\n ((= 1 (length body))\n (car body))\n (t `(progn ,@body))))", "category": "anaphoric", "technique": "nested-backquote,anaphor", "complexity": "advanced", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(is-values nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IS-VALUES", "input": "(is-values nil)", "output": "(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)))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-value-binding nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFINE-VALUE-BINDING", "input": "(define-value-binding nil\n (progn))", "output": "(defmacro define-value-binding (name (var &rest args) &body body)\n (let ((vars (lambda-fiddle:extract-lambda-vars (lambda-fiddle:remove-aux-part args))))\n (emit-binding-definition name var args body :extra-vars vars)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(gen-lambda-with-sticky-stop nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by GEN-LAMBDA-WITH-STICKY-STOP", "input": "(gen-lambda-with-sticky-stop nil :key nil)", "output": "(defmacro gen-lambda-with-sticky-stop (&rest rest)\n `(make-instance \n 'basic-generator \n :function (sticky-stop-lambda ,@rest)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(pprint-coalton-codegen\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by PPRINT-COALTON-CODEGEN", "input": "(pprint-coalton-codegen\n common-lisp:nil)", "output": "(defmacro PPRINT-COALTON-CODEGEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(local*\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LOCAL*", "input": "(local*\n nil\n nil)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(acond)\n\nWhat needs to change: Macro call that should be transformed by ACOND", "input": "(acond)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.79} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(econd nil :key nil)\n\nProblem: Macro call that should be transformed by ECOND", "input": "(econd nil :key nil)", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(the nil nil)\n\nPattern to recognize: Macro call that should be transformed by THE", "input": "(the nil nil)", "output": "(defmacro THE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(iter\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by ITER", "input": "(iter\n 'lol-gen::some-name)", "output": "(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))))))))", "category": "anaphoric", "technique": "tagbody-go,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defsynonym nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEFSYNONYM", "input": "(defsynonym nil nil)", "output": "(defmacro defsynonym (syn word)\n \"Makes SYN a synonym for the existing iterate keyword WORD.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (get ',syn 'synonym) ',word)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(caching-types\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CACHING-TYPES", "input": "(caching-types\n nil)", "output": "(defmacro CACHING-TYPES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defmethod nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFMETHOD", "input": "(defmethod nil nil)", "output": "(defmacro DEFMETHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(send 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by SEND", "input": "(send 'lol-gen::some-name)", "output": "(defmacro SEND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(some->\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by SOME->", "input": "(some->\n nil\n (progn))", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda-match1 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by LAMBDA-MATCH1", "input": "(lambda-match1 'lol-gen::some-name)", "output": "(defmacro lambda-match1 (pattern &body body)\n \"Equivalent to (lambda (arg) (match arg (PATTERN BODY...))).\"\n `(lambda-match (,pattern ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(def-suite* nil nil)\n\nProblem: Macro call that should be transformed by DEF-SUITE*", "input": "(def-suite* nil nil)", "output": "(defmacro def-suite* (name &rest def-suite-args)\n `(progn\n (def-suite ,name ,@def-suite-args)\n (in-suite ,name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(defgeneric nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFGENERIC", "input": "(defgeneric nil (progn))", "output": "(defmacro DEFGENERIC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(enable-quasi-quoted-binary-to-binary-emitting-form-syntax nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BINARY-TO-BINARY-EMITTING-FORM-SYNTAX", "input": "(enable-quasi-quoted-binary-to-binary-emitting-form-syntax nil)", "output": "(defmacro ENABLE-QUASI-QUOTED-BINARY-TO-BINARY-EMITTING-FORM-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(<* nil)\n\nWhat needs to change: Macro call that should be transformed by <*", "input": "(<* nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(enable-quasi-quoted-list-to-list-emitting-form-syntax)\n\nProblem: Macro call that should be transformed by ENABLE-QUASI-QUOTED-LIST-TO-LIST-EMITTING-FORM-SYNTAX", "input": "(enable-quasi-quoted-list-to-list-emitting-form-syntax)", "output": "(defmacro ENABLE-QUASI-QUOTED-LIST-TO-LIST-EMITTING-FORM-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make-node 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by MAKE-NODE", "input": "(make-node 'lol-gen::some-name)", "output": "(defmacro make-node (item)\n \"Try to identify and make node object\"\n `(make-node-function (quoty ,item)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(some-> nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SOME->", "input": "(some-> nil\n (progn))", "output": "(defmacro some-> (init &body exps) (arrow-macro init exps nil t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(accase nil)\n\nPattern to recognize: Macro call that should be transformed by ACCASE", "input": "(accase nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(query nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by QUERY", "input": "(query nil (progn))", "output": "(defmacro query (query &rest args/format)\n \"Execute the given query, which can be either a string or an S-SQL form (list\nstarting with a keyword). If the query contains placeholders ($1, $2, etc)\ntheir values can be given as extra arguments. If one of these arguments is a\nkeyword occurring in the table below, it will not be used as a query\nargument, but will determine the format in which the results are returned\ninstead. Any of the following formats can be used, with the default being :rows:\n\n| :none\t | Ignore the result values. |\n| :lists, :rows | Return a list of lists, each list containing the values |\n| | for a row. |\n| :list, :row | Return a single row as a list. |\n| :alists\t | Return a list of alists which map column names to values, |\n| | with the names represented as keywords. |\n| :alist\t | Return a single row as an alist. |\n| :array-hash | Return an array of hashtables which map column names to |\n| | hash table keys. NOTE: It will return an empty array |\n| | if there is no result. |\n| :vectors | Returns a vector of vectors where each internal vector is |\n| | a returned row from the query. The field names are not |\n| | included. NOTE: It will return an empty vector instead of |\n| | NIL if there is no result. |\n| :str-alists | Like :alists, but use the original column names. |\n| :str-alist\t | Return a single row as an alist, with strings for names. |\n| :plists\t | Return a list of plists which map column names to values, |\n| | with the names represented as keywords. |\n| :plist\t | Return a single row as a plist. |\n| :column\t | Return a single column as a list. |\n| :single\t | Return a single value. |\n| :single!\t | Like :single, but raise an error when the number of |\n| | selected rows is not equal to 1. |\n| (:dao type)\t | Return a list of DAOs of the given type. The names of the |\n| | fields returned by the query must match slots in the DAO |\n| | class the same way as with query-dao. |\n| (:dao type :single)| Return a single DAO of the given type. |\n| :json-strs | Return a list of strings where each row is a json object |\n| | expressed as a string |\n| :json-str | Return a single string where the row returned is a json |\n| | object expressed as a string. |\n| :json-array-str | Return a string containing a json array, each element in |\n| | the array is a selected row expressed as a json object. |\n| | NOTE: If there is no result, it will return a string with |\n| | an empty json array. |\n\nIf the database returns information about the amount rows that were affected,\nsuch as with updating or deleting queries, this is returned as a second value.\"\n (let* ((format :rows)\n (args (loop :for arg :in args/format\n :if (or (dao-spec-for-format arg)\n (assoc arg *result-styles*)) :do (setf format arg)\n :else :collect arg)))\n (destructuring-bind (reader result-form) (reader-for-format format)\n (let ((base (if args\n\t\t (let ((vars (loop :for x :in args :collect (gensym))))\n\t\t\t`(let ,(loop :for v :in vars :for a :in args :collect `(,v ,a))\n\t\t\t (prepare-query *database* \"\" ,(real-query query) (list ,@vars))\n\t\t\t (exec-prepared *database* \"\" (list ,@vars) ,reader)))\n\t\t `(exec-query *database* ,(real-query query) ,reader))))\n `(,result-form ,base)))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(enable-quasi-quoted-binary-to-binary-emitting-form-syntax 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ENABLE-QUASI-QUOTED-BINARY-TO-BINARY-EMITTING-FORM-SYNTAX", "input": "(enable-quasi-quoted-binary-to-binary-emitting-form-syntax 'lol-gen::some-name)", "output": "(defmacro ENABLE-QUASI-QUOTED-BINARY-TO-BINARY-EMITTING-FORM-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(doseq! 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DOSEQ!", "input": "(doseq! 'lol-gen::some-name)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(cmatch nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by CMATCH", "input": "(cmatch nil\n (progn))", "output": "(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))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(some-<>\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by SOME-<>", "input": "(some-<>\n nil\n nil)", "output": "(defmacro SOME-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(group-by)\n\nProblem: Macro call that should be transformed by GROUP-BY", "input": "(group-by)", "output": "(defmacro GROUP-BY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(prog* (quote lol-gen::some-name))\n\nWhat needs to change: Macro call that should be transformed by PROG*", "input": "(prog* (quote lol-gen::some-name))", "output": "(defmacro PROG* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dispatch-case-let nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DISPATCH-CASE-LET", "input": "(dispatch-case-let nil\n nil)", "output": "(defmacro dispatch-case-let ((&rest bindings) &body clauses &environment env)\n \"Like `dispatch-case', but establish new bindings for each expression.\n\nFor example,\n\n (dispatch-case-let (((x string) (expr1))\n ((y string) (expr2)))\n ...)\n\nis equivalent to\n\n (let ((x (expr1))\n (y (expr2)))\n (dispatch-case ((x string)\n (y string))\n ...))\n\nIt may be helpful to think of this as a cross between\n`defmethod' (where the (variable type) notation is used in the lambda\nlist) and `let' (which has an obvious macro-expansion in terms of\n`lambda').\"\n (multiple-value-bind (vars types exprs)\n ;; Split the bindings and types.\n (with-collectors (vars-out types-out exprs-out)\n (flet ((vars-out (var) (vars-out (ensure-var var))))\n (dolist (binding bindings)\n (ematch binding\n ((list (and var (type symbol)) expr)\n (vars-out var)\n (types-out t)\n (exprs-out expr))\n ((list (list (and var (type symbol)) type) expr)\n (vars-out var)\n (types-out type)\n (exprs-out expr))))))\n (let ((normalized-clauses\n ;; Normalize asterisks into the types of the corresponding\n ;; variables.\n (loop for (clause-types . clause-body) in clauses\n collect (cons\n (loop for clause-type in clause-types\n for type in types\n if (eql clause-type '*)\n collect type\n else collect clause-type)\n clause-body))))\n (with-unique-names (block)\n (multiple-value-bind (tags final-clauses)\n (hoist-clause-bodies block normalized-clauses env)\n `(let ,(mapcar #'list vars exprs)\n (with-read-only-vars ,vars\n (block ,block\n (tagbody\n (dispatch-case/nobindings ,(mapcar #'list vars types)\n ,@final-clauses)\n ,@tags)))))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(selector nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by SELECTOR", "input": "(selector nil\n :key\n nil)", "output": "(defmacro SELECTOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(-<> nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by -<>", "input": "(-<> nil :key nil)", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ps-inline nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PS-INLINE", "input": "(ps-inline nil)", "output": "(defmacro PS-INLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defreply nil\n nil)\n\nProblem: Macro call that should be transformed by DEFREPLY", "input": "(defreply nil\n nil)", "output": "(defmacro DEFREPLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nor nil nil)\n\nIssue: Macro call that should be transformed by NOR", "input": "(nor nil nil)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(for nil)\n\nWhat needs to change: Macro call that should be transformed by FOR", "input": "(for nil)", "output": "(defmacro for (update-type &key of nowait skip-locked)\n (let ((ident-list (if (keywordp of)\n `(list ,of)\n `(quote ,of))))\n `(make-clause :updatability ,update-type :of ,ident-list :nowait ,nowait :skip-locked ,skip-locked)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(->> nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by ->>", "input": "(->> nil :key nil)", "output": "(defmacro ->> (x &rest forms)\n \"Threads the expr through FORMS. Inserts X as the\n last item in the first form, or in place of % if it is present in the form,\n making a list of it if it is not a list already.\n If there are more forms, inserts the first form\n as the last item in second form, etc.\"\n (if (first forms)\n (let* ((form (first forms))\n (threaded (if (listp form)\n (if (member '% form)\n `(funcall (lambda (%) ,form) ,x)\n `(,(first form) ,@(rest form) ,x))\n `(,form ,x))))\n `(->> ,threaded ,@(rest forms)))\n x))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(caching-types\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by CACHING-TYPES", "input": "(caching-types\n nil\n nil)", "output": "(defmacro CACHING-TYPES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(prog () :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PROG", "input": "(prog () :key nil)", "output": "(defmacro PROG ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(proxy nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by PROXY", "input": "(proxy nil (progn))", "output": "(defmacro PROXY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(remf nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by REMF", "input": "(remf nil nil)", "output": "(defmacro REMF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-live-scope\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-LIVE-SCOPE", "input": "(with-live-scope\n 'lol-gen::some-name)", "output": "(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))))))", "category": "anaphoric", "technique": "macrolet,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(cond->> nil)\n\nWrite a macro that addresses: Macro call that should be transformed by COND->>", "input": "(cond->> nil)", "output": "(defmacro COND->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fgather-result nil)\n\nWhat needs to change: Macro call that should be transformed by FGATHER-RESULT", "input": "(fgather-result nil)", "output": "(defmacro FGATHER-RESULT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-active-layers* nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-ACTIVE-LAYERS*", "input": "(with-active-layers* nil\n (progn))", "output": "(defmacro WITH-ACTIVE-LAYERS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(jor 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by JOR", "input": "(jor 'lol-gen::some-name)", "output": "(defmacro jor (&rest args)\n \"JSON-aware version of `cl:or'.\"\n `(or ,@(loop for arg in args\n collecting `(jwhen ,arg ,arg))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(incf-pointer nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by INCF-POINTER", "input": "(incf-pointer nil nil)", "output": "(defmacro INCF-POINTER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(options)\n\nPattern to recognize: Macro call that should be transformed by OPTIONS", "input": "(options)", "output": "(defmacro OPTIONS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(class/std nil)\n\nWhat needs to change: Macro call that should be transformed by CLASS/STD", "input": "(class/std nil)", "output": "(defmacro class/std (name &body defaulted-slots)\n \"The most concise shortcut macro to DEFCLASS.\n\n (class/std example slot1 slot2 slot3)\n\n expands to:\n\n (DEFCLASS/STD EXAMPLE ()\n ((SLOT1 SLOT2 SLOT3)))\n\n which expands to:\n\n (DEFCLASS EXAMPLE ()\n ((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL)\n (SLOT2 :ACCESSOR SLOT2 :INITARG :SLOT2 :INITFORM NIL)\n (SLOT3 :ACCESSOR SLOT3 :INITARG :SLOT3 :INITFORM NIL)))\n\"\n `(defclass/std ,name ()\n ((,@defaulted-slots))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-unique-names nil)\n\nProblem: Macro call that should be transformed by WITH-UNIQUE-NAMES", "input": "(with-unique-names nil)", "output": "(defmacro WITH-UNIQUE-NAMES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(local*\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by LOCAL*", "input": "(local*\n 'lol-gen::some-name)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(cond->\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by COND->", "input": "(cond->\n nil\n (progn))", "output": "(defmacro COND-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make-$instance nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-$INSTANCE", "input": "(make-$instance nil :key nil)", "output": "(defmacro MAKE-$INSTANCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(some->\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by SOME->", "input": "(some->\n 'lol-gen::some-name)", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(^kids)\n\nIssue: Macro call that should be transformed by ^KIDS", "input": "(^kids)", "output": "(defmacro ^KIDS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(coercef nil nil)\n\nPattern to recognize: Macro call that should be transformed by COERCEF", "input": "(coercef nil nil)", "output": "(defmacro COERCEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(walk-environment)\n\nIssue: Macro call that should be transformed by WALK-ENVIRONMENT", "input": "(walk-environment)", "output": "(defmacro WALK-ENVIRONMENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond-it\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by COND-IT", "input": "(cond-it\n nil\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(jand nil nil)\n\nProblem: Macro call that should be transformed by JAND", "input": "(jand nil nil)", "output": "(defmacro jand (&rest args)\n \"JSON-aware version of `cl:and'.\"\n `(and ,@(loop for arg in args\n collecting `(jwhen ,arg ,arg))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(c-lambda\n nil)\n\nIssue: Macro call that should be transformed by C-LAMBDA", "input": "(c-lambda\n nil)", "output": "(defmacro c-lambda (&body body)\n `(c-lambda-var (slot-c) ,@body))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-switches)\n\nIssue: Macro call that should be transformed by DEFINE-SWITCHES", "input": "(define-switches)", "output": "(defmacro define-switches (&key cl-reader cm-reader macro-character)\n \"Define c-mera/common-lisp reader switches\"\n `(progn\n (defun ,cl-reader ()\n (setf *c-mera-reader* 'cl)\n (setf *readtable* *readtable-backup*))\n (defun ,cm-reader ()\n (setf *c-mera-reader* 'cm)\n ,@macro-character\n (setf (readtable-case *readtable*) :invert))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defunion nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFUNION", "input": "(defunion nil\n nil)", "output": "(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)))))", "category": "anaphoric", "technique": "symbol-macrolet,anaphor", "complexity": "advanced", "quality_score": 0.8925} {"instruction": "Generate a defmacro form that transforms code like this:\n(nand nil nil)\n\nPattern to recognize: Macro call that should be transformed by NAND", "input": "(nand nil nil)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ensure-transaction-with-isolation-level 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ENSURE-TRANSACTION-WITH-ISOLATION-LEVEL", "input": "(ensure-transaction-with-isolation-level 'lol-gen::some-name)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nconcf nil (progn))\n\nIssue: Macro call that should be transformed by NCONCF", "input": "(nconcf nil (progn))", "output": "(defmacro NCONCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-dispatch nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFINE-DISPATCH", "input": "(define-dispatch nil\n :key\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(if-it nil nil)\n\nProblem: Macro call that should be transformed by IF-IT", "input": "(if-it nil nil)", "output": "(defmacro if-it (test then &optional else)\n \"Like IF. IT is bound to TEST.\"\n `(let ((it ,test))\n (if it ,then ,else)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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", "input": "(when-failing nil\n nil)", "output": "(defmacro WHEN-FAILING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda-ematch\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by LAMBDA-EMATCH", "input": "(lambda-ematch\n 'lol-gen::some-name)", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(match2* 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by MATCH2*", "input": "(match2* 'lol-gen::some-name)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defgeneric nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEFGENERIC", "input": "(defgeneric nil nil)", "output": "(defmacro defgeneric (name (&rest lambda-list) &rest options)\n (with-gensyms (gf)\n (flet ((make-save-method (args)\n (with-gensyms (method)\n (multiple-value-bind (qualifiers specializers lambda-list body)\n (parse-method args)\n\n (let ((fn-name (gentemp (symbol-name (block-name name)) *method-function-package*)))\n (list `(let ((,method (find-method% ,gf ',qualifiers ',specializers)))\n ,(make-add-method-info name method fn-name body :remove-on-redefine-p t))\n\n (make-method-function name fn-name lambda-list body)\n\n (make-static-dispatch name lambda-list specializers)))))))\n\n (let ((combination 'standard)\n (combination-options))\n\n `(progn\n (walk-environment\n (c2mop:defgeneric ,name ,lambda-list ,@options))\n\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (add-compiler-macro ',name)\n (remove-defined-methods ',name))\n\n (let ((,gf (fdefinition ',name)))\n (when (typep ,gf 'generic-function)\n ,@(handler-case\n (append\n (mappend\n (lambda-match\n ((list* :method args)\n (make-save-method args))\n\n ((list* :method-combination name options)\n (setf combination name)\n (setf combination-options options)))\n\n options)\n\n `((setf (combination-options ',name)\n '(,combination ,combination-options))))\n\n (error (e)\n (simple-style-warning \"Error parsing DEFGENERIC form:~%~a\" e)\n nil)))\n\n ,gf))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(make-list 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by MAKE-LIST", "input": "(make-list 'lol-gen::some-name)", "output": "(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)))", "category": "control-flow", "technique": "nested-backquote", "complexity": "advanced", "quality_score": 0.8999999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(sccase nil\n (progn))\n\nProblem: Macro call that should be transformed by SCCASE", "input": "(sccase nil\n (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(f-plusp nil nil)\n\nProblem: Macro call that should be transformed by F-PLUSP", "input": "(f-plusp nil nil)", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(delete-from nil)\n\nIssue: Macro call that should be transformed by DELETE-FROM", "input": "(delete-from nil)", "output": "(defmacro delete-from (table &body clauses)\n `(make-statement :delete-from\n ,(expand-expression table) ,@clauses))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-foreign-object 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-FOREIGN-OBJECT", "input": "(with-foreign-object 'lol-gen::some-name)", "output": "(defmacro with-foreign-object ((var type &optional (count 1)) &body body)\n \"Bind VAR to a pointer to COUNT objects of TYPE during BODY.\nThe buffer has dynamic extent and may be stack allocated.\"\n `(with-foreign-pointer\n (,var ,(if (constantp type)\n ;; with-foreign-pointer may benefit from constant folding:\n (if (constantp count)\n (* (eval count) (foreign-type-size (eval type)))\n `(* ,count ,(foreign-type-size (eval type))))\n `(* ,count (foreign-type-size ,type))))\n ,@body))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-parse-tree-synonym nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-PARSE-TREE-SYNONYM", "input": "(define-parse-tree-synonym nil (progn))", "output": "(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)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-filtered-function nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFINE-FILTERED-FUNCTION", "input": "(define-filtered-function nil\n (progn))", "output": "(defmacro DEFINE-FILTERED-FUNCTION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(do-all-symbols (quote lol-gen::some-name))\n\nPattern to recognize: Macro call that should be transformed by DO-ALL-SYMBOLS", "input": "(do-all-symbols (quote lol-gen::some-name))", "output": "(defmacro DO-ALL-SYMBOLS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(match nil)\n\nPattern to recognize: Macro call that should be transformed by MATCH", "input": "(match nil)", "output": "(defmacro MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(f 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by F", "input": "(f 'lol-gen::some-name)", "output": "(defmacro F ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-shadowed-custom-vars)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-SHADOWED-CUSTOM-VARS", "input": "(with-shadowed-custom-vars)", "output": "(defmacro with-shadowed-custom-vars (&body body)\n `(let ,(loop for (var) in *custom-vars*\n collect `(,var (if (boundp ',var) ,var)))\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(mapping nil nil)\n\nPattern to recognize: Macro call that should be transformed by MAPPING", "input": "(mapping nil nil)", "output": "(defmacro MAPPING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ps-doc)\n\nWhat needs to change: Macro call that should be transformed by PS-DOC", "input": "(ps-doc)", "output": "(defmacro PS-DOC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(defobserver nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFOBSERVER", "input": "(defobserver nil (progn))", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-length 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by COLLECT-LENGTH", "input": "(collect-length 'lol-gen::some-name)", "output": "(defmacro COLLECT-LENGTH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(psetf nil nil)\n\nWhat needs to change: Macro call that should be transformed by PSETF", "input": "(psetf nil nil)", "output": "(defmacro PSETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(m nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by M", "input": "(m nil\n :key\n nil)", "output": "(defmacro M ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(-<>> 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by -<>>", "input": "(-<>> 'lol-gen::some-name)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(once-only 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ONCE-ONLY", "input": "(once-only 'lol-gen::some-name)", "output": "(defmacro once-only (specs &body forms)\n \"Constructs code whose primary goal is to help automate the handling of\nmultiple evaluation within macros. Multiple evaluation is handled by introducing\nintermediate variables, in order to reuse the result of an expression.\n\nThe returned value is a list of the form\n\n (let (( )\n ...\n ( ))\n )\n\nwhere GENSYM-1, ..., GENSYM-N are the intermediate variables introduced in order\nto evaluate EXPR-1, ..., EXPR-N once, only. RES is code that is the result of\nevaluating the implicit progn FORMS within a special context determined by\nSPECS. RES should make use of (reference) the intermediate variables.\n\nEach element within SPECS is either a symbol SYMBOL or a pair (SYMBOL INITFORM).\nBare symbols are equivalent to the pair (SYMBOL SYMBOL).\n\nEach pair (SYMBOL INITFORM) specifies a single intermediate variable:\n\n- INITFORM is an expression evaluated to produce EXPR-i\n\n- SYMBOL is the name of the variable that will be bound around FORMS to the\n corresponding gensym GENSYM-i, in order for FORMS to generate RES that\n references the intermediate variable\n\nThe evaluation of INITFORMs and binding of SYMBOLs resembles LET. INITFORMs of\nall the pairs are evaluated before binding SYMBOLs and evaluating FORMS.\n\nExample:\n\n The following expression\n\n (let ((x '(incf y)))\n (once-only (x)\n `(cons ,x ,x)))\n\n ;;; =>\n ;;; (let ((#1=#:X123 (incf y)))\n ;;; (cons #1# #1#))\n\n could be used within a macro to avoid multiple evaluation like so\n\n (defmacro cons1 (x)\n (once-only (x)\n `(cons ,x ,x)))\n\n (let ((y 0))\n (cons1 (incf y)))\n\n ;;; => (1 . 1)\n\nExample:\n\n The following expression demonstrates the usage of the INITFORM field\n\n (let ((expr '(incf y)))\n (once-only ((var `(1+ ,expr)))\n `(list ',expr ,var ,var)))\n\n ;;; =>\n ;;; (let ((#1=#:VAR123 (1+ (incf y))))\n ;;; (list '(incf y) #1# #1))\n\n which could be used like so\n\n (defmacro print-succ-twice (expr)\n (once-only ((var `(1+ ,expr)))\n `(format t \\\"Expr: ~s, Once: ~s, Twice: ~s~%\\\" ',expr ,var ,var)))\n\n (let ((y 10))\n (print-succ-twice (incf y)))\n\n ;;; >>\n ;;; Expr: (INCF Y), Once: 12, Twice: 12\"\n (let ((gensyms (make-gensym-list (length specs) \"ONCE-ONLY\"))\n (names-and-forms (mapcar (lambda (spec)\n (etypecase spec\n (list\n (destructuring-bind (name form) spec\n (cons name form)))\n (symbol\n (cons spec spec))))\n specs)))\n ;; bind in user-macro\n `(let ,(mapcar (lambda (g n) (list g `(gensym ,(string (car n)))))\n gensyms names-and-forms)\n ;; bind in final expansion\n `(let (,,@(mapcar (lambda (g n)\n ``(,,g ,,(cdr n)))\n gensyms names-and-forms))\n ;; bind in user-macro\n ,(let ,(mapcar (lambda (n g) (list (car n) g))\n names-and-forms gensyms)\n ,@forms)))))", "category": "control-flow", "technique": "once-only,gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Generate a defmacro form that transforms code like this:\n(defmethod nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFMETHOD", "input": "(defmethod nil\n nil)", "output": "(defmacro DEFMETHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(for-all* nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by FOR-ALL*", "input": "(for-all* nil\n :key\n nil)", "output": "(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))))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda-ematch*)\n\nProblem: Macro call that should be transformed by LAMBDA-EMATCH*", "input": "(lambda-ematch*)", "output": "(defmacro lambda-ematch* (&body body)\n \"Equivalent to (lambda (args...) (ematch* (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 (ematch* ,gensyms\n ,@clauses)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-script-symbol-macro nil\n (progn))\n\nProblem: Macro call that should be transformed by DEFINE-SCRIPT-SYMBOL-MACRO", "input": "(define-script-symbol-macro nil\n (progn))", "output": "(defmacro DEFINE-SCRIPT-SYMBOL-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ematch common-lisp:nil\n :key\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by EMATCH", "input": "(ematch common-lisp:nil\n :key\n common-lisp:nil)", "output": "(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))))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(acase nil\n nil)\n\nProblem: Macro call that should be transformed by ACASE", "input": "(acase nil\n nil)", "output": "(defmacro acase (keyform &body cases)\n \"Like CASE, except binds the result of the keyform to IT (via LET) for the\nscope of the cases.\"\n `(anaphoric case ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(gatherer 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by GATHERER", "input": "(gatherer 'lol-gen::some-name)", "output": "(defmacro GATHERER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(and-let nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AND-LET", "input": "(and-let nil :key nil)", "output": "(defmacro and-let (var &rest args)\n \"Like AND. VAR will be bound to the value of the previous AND form\"\n (cond ((null args) t)\n ((null (cdr args)) (car args))\n (t `(when-let (,var ,(car args))\n (and ,@(cdr args))))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defwalker-handler nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFWALKER-HANDLER", "input": "(defwalker-handler nil\n :key\n nil)", "output": "(defmacro DEFWALKER-HANDLER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(let-match* 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by LET-MATCH*", "input": "(let-match* 'lol-gen::some-name)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-gensyms nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-GENSYMS", "input": "(with-gensyms nil)", "output": "(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))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defaction nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFACTION", "input": "(defaction nil\n (progn))", "output": "(defmacro DEFACTION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defparameter nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DEFPARAMETER", "input": "(defparameter nil :key nil)", "output": "(defmacro DEFPARAMETER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(remove-from-plistf nil :key nil)", "output": "(defmacro REMOVE-FROM-PLISTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(dispatch-caseql-let 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DISPATCH-CASEQL-LET", "input": "(dispatch-caseql-let 'lol-gen::some-name)", "output": "(defmacro dispatch-caseql-let ((&rest bindings) &body clauses)\n \"Like `dispatch-case-let', but using the clause syntax of `dispatch-caseql'.\"\n `(dispatch-case-let ,bindings\n ,@(expand-dispatch-caseql-clauses clauses)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(do-sequences 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DO-SEQUENCES", "input": "(do-sequences 'lol-gen::some-name)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(dowhile-it 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DOWHILE-IT", "input": "(dowhile-it 'lol-gen::some-name)", "output": "(defmacro dowhile-it (test &body body)\n \"Like DOWHILE. IT is bound to TEST.\"\n `(do ((it ,test ,test))\n ((not it))\n ,@body))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defun-cmatch* common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by DEFUN-CMATCH*", "input": "(defun-cmatch* common-lisp:nil\n common-lisp:nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ignore common-lisp:nil\n :key\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by IGNORE", "input": "(ignore common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro IGNORE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-open-files nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-OPEN-FILES", "input": "(with-open-files nil)", "output": "(defmacro with-open-files ((&rest args) &body body)\n \"A simple macro to open one or more files providing the streams for the BODY. The ARGS is a list of `(stream filespec options*)` as supplied to WITH-OPEN-FILE.\"\n (case (length args)\n ((0)\n `(progn ,@body))\n ((1)\n `(with-open-file ,(first args) ,@body))\n (t `(with-open-file ,(first args)\n (with-open-files\n ,(rest args) ,@body)))))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.815} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(and-bind nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AND-BIND", "input": "(and-bind nil :key nil)", "output": "(defmacro AND-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(continue-whopper nil (progn))\n\nPattern to recognize: Macro call that should be transformed by CONTINUE-WHOPPER", "input": "(continue-whopper nil (progn))", "output": "(defmacro CONTINUE-WHOPPER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(reversef nil)", "output": "(defmacro REVERSEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n;; Manual destructuring from sequences is verbose\n(let ((lst (compute-list)))\n (let ((a (elt lst 0))\n (b (elt lst 1))\n (c (subseq lst 2)))\n (process a b c)))\n\n;; Nested structures are even worse:\n(let ((tree (compute-tree)))\n (let ((x (elt tree 0))\n (inner (elt tree 1)))\n (let ((y (elt inner 0))\n (z (elt inner 1)))\n (compute x y z))))\n\nProblem: Manual sequence destructuring with elt/subseq is error-prone \u2014 want pattern-based destructuring like ML/Haskell", "input": ";; Manual destructuring from sequences is verbose\n(let ((lst (compute-list)))\n (let ((a (elt lst 0))\n (b (elt lst 1))\n (c (subseq lst 2)))\n (process a b c)))\n\n;; Nested structures are even worse:\n(let ((tree (compute-tree)))\n (let ((x (elt tree 0))\n (inner (elt tree 1)))\n (let ((y (elt inner 0))\n (z (elt inner 1)))\n (compute x y z))))", "output": "(defmacro dbind (pat seq &body body)\n (let ((gseq (gensym)))\n `(let ((,gseq ,seq))\n ,(dbind-ex (destruc pat gseq #'atom) body))))", "category": "dsl", "technique": "gensym,nested-backquote", "complexity": "intermediate", "quality_score": 0.9625} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(do-symbol-macros-in-lexenv 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DO-SYMBOL-MACROS-IN-LEXENV", "input": "(do-symbol-macros-in-lexenv 'lol-gen::some-name)", "output": "(defmacro DO-SYMBOL-MACROS-IN-LEXENV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(decf nil)\n\nProblem: Macro call that should be transformed by DECF", "input": "(decf nil)", "output": "(defmacro DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-synapse nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-SYNAPSE", "input": "(with-synapse nil\n nil)", "output": "(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)))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-transaction nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-TRANSACTION", "input": "(with-transaction nil\n (progn))", "output": "(defmacro with-transaction (conn &body body)\n \"Start a transaction and commit at the end of this block. If the evaluation `body` is interrupted, the transaction is rolled back automatically.\"\n (let ((conn-var (gensym \"CONN-VAR\")))\n `(let ((,conn-var ,conn))\n (if (in-transaction ,conn-var)\n (with-savepoint ,conn-var ,@body)\n (%with-transaction ,conn-var ,@body)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ctypecase-of nil\n nil)\n\nProblem: Macro call that should be transformed by CTYPECASE-OF", "input": "(ctypecase-of nil\n nil)", "output": "(defmacro ctypecase-of (type keyplace &body body &environment env)\n \"Like `etypecase-of', but providing a `store-value' restart to correct KEYPLACE and try again.\"\n (check-exhaustiveness 'typecase type body env)\n `(ctypecase ,keyplace ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(enable-quasi-quoted-string-to-string-emitting-form-syntax 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by ENABLE-QUASI-QUOTED-STRING-TO-STRING-EMITTING-FORM-SYNTAX", "input": "(enable-quasi-quoted-string-to-string-emitting-form-syntax 'lol-gen::some-name)", "output": "(defmacro ENABLE-QUASI-QUOTED-STRING-TO-STRING-EMITTING-FORM-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(or)\n\nIssue: Macro call that should be transformed by OR", "input": "(or)", "output": "(defmacro OR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-templated-dispatch nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFINE-TEMPLATED-DISPATCH", "input": "(define-templated-dispatch nil\n (progn))", "output": "(defmacro DEFINE-TEMPLATED-DISPATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(the-part nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by THE-PART", "input": "(the-part nil :key nil)", "output": "(defmacro THE-PART ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-foreign-string 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WITH-FOREIGN-STRING", "input": "(with-foreign-string 'lol-gen::some-name)", "output": "(defmacro with-foreign-string ((var-or-vars lisp-string &rest args) &body body)\n \"VAR-OR-VARS is not evaluated and should be a list of the form\n\\(VAR &OPTIONAL BYTE-SIZE-VAR) or just a VAR symbol. VAR is\nbound to a foreign string containing LISP-STRING in BODY. When\nBYTE-SIZE-VAR is specified then bind the C buffer size\n\\(including the possible null terminator\\(s)) to this variable.\"\n (destructuring-bind (var &optional size-var)\n (ensure-list var-or-vars)\n `(multiple-value-bind (,var ,@(when size-var (list size-var)))\n (foreign-string-alloc ,lisp-string ,@args)\n (unwind-protect\n (progn ,@body)\n (foreign-string-free ,var)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(alet nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by ALET", "input": "(alet nil\n :key\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defun-cmatch* common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFUN-CMATCH*", "input": "(defun-cmatch* common-lisp:nil\n :key\n common-lisp:nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda-bind nil)\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-BIND", "input": "(lambda-bind nil)", "output": "(defmacro lambda-bind ((&rest instrs) &body body)\n \"Use `bind' to allow restructuring of argument to lambda expressions.\n\nThis lets you funcall and destructure simultaneously. For example\n\n (let ((fn (lambda-bind ((a b) c) (cons a c))))\n (funcall fn '(1 2) 3))\n ;; => (1 . 3)\n\nVia eschulte (see git://gist.github.com/902174.git).\n\"\n #+(or)\n (declare (indent 1))\n (let* ((evald-instrs instrs)\n (syms (mapcar (lambda (_)\n\t\t\t (declare (ignore _))\n\t\t\t (gensym))\n\t\t evald-instrs)))\n `(lambda ,syms (bind ,(mapcar #'list evald-instrs syms) ,@body))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda-cmatch*\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by LAMBDA-CMATCH*", "input": "(lambda-cmatch*\n common-lisp:nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(string-case nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by STRING-CASE", "input": "(string-case nil\n nil)", "output": "(defmacro STRING-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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 ->", "input": "(-> nil (progn))", "output": "(defmacro -> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(f0)\n\nWrite a macro that addresses: Macro call that should be transformed by F0", "input": "(f0)", "output": "(defmacro F0 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(on-conflict-do-nothing 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ON-CONFLICT-DO-NOTHING", "input": "(on-conflict-do-nothing 'lol-gen::some-name)", "output": "(defmacro on-conflict-do-nothing (&optional (conflict-target nil))\n `(make-clause :on-conflict-do-nothing ,conflict-target))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-none-awake nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-NONE-AWAKE", "input": "(with-none-awake nil\n nil)", "output": "(defmacro with-none-awake ((&key dbg diag) &body body)\n `(call-with-none-awake ,dbg (lambda () ,@body) ,diag))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ensure-transaction\n nil)\n\nWhat needs to change: Macro call that should be transformed by ENSURE-TRANSACTION", "input": "(ensure-transaction\n nil)", "output": "(defmacro ensure-transaction (&body body)\n \"Ensures that body is executed within a transaction, but does not begin a new\ntransaction if one is already in progress.\"\n `(call-with-ensured-transaction (lambda () ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-class-method nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-CLASS-METHOD", "input": "(define-class-method nil\n (progn))", "output": "(defmacro DEFINE-CLASS-METHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(some-<>\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SOME-<>", "input": "(some-<>\n nil\n :key\n nil)", "output": "(defmacro SOME-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(raw 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by RAW", "input": "(raw 'lol-gen::some-name)", "output": "(defmacro raw (&rest forms)\n `(list ,@forms))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c?1\n nil\n (progn))\n\nProblem: Macro call that should be transformed by C?1", "input": "(c?1\n nil\n (progn))", "output": "(defmacro c?1 (&body body)\n `(c?once ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-capped-stack nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-CAPPED-STACK", "input": "(with-capped-stack nil)", "output": "(defmacro with-capped-stack (() &body body)\n `(stack-capper (lambda () ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lazy-seq nil)\n\nIssue: Macro call that should be transformed by LAZY-SEQ", "input": "(lazy-seq nil)", "output": "(defmacro lazy-seq (head &optional tail)\n \"Creates a `LAZY-SEQ' where HEAD is the first element in the\n sequence and TAIL is a form which computes the remainder of the\n sequence. TAIL is wrapped in a function that stores the result of\n evaluating FORM, the first time it is invoked, and returns the\n stored result in future invocations.\"\n\n `(make-lazy-seq :head ,head :tail (thunk ,tail)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(subtest nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SUBTEST", "input": "(subtest nil\n (progn))", "output": "(defmacro subtest (desc &body body)\n `(%subtest ,desc (lambda () ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(when-failing nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WHEN-FAILING", "input": "(when-failing nil)", "output": "(defmacro WHEN-FAILING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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?", "input": "(necessarily?\n nil)", "output": "(defmacro NECESSARILY? ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defreply nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFREPLY", "input": "(defreply nil\n (progn))", "output": "(defmacro DEFREPLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(nlet nil\n (progn))\n\nProblem: Macro call that should be transformed by NLET", "input": "(nlet nil\n (progn))", "output": "(defmacro nlet (name (&rest bindings) &body body &environment env)\n \"Within BODY, bind NAME as a function, somewhat like LABELS, but\nwith the guarantee that recursive calls to NAME will not grow the\nstack.\n\n`nlet' resembles Scheme\u2019s named let, and is used for the same purpose:\nwriting loops using tail recursion. You could of course do this with\n`labels' as well, at least under some Lisp implementations, but `nlet'\nguarantees tail call elimination anywhere and everywhere.\n\n (nlet rec ((i 1000000))\n (if (= i 0)\n 0\n (rec (1- i))))\n => 0\n\nBeware: because of the way it is written (literally, a GOTO with\narguments), `nlet' is limited: self calls must be tail calls. That is,\nyou cannot use `nlet' for true recursion.\n\nThe name comes from `Let Over Lambda', but this is a more careful\nimplementation: the function is not bound while the initial arguments\nare being evaluated, and it is safe to close over the arguments.\"\n (setf bindings (loop for binding in bindings\n if (symbolp binding)\n collect `(,binding ,binding)\n else collect binding))\n (multiple-value-bind (body decls)\n (parse-body body)\n (let* ((bindings (mapcar #'ensure-list bindings))\n (vars (mapcar #'first bindings))\n (inits (mapcar #'second bindings))\n (temps (mapcar #'string-gensym vars))\n (alist (pairlis vars temps))\n (decls\n (map-declaration-env\n (lambda (id names env)\n (values id (sublis alist names) env))\n (parse-declarations decls env))))\n (with-gensyms (tag)\n `(block ,name\n (let ,(mapcar #'list temps inits)\n ,@(build-declarations 'declare decls)\n (macrolet ((,name ,vars\n `(progn\n (psetq\n ,@(mapcan #'list\n ',temps\n (list ,@vars)))\n (go ,',tag))))\n (tagbody\n ,tag (return-from ,name\n (let ,(mapcar #'list vars temps)\n ,@body))))))))))", "category": "anaphoric", "technique": "macrolet,tagbody-go,gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(nsplice-seqf 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by NSPLICE-SEQF", "input": "(nsplice-seqf 'lol-gen::some-name)", "output": "(defmacro NSPLICE-SEQF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-gensyms nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-GENSYMS", "input": "(with-gensyms nil\n nil)", "output": "(defmacro with-gensyms (names &body forms)\n \"Binds a set of variables to gensyms and evaluates the implicit progn FORMS.\n\nEach element within NAMES is either a symbol SYMBOL or a pair (SYMBOL\nSTRING-DESIGNATOR). Bare symbols are equivalent to the pair (SYMBOL SYMBOL).\n\nEach pair (SYMBOL STRING-DESIGNATOR) specifies that the variable named by SYMBOL\nshould be bound to a symbol constructed using GENSYM with the string designated\nby STRING-DESIGNATOR being its first argument.\"\n `(let ,(mapcar (lambda (name)\n (multiple-value-bind (symbol string)\n (etypecase name\n (symbol\n (values name (symbol-name name)))\n ((cons symbol (cons string-designator null))\n (values (first name) (string (second name)))))\n `(,symbol (gensym ,string))))\n names)\n ,@forms))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(->*\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by ->*", "input": "(->*\n nil\n :key\n nil)", "output": "(defmacro ->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(upper nil nil)\n\nWhat needs to change: Macro call that should be transformed by UPPER", "input": "(upper nil nil)", "output": "(defmacro upper (self &optional (type t))\n `(container-typed ,self ',type))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(while nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WHILE", "input": "(while nil\n nil)", "output": "(defmacro WHILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(->*)\n\nWhat needs to change: Macro call that should be transformed by ->*", "input": "(->*)", "output": "(defmacro ->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(coercef nil (progn))\n\nIssue: Macro call that should be transformed by COERCEF", "input": "(coercef nil (progn))", "output": "(defmacro COERCEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cardinality-case 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by CARDINALITY-CASE", "input": "(cardinality-case 'lol-gen::some-name)", "output": "(defmacro CARDINALITY-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-vari-macro nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-VARI-MACRO", "input": "(define-vari-macro nil\n nil)", "output": "(defmacro define-vari-macro (name lambda-list &body body)\n (check-args-for-constant-names :macro name lambda-list)\n (vbind (func-code context) (gen-macro-function-code name lambda-list body)\n `(progn\n (add-global-form-binding\n (make-regular-macro ',name ,func-code ',context nil))\n ',name)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(when-let nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WHEN-LET", "input": "(when-let nil\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(prepare 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by PREPARE", "input": "(prepare 'lol-gen::some-name)", "output": "(defmacro prepare (query &optional (format :rows))\n \"Wraps a query into a function that can be used as the interface to a prepared\nstatement. The given query (either a string or an S-SQL form) may contain\nplaceholders, which look like $1, $2, etc. The resulting function takes one\nargument for every placeholder in the query, executes the prepared query, and\nreturns the result in the format specified. (Allowed formats are the same as for\nquery.)\n\nFor queries that have to be run very often, especially when they are complex,\nit may help performance since the server only has to plan them once. See the\nhttp://www.postgresql.org/docs/current/static/sql-prepare.html\nin the PostgreSQL manual for details.\n\nIn some cases, the server will complain about not being able to deduce the type\nof the arguments in a statement. In that case you should add type\ndeclarations (either with the PostgreSQL's CAST SQL-conforming syntax or\nhistorical :: syntax, or with S-SQL's :type construct) to help it out.\n\nNote that it will attempt to automatically reconnect if database-connection-error,\nor admin-shutdown. It will reset prepared statements triggering an\ninvalid-sql-statement-name error. It will overwrite old prepared statements\ntriggering a duplicate-prepared-statement error.\"\n `(let ((overwrite ,*allow-overwriting-prepared-statements*))\n ,(generate-prepared '(lambda) (next-statement-id) query format)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(isnt nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ISNT", "input": "(isnt nil :key nil)", "output": "(defmacro isnt (comp expected form &optional description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(isnt ,comp ,expected ,form)\n :value-form ',form\n :body (lambda () ,form)\n :expected ,expected\n :comparison ,(maybe-quote comp)\n :comparison-geq NIL\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ps-package-prefix nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PS-PACKAGE-PREFIX", "input": "(ps-package-prefix nil)", "output": "(defmacro PS-PACKAGE-PREFIX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ensure-get nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by ENSURE-GET", "input": "(ensure-get nil\n (progn))", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(c-input nil)\n\nIssue: Macro call that should be transformed by C-INPUT", "input": "(c-input nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cmatch common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by CMATCH", "input": "(cmatch common-lisp:nil\n (common-lisp:progn))", "output": "(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))))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(like nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LIKE", "input": "(like nil :key nil)", "output": "(defmacro like (got regex &optional desc)\n (with-gensyms (duration result)\n (once-only (regex desc)\n `(with-catching-errors (:description ,desc :expected ,regex)\n (with-duration ((,duration ,result) ,got)\n (test ,result ,regex ,desc\n :duration ,duration\n :test-fn (lambda (x y) (not (null (ppcre:scan y x))))\n :report-expected-label \"be like\"))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(c?n\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by C?N", "input": "(c?n\n 'lol-gen::some-name)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defmacro+ps nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFMACRO+PS", "input": "(defmacro+ps nil\n (progn))", "output": "(defmacro DEFMACRO+PS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(make-$instance 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by MAKE-$INSTANCE", "input": "(make-$instance 'lol-gen::some-name)", "output": "(defmacro MAKE-$INSTANCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda-match\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LAMBDA-MATCH", "input": "(lambda-match\n common-lisp:nil)", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(some->>\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by SOME->>", "input": "(some->>\n nil\n :key\n nil)", "output": "(defmacro SOME->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(destructuring-ccase nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DESTRUCTURING-CCASE", "input": "(destructuring-ccase nil)", "output": "(defmacro destructuring-ccase (keyform &body clauses)\n (expand-destructuring-case keyform clauses 'ccase))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(char-case 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by CHAR-CASE", "input": "(char-case 'lol-gen::some-name)", "output": "(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)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(whichever)\n\nWrite a macro that addresses: Macro call that should be transformed by WHICHEVER", "input": "(whichever)", "output": "(defmacro whichever (&rest possibilities &environment env)\n \"Evaluates exactly one of POSSIBILITIES, chosen at random.\"\n (setf possibilities (mapcar (lambda (p) (macroexpand p env)) possibilities))\n (let ((length (length possibilities)))\n (cond\n ((= 1 length)\n (first possibilities))\n ((every #'constantp possibilities)\n `(svref (load-time-value (vector ,@possibilities)) \n (random ,length)))\n (T\n (labels ((expand (possibilities position random-number)\n (if (null (cdr possibilities))\n (car possibilities)\n (let* ((length (length possibilities))\n (half (truncate length 2))\n (second-half (nthcdr half possibilities))\n (first-half (butlast possibilities (- length half))))\n `(if (< ,random-number ,(+ position half))\n ,(expand first-half position random-number)\n ,(expand second-half (+ position half) random-number))))))\n (with-gensyms (random-number)\n `(let ((,random-number (random ,length)))\n ,(expand possibilities 0 random-number))))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(bind-custom-vars nil\n (progn))\n\nIssue: Macro call that should be transformed by BIND-CUSTOM-VARS", "input": "(bind-custom-vars nil\n (progn))", "output": "(defmacro bind-custom-vars ((&rest customizations) &body body)\n `(let ,(loop-on-custom (key var value) customizations\n collect (list var value))\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(execute nil)\n\nProblem: Macro call that should be transformed by EXECUTE", "input": "(execute nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(documentation common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by DOCUMENTATION", "input": "(documentation common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro DOCUMENTATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(f-delta nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by F-DELTA", "input": "(f-delta nil\n nil)", "output": "(defmacro f-delta (synapse-id (&key sensitivity (type 'number)) &body body)\n `(call-f-delta ,synapse-id ,sensitivity ',type (lambda () ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(on-duplicate-key-update nil (progn))\n\nPattern to recognize: Macro call that should be transformed by ON-DUPLICATE-KEY-UPDATE", "input": "(on-duplicate-key-update nil (progn))", "output": "(defmacro on-duplicate-key-update (&rest args)\n `(make-clause :on-duplicate-key-update ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-collectors nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-COLLECTORS", "input": "(with-collectors nil\n nil)", "output": "(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))))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(dispatch-case nil\n (progn))\n\nProblem: Macro call that should be transformed by DISPATCH-CASE", "input": "(dispatch-case nil\n (progn))", "output": "(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)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(returning nil (progn))\n\nIssue: Macro call that should be transformed by RETURNING", "input": "(returning nil (progn))", "output": "(defmacro RETURNING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(reversef nil)\n\nPattern to recognize: Macro call that should be transformed by REVERSEF", "input": "(reversef nil)", "output": "(defmacro REVERSEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(scond)\n\nPattern to recognize: Macro call that should be transformed by SCOND", "input": "(scond)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.79} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fm!v nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FM!V", "input": "(fm!v nil)", "output": "(defmacro fm!v (id)\n `(value (fm! ,id)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cond->>)\n\nIssue: Macro call that should be transformed by COND->>", "input": "(cond->>)", "output": "(defmacro COND->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(collecting\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by COLLECTING", "input": "(collecting\n 'lol-gen::some-name)", "output": "(defmacro collecting (&body body)\n \"Like `with-collector', with the collector bound to the result of\ninterning `collect' in the current package.\"\n (with-current-package-symbols (collect)\n `(with-collector (,collect)\n ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-mapping-collector 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WITH-MAPPING-COLLECTOR", "input": "(with-mapping-collector 'lol-gen::some-name)", "output": "(defmacro WITH-MAPPING-COLLECTOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(actypecase nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by ACTYPECASE", "input": "(actypecase nil\n :key\n nil)", "output": "(defmacro actypecase (keyform &body cases)\n \"Like CTYPECASE, except binds the result of the keyform to IT (via LET) for\nthe scope of the cases. Unlike CTYPECASE, new values possible stored by the\nSTORE-VALUE restart are not received by the keyform/place, but by IT.\"\n `(anaphoric ctypecase ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c_?dbg)\n\nWrite a macro that addresses: Macro call that should be transformed by C_?DBG", "input": "(c_?dbg)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-first nil nil)\n\nIssue: Macro call that should be transformed by COLLECT-FIRST", "input": "(collect-first nil nil)", "output": "(defmacro COLLECT-FIRST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dletf nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DLETF", "input": "(dletf nil)", "output": "(defmacro DLETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-compiler-macro nil\n nil)\n\nIssue: Macro call that should be transformed by DEFINE-COMPILER-MACRO", "input": "(define-compiler-macro nil\n nil)", "output": "(defmacro DEFINE-COMPILER-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(pcase nil nil)\n\nIssue: Macro call that should be transformed by PCASE", "input": "(pcase nil nil)", "output": "(defmacro pcase (pred keyform &rest clauses)\n \"Like CASE, but uses given PRED instead of EQL to select appropriate CLAUSE.\n\n Example usage:\n\n CL-USER> (pcase '< 1\n (0 (print \\\"Below zero\\\"))\n (2 (print \\\"OK\\\"))\n (otherwise (error \\\"Oops\\\")))\n\"\n (expand-predicate-case pred keyform clauses 'case))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(do-generators nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DO-GENERATORS", "input": "(do-generators nil\n nil)", "output": "(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)))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(false nil :key nil)\n\nProblem: Macro call that should be transformed by FALSE", "input": "(false nil :key nil)", "output": "(defmacro false (form &optional description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(false ,form)\n :value-form ',form\n :body (lambda () ,form)\n :expected 'NIL\n :comparison 'geq\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ensure-functionf nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ENSURE-FUNCTIONF", "input": "(ensure-functionf nil :key nil)", "output": "(defmacro ensure-functionf (&rest places)\n \"Multiple-place modify macro for ENSURE-FUNCTION: ensures that each of\nPLACES contains a function.\"\n `(progn ,@(mapcar (lambda (x) `(ensure-functionf/1 ,x)) places)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(def-shadow-type-constructor nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEF-SHADOW-TYPE-CONSTRUCTOR", "input": "(def-shadow-type-constructor nil nil)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(for-all nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FOR-ALL", "input": "(for-all nil\n nil)", "output": "(defmacro for-all (bindings &body body)\n \"Bind BINDINGS to random variables and test BODY *num-trials* times.\n\nBINDINGS is a list of binding forms, each element is a list\nof (BINDING VALUE &optional GUARD). Value, which is evaluated\nonce when the for-all is evaluated, must return a generator which\nbe called each time BODY is evaluated. BINDING is either a symbol\nor a list which will be passed to destructuring-bind. GUARD is a\nform which, if present, stops BODY from executing when IT returns\nNIL. The GUARDS are evaluated after all the random data has been\ngenerated and they can refer to the current value of any\nbinding. NB: Generator forms, unlike guard forms, can not contain\nreferences to the bound variables.\n\nExamples:\n\n (for-all ((a (gen-integer)))\n (is (integerp a)))\n\n (for-all ((a (gen-integer) (plusp a)))\n (is (integerp a))\n (is (plusp a)))\n\n (for-all ((less (gen-integer))\n (more (gen-integer) (< less more)))\n (is (<= less more)))\n\n (for-all (((a b) (gen-two-integers)))\n (is (integerp a))\n (is (integerp b)))\"\n (with-gensyms (test-lambda-args)\n `(perform-random-testing\n (list ,@(mapcar #'second bindings))\n (lambda (,test-lambda-args)\n (destructuring-bind ,(mapcar #'first bindings)\n ,test-lambda-args\n (if (and ,@(delete-if #'null (mapcar #'third bindings)))\n (progn ,@body)\n (throw 'run-once\n (list :guard-conditions-failed))))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(stypecase 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by STYPECASE", "input": "(stypecase 'lol-gen::some-name)", "output": "(defmacro stypecase (keyform &body cases)\n \"Like TYPECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for the\nscope of the cases. IT can be set with SETF.\"\n `(symbolic typecase ,keyform ,@cases))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(incf 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by INCF", "input": "(incf 'lol-gen::some-name)", "output": "(defmacro INCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(multiple-value-ematch nil)\n\nPattern to recognize: Macro call that should be transformed by MULTIPLE-VALUE-EMATCH", "input": "(multiple-value-ematch nil)", "output": "(defmacro multiple-value-ematch (values-form &body clauses)\n \"Same as MULTIPLE-VALUE-MATCH, except MATCH-ERROR will be raised if\nnot matched.\"\n (let* ((values (gensym \"VALUES\"))\n (else `(error '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))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ps-to-stream 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by PS-TO-STREAM", "input": "(ps-to-stream 'lol-gen::some-name)", "output": "(defmacro PS-TO-STREAM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-compilation-unit nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-COMPILATION-UNIT", "input": "(with-compilation-unit nil :key nil)", "output": "(defmacro WITH-COMPILATION-UNIT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(order-by nil)\n\nIssue: Macro call that should be transformed by ORDER-BY", "input": "(order-by nil)", "output": "(defmacro ORDER-BY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(once-only nil)\n\nIssue: Macro call that should be transformed by ONCE-ONLY", "input": "(once-only nil)", "output": "(defmacro once-only (specs &body forms)\n \"Constructs code whose primary goal is to help automate the handling of\nmultiple evaluation within macros. Multiple evaluation is handled by introducing\nintermediate variables, in order to reuse the result of an expression.\n\nThe returned value is a list of the form\n\n (let (( )\n ...\n ( ))\n )\n\nwhere GENSYM-1, ..., GENSYM-N are the intermediate variables introduced in order\nto evaluate EXPR-1, ..., EXPR-N once, only. RES is code that is the result of\nevaluating the implicit progn FORMS within a special context determined by\nSPECS. RES should make use of (reference) the intermediate variables.\n\nEach element within SPECS is either a symbol SYMBOL or a pair (SYMBOL INITFORM).\nBare symbols are equivalent to the pair (SYMBOL SYMBOL).\n\nEach pair (SYMBOL INITFORM) specifies a single intermediate variable:\n\n- INITFORM is an expression evaluated to produce EXPR-i\n\n- SYMBOL is the name of the variable that will be bound around FORMS to the\n corresponding gensym GENSYM-i, in order for FORMS to generate RES that\n references the intermediate variable\n\nThe evaluation of INITFORMs and binding of SYMBOLs resembles LET. INITFORMs of\nall the pairs are evaluated before binding SYMBOLs and evaluating FORMS.\n\nExample:\n\n The following expression\n\n (let ((x '(incf y)))\n (once-only (x)\n `(cons ,x ,x)))\n\n ;;; =>\n ;;; (let ((#1=#:X123 (incf y)))\n ;;; (cons #1# #1#))\n\n could be used within a macro to avoid multiple evaluation like so\n\n (defmacro cons1 (x)\n (once-only (x)\n `(cons ,x ,x)))\n\n (let ((y 0))\n (cons1 (incf y)))\n\n ;;; => (1 . 1)\n\nExample:\n\n The following expression demonstrates the usage of the INITFORM field\n\n (let ((expr '(incf y)))\n (once-only ((var `(1+ ,expr)))\n `(list ',expr ,var ,var)))\n\n ;;; =>\n ;;; (let ((#1=#:VAR123 (1+ (incf y))))\n ;;; (list '(incf y) #1# #1))\n\n which could be used like so\n\n (defmacro print-succ-twice (expr)\n (once-only ((var `(1+ ,expr)))\n `(format t \\\"Expr: ~s, Once: ~s, Twice: ~s~%\\\" ',expr ,var ,var)))\n\n (let ((y 10))\n (print-succ-twice (incf y)))\n\n ;;; >>\n ;;; Expr: (INCF Y), Once: 12, Twice: 12\"\n (let ((gensyms (make-gensym-list (length specs) \"ONCE-ONLY\"))\n (names-and-forms (mapcar (lambda (spec)\n (etypecase spec\n (list\n (destructuring-bind (name form) spec\n (cons name form)))\n (symbol\n (cons spec spec))))\n specs)))\n ;; bind in user-macro\n `(let ,(mapcar (lambda (g n) (list g `(gensym ,(string (car n)))))\n gensyms names-and-forms)\n ;; bind in final expansion\n `(let (,,@(mapcar (lambda (g n)\n ``(,,g ,,(cdr n)))\n gensyms names-and-forms))\n ;; bind in user-macro\n ,(let ,(mapcar (lambda (n g) (list (car n) g))\n names-and-forms gensyms)\n ,@forms)))))", "category": "control-flow", "technique": "once-only,gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(pprint-coalton-codegen-ast)\n\nWrite a macro that addresses: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-AST", "input": "(pprint-coalton-codegen-ast)", "output": "(defmacro PPRINT-COALTON-CODEGEN-AST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defjsmacro nil (progn))\n\nProblem: Macro call that should be transformed by DEFJSMACRO", "input": "(defjsmacro nil (progn))", "output": "(defmacro DEFJSMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(string-literal 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by STRING-LITERAL", "input": "(string-literal 'lol-gen::some-name)", "output": "(defmacro STRING-LITERAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(if-match common-lisp:nil\n :key\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by IF-MATCH", "input": "(if-match common-lisp:nil\n :key\n common-lisp:nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fbind nil)\n\nIssue: Macro call that should be transformed by FBIND", "input": "(fbind nil)", "output": "(defmacro fbind (bindings &body body &environment *lexenv*)\n \"Binds values in the function namespace.\n\nThat is,\n (fbind ((fn (lambda () ...))))\n \u2261 (flet ((fn () ...))),\n\nexcept that a bare symbol in BINDINGS is rewritten as (symbol\nsymbol).\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbind `(locally ,@body)))\n ;; When possible (if the binding expands to a simple\n ;; let-over-lambda), we hoist the bindings to the top and bind\n ;; the lambda directly with flet.\n\n ;; Failing that, if we know that the function is never directly\n ;; dereferenced with sharp-quote, we can bind with `macrolet'\n ;; instead of `flet', leaving no runtime overhead vs. `funcall'.\n (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))\n (macro-vars\n (merely-syntactic-functions (mapcar #'first bindings)\n body\n *lexenv*))\n (vars (mapcar #'first bindings))\n (exprs (mapcar #'second bindings))\n (temps (mapcar #'string-gensym vars))\n (body decls (parse-body body)))\n `(let ,env\n ,@(unsplice (and env-decls `(declare ,@env-decls)))\n (comment \"fbind: Hidden variable bindings to close over.\")\n (let ,(loop for temp in temps\n for expr in exprs\n collect `(,temp (ensure-function ,expr)))\n ,@(when temps\n (unsplice\n `(declare (function ,@temps))))\n (comment \"fbind: Hidden variable bindings for function values.\")\n (flet (,@(loop for (name lambda) in lambdas\n collect `(,name ,@(cdr lambda)))\n ,@(loop for var in vars\n for temp in temps\n unless (member var macro-vars)\n collect (build-bind/ftype var temp decls env)))\n #-sbcl (declare (inline ,@(set-difference vars macro-vars)))\n ,@decls\n (comment \"fbind: Functions that might be sharp-quoted.\")\n (macrolet (,@(loop for var in vars\n for temp in temps\n when (member var macro-vars)\n collect `(,var\n (&rest args)\n (list* 'funcall ',temp args))))\n (comment \"fbind: Macros for functions provably never sharp-quoted.\")\n ,@body))))))", "category": "control-flow", "technique": "macrolet,gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.84} {"instruction": "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", "input": "(*let nil\n nil)", "output": "(defmacro *LET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ps-html)\n\nIssue: Macro call that should be transformed by PS-HTML", "input": "(ps-html)", "output": "(defmacro PS-HTML ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\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\nWrite a macro that addresses: Repeated pattern of binding test result then branching on it \u2014 want implicit 'it' anaphor", "input": ";; 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", "output": "(defmacro aif (test then &optional else)\n `(let ((it ,test))\n (if it ,then ,else)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.9125} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(assert common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by ASSERT", "input": "(assert common-lisp:nil)", "output": "(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))))", "category": "control-flow", "technique": "gensym", "complexity": "advanced", "quality_score": 0.8724999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(brkx nil)\n\nPattern to recognize: Macro call that should be transformed by BRKX", "input": "(brkx nil)", "output": "(defmacro brkx (msg)\n `(break \"At ~a: OK?\" ',msg))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(loop 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by LOOP", "input": "(loop 'lol-gen::some-name)", "output": "(defmacro LOOP ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH", "input": "(with nil)", "output": "(defmacro WITH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(-<> nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by -<>", "input": "(-<> nil (progn))", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(local-output\n nil)\n\nIssue: Macro call that should be transformed by LOCAL-OUTPUT", "input": "(local-output\n nil)", "output": "(defmacro LOCAL-OUTPUT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(proxy nil nil)\n\nIssue: Macro call that should be transformed by PROXY", "input": "(proxy nil nil)", "output": "(defmacro PROXY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ekx nil :key nil)\n\nProblem: Macro call that should be transformed by EKX", "input": "(ekx nil :key nil)", "output": "(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)))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(reduced-typecase nil)\n\nProblem: Macro call that should be transformed by REDUCED-TYPECASE", "input": "(reduced-typecase nil)", "output": "(defmacro REDUCED-TYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-global-parameter* nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-GLOBAL-PARAMETER*", "input": "(define-global-parameter* nil (progn))", "output": "(defmacro DEFINE-GLOBAL-PARAMETER* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(pecase nil nil)\n\nProblem: Macro call that should be transformed by PECASE", "input": "(pecase nil nil)", "output": "(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))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(block-compile nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by BLOCK-COMPILE", "input": "(block-compile nil\n nil)", "output": "(defmacro block-compile ((&key entry-points\n (block-compile t))\n &body body)\n \"Shorthand for block compilation with `local*'.\n\nOnly the functions in ENTRY-POINTS will have global definitions. All\nother functions in BODY will be compiled as purely local functions,\nand all of their calls to one another will be compiled as local calls.\nThis includes calls to the entry points, and even self-calls from\nwithin the entry points.\n\nNote that `declaim' forms occuring inside of BODY will be translated\ninto local `declare' forms.\n\nIf you pass `:block-compile nil', this macro is equivalent to progn.\nThis may be useful during development.\"\n (if (not block-compile) `(progn ,@body)\n `(local*\n ,@body\n (progn\n ,@(loop for entry-point in entry-points\n collect `(defalias ,entry-point #',entry-point))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(if-not-let nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by IF-NOT-LET", "input": "(if-not-let nil\n (progn))", "output": "(defmacro if-not-let (bindings &body (then-form &optional else-form))\n \"Creates new variable bindings, and conditionally executes either\nTHEN-FORM or ELSE-FORM. ELSE-FORM defaults to NIL.\nBINDINGS must be either single binding of the form:\n (variable initial-form)\nor a list of bindings of the form:\n ((variable-1 initial-form-1)\n (variable-2 initial-form-2)\n ...\n (variable-n initial-form-n))\nAll initial-forms are executed sequentially in the specified order. Then all\nthe variables are bound to the corresponding values.\nIf one of the variables was bound to NIL, the THEN-FORM is executed with the\nbindings in effect, otherwise the ELSE-FORM is executed with the bindings in\neffect.\nAdapted from Alexandria if-let.\"\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 (if-not (and ,@variables)\n\t ,then-form\n\t ,else-form))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(local*\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by LOCAL*", "input": "(local*\n nil\n :key\n nil)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(some->> nil nil)\n\nPattern to recognize: Macro call that should be transformed by SOME->>", "input": "(some->> nil nil)", "output": "(defmacro SOME->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(c-envalue)\n\nIssue: Macro call that should be transformed by C-ENVALUE", "input": "(c-envalue)", "output": "(defmacro c-envalue (&body body)\n `(make-c-envaluer\n :envalue-rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(export-constructors\n common-lisp:nil\n :key\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by EXPORT-CONSTRUCTORS", "input": "(export-constructors\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro EXPORT-CONSTRUCTORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(join nil)\n\nPattern to recognize: Macro call that should be transformed by JOIN", "input": "(join nil)", "output": "(defmacro join (table &key (kind :inner) on using)\n `(make-clause :join ,(expand-op table)\n :kind ,kind\n ,@(if on\n `(:on ,(if (and (listp on)\n (keywordp (car on)))\n (expand-op on)\n `,on))\n nil)\n ,@(if using\n `(:using ',using)\n nil)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(ps)\n\nPattern to recognize: Macro call that should be transformed by PS", "input": "(ps)", "output": "(defmacro PS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(type 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by TYPE", "input": "(type 'lol-gen::some-name)", "output": "(defmacro TYPE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(to-boolean 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by TO-BOOLEAN", "input": "(to-boolean 'lol-gen::some-name)", "output": "(defmacro TO-BOOLEAN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(prog (quote lol-gen::some-name))\n\nProblem: Macro call that should be transformed by PROG", "input": "(prog (quote lol-gen::some-name))", "output": "(defmacro PROG ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(psib)\n\nWrite a macro that addresses: Macro call that should be transformed by PSIB", "input": "(psib)", "output": "(defmacro psib (&optional (self-form 'self))\n (let ((self (gensym)))\n `(bwhen (,self ,self-form)\n (find-prior ,self (kids (fm-parent ,self))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "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 *>", "input": "(*> nil :key nil)", "output": "(defmacro *> (parser &rest parsers)\n \"Combination of parsers yielding the result of the rightmost one.\"\n (let ((offset (gensym \"*>-OFFSET\")))\n `(lambda (,offset)\n ,(reduce (lambda (i p)\n (let ((res (gensym \"*>-RES\"))\n (next (gensym \"*>-NEXT\")))\n `(multiple-value-bind (,res ,next) ,i\n (if (ok? ,res)\n (funcall ,p ,next)\n (fail ,next)))))\n parsers\n :initial-value `(funcall ,parser ,offset)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(fdec nil)\n\nPattern to recognize: Macro call that should be transformed by FDEC", "input": "(fdec nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(xor nil nil)\n\nIssue: Macro call that should be transformed by XOR", "input": "(xor nil nil)", "output": "(defmacro xor (&rest datums)\n \"Evaluates its arguments one at a time, from left to right. If more than one\nargument evaluates to a true value no further DATUMS are evaluated, and NIL is\nreturned as both primary and secondary value. If exactly one argument\nevaluates to true, its value is returned as the primary value after all the\narguments have been evaluated, and T is returned as the secondary value. If no\narguments evaluate to true NIL is returned as primary, and T as secondary\nvalue.\"\n (with-gensyms (xor tmp true)\n `(let (,tmp ,true)\n (declare (ignorable ,tmp))\n (block ,xor\n ,@(mapcar (lambda (datum)\n `(if (setf ,tmp ,datum)\n (if ,true\n (return-from ,xor (values nil nil))\n (setf ,true ,tmp))))\n datums)\n (return-from ,xor (values ,true t))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "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", "input": "(aecase nil\n (progn))", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-dot nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-DOT", "input": "(with-dot nil\n (progn))", "output": "(defmacro with-dot (() &body body)\n `(progn ,@(replace-dot-calls body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": ";; 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", "output": "(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)))))))", "category": "dispatch", "technique": "dlambda,nested-backquote", "complexity": "advanced", "quality_score": 0.975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(terminate-producing)\n\nWrite a macro that addresses: Macro call that should be transformed by TERMINATE-PRODUCING", "input": "(terminate-producing)", "output": "(defmacro TERMINATE-PRODUCING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "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", "input": "(with-shuffling\n nil)", "output": "(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))))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(nconcf nil :key nil)\n\nProblem: Macro call that should be transformed by NCONCF", "input": "(nconcf nil :key nil)", "output": "(defmacro NCONCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(next-in 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by NEXT-IN", "input": "(next-in 'lol-gen::some-name)", "output": "(defmacro NEXT-IN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c-input 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by C-INPUT", "input": "(c-input 'lol-gen::some-name)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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 .<", "input": "(.<)", "output": "(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))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(and nil)\n\nWhat needs to change: Macro call that should be transformed by AND", "input": "(and nil)", "output": "(defmacro AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defpackage nil)\n\nWhat needs to change: Macro call that should be transformed by DEFPACKAGE", "input": "(defpackage nil)", "output": "(defmacro DEFPACKAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(unwind-protect-case nil\n (progn))\n\nIssue: Macro call that should be transformed by UNWIND-PROTECT-CASE", "input": "(unwind-protect-case nil\n (progn))", "output": "(defmacro unwind-protect-case ((&optional abort-flag) protected-form &body clauses)\n \"Like CL:UNWIND-PROTECT, but you can specify the circumstances that\nthe cleanup CLAUSES are run.\n\n clauses ::= (:NORMAL form*)* | (:ABORT form*)* | (:ALWAYS form*)*\n\nClauses can be given in any order, and more than one clause can be\ngiven for each circumstance. The clauses whose denoted circumstance\noccured, are executed in the order the clauses appear.\n\nABORT-FLAG is the name of a variable that will be bound to T in\nCLAUSES if the PROTECTED-FORM aborted preemptively, and to NIL\notherwise.\n\nExamples:\n\n (unwind-protect-case ()\n (protected-form)\n (:normal (format t \\\"This is only evaluated if PROTECTED-FORM executed normally.~%\\\"))\n (:abort (format t \\\"This is only evaluated if PROTECTED-FORM aborted preemptively.~%\\\"))\n (:always (format t \\\"This is evaluated in either case.~%\\\")))\n\n (unwind-protect-case (aborted-p)\n (protected-form)\n (:always (perform-cleanup-if aborted-p)))\n\"\n (check-type abort-flag (or null symbol))\n (let ((gflag (gensym \"FLAG+\")))\n `(let ((,gflag t))\n (unwind-protect (multiple-value-prog1 ,protected-form (setf ,gflag nil))\n\t (let ,(and abort-flag `((,abort-flag ,gflag)))\n\t ,@(loop for (cleanup-kind . forms) in clauses\n\t\t collect (ecase cleanup-kind\n\t\t\t (:normal `(when (not ,gflag) ,@forms))\n\t\t\t (:abort `(when ,gflag ,@forms))\n\t\t\t (:always `(progn ,@forms)))))))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(metaclass common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by METACLASS", "input": "(metaclass common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro METACLASS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ignore-errors nil :key nil)\n\nIssue: Macro call that should be transformed by IGNORE-ERRORS", "input": "(ignore-errors nil :key nil)", "output": "(defmacro IGNORE-ERRORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-plist nil nil)\n\nWhat needs to change: Macro call that should be transformed by COLLECT-PLIST", "input": "(collect-plist nil nil)", "output": "(defmacro COLLECT-PLIST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-column-writers 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-COLUMN-WRITERS", "input": "(with-column-writers 'lol-gen::some-name)", "output": "(defmacro with-column-writers ((&rest defs) &body body)\n \"Provides control over the way get-dao, select-dao, and query-dao read values\nfrom the database. This is not commonly needed, but can be used to reduce the\namount of queries a system makes. writers should be a list of alternating\ncolumn names (strings or symbols) and writers, where writers are either\nsymbols referring to a slot in the objects, or functions taking two arguments \u2015\nan instance and a value \u2015 which can be used to somehow store the value in the\nnew instance. When any DAO-fetching function is called in the body, and\ncolumns matching the given names are encountered in the result, the writers\nare used instead of the default behaviour (try and store the value in the slot\nthat matches the column name).\n\nAn example of using this is to add some non-column slots to a DAO class, and\nuse query-dao within a with-column-writers form to pull in extra information\nabout the objects, and immediately store it in the new instances.\"\n `(let ((*custom-column-writers*\n (append (list ,@(loop :for (field writer) :on defs :by #'cddr\n :collect `(cons (to-sql-name ,field nil) ,writer)))\n *custom-column-writers*)))\n ,@body))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(<$ nil (progn))\n\nPattern to recognize: Macro call that should be transformed by <$", "input": "(<$ nil (progn))", "output": "(defmacro <$ (item parser)\n \"Run some parser, but substitute its inner value with some `item' if parsing was\n successful.\"\n (let ((offset (gensym \"<$-OFFSET\"))\n (res (gensym \"<$-RES\"))\n (next (gensym \"<$-NEXT\")))\n `(lambda (,offset)\n (multiple-value-bind (,res ,next) (funcall ,parser ,offset)\n (if (failure? ,res)\n (fail ,next)\n (values ,item ,next))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Generate a defmacro form that transforms code like this:\n(collect-max nil (progn))\n\nPattern to recognize: Macro call that should be transformed by COLLECT-MAX", "input": "(collect-max nil (progn))", "output": "(defmacro COLLECT-MAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ensure-functionf nil)\n\nWhat needs to change: Macro call that should be transformed by ENSURE-FUNCTIONF", "input": "(ensure-functionf nil)", "output": "(defmacro ensure-functionf (&rest places)\n \"Multiple-place modify macro for ENSURE-FUNCTION: ensures that each of\nPLACES contains a function.\"\n `(progn ,@(mapcar (lambda (x) `(ensure-functionf/1 ,x)) places)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ctypecase nil (progn))\n\nIssue: Macro call that should be transformed by CTYPECASE", "input": "(ctypecase nil (progn))", "output": "(defmacro CTYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(eval-when-execute)\n\nPattern to recognize: Macro call that should be transformed by EVAL-WHEN-EXECUTE", "input": "(eval-when-execute)", "output": "(defmacro EVAL-WHEN-EXECUTE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-rules 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-RULES", "input": "(with-rules 'lol-gen::some-name)", "output": "(defmacro WITH-RULES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(batch\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by BATCH", "input": "(batch\n nil\n (progn))", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cll-outer nil)\n\nIssue: Macro call that should be transformed by CLL-OUTER", "input": "(cll-outer nil)", "output": "(defmacro cll-outer (val &body body)\n `(let ((outer-val ,val))\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dreletf* nil\n (progn))\n\nIssue: Macro call that should be transformed by DRELETF*", "input": "(dreletf* nil\n (progn))", "output": "(defmacro DRELETF* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(do-instance-combinations nil)", "output": "(defmacro DO-INSTANCE-COMBINATIONS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(do-each 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DO-EACH", "input": "(do-each 'lol-gen::some-name)", "output": "(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))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(summing-to 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by SUMMING-TO", "input": "(summing-to 'lol-gen::some-name)", "output": "(defmacro SUMMING-TO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(some-<>\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by SOME-<>", "input": "(some-<>\n nil\n (progn))", "output": "(defmacro SOME-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(labels* nil)\n\nWhat needs to change: Macro call that should be transformed by LABELS*", "input": "(labels* nil)", "output": "(defmacro LABELS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-test+run-interactively nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-TEST+RUN-INTERACTIVELY", "input": "(define-test+run-interactively nil\n :key\n nil)", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(ecase 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by ECASE", "input": "(ecase 'lol-gen::some-name)", "output": "(defmacro ECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(-<>>)\n\nIssue: Macro call that should be transformed by -<>>", "input": "(-<>>)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(jwhen nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by JWHEN", "input": "(jwhen nil\n nil)", "output": "(defmacro jwhen (test &body body)\n \"JSON-aware version of `cl:when'.\nIf TEST is `jtruep' evaluate BODY.\"\n `(jif ,test\n (progn ,@body)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(caching-types\n nil\n (progn))\n\nProblem: Macro call that should be transformed by CACHING-TYPES", "input": "(caching-types\n nil\n (progn))", "output": "(defmacro CACHING-TYPES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ifmatch nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by IFMATCH", "input": "(ifmatch nil\n :key\n nil)", "output": "(defmacro IFMATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fbindrec* nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by FBINDREC*", "input": "(fbindrec* nil\n (progn))", "output": "(defmacro fbindrec* (bindings &body body &environment *lexenv*)\n \"Like `fbindrec`, but the function defined in each binding can be\nused in successive bindings.\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbindrec* `(locally ,@body)))\n (mvlet* ((env env-decls binds lambdas (analyze-fbinds bindings *lexenv*))\n (simple complex lambda unref\n (partition-fbinds (append binds lambdas)\n body))\n (temps (mapcar (op (gensym (string (first _)))) complex))\n (body decls (parse-body body))\n (simple-decls complex-decls lambda-decls others\n (partition-declarations-by-kind simple complex lambda decls)))\n `(let\n ;; Use dummies when we can (with ensure-function).\n ,(loop for (var init) in env\n collect (if (and (listp init)\n (eql (car init) 'ensure-function))\n `(,var #'invalid)\n var))\n ,@(unsplice (and env-decls `(declare ,@env-decls)))\n (comment \"fbind: Simple bindings\")\n (fbind ,simple\n ,@simple-decls\n (comment \"fbind: Temps for complex bindings\")\n (let ,(loop for temp in temps collect `(,temp #'invalid))\n (declare ,@(loop for temp in temps collect `(function ,temp)))\n (flet ,(loop for (name nil) in complex\n for temp in temps\n collect (build-bind/ftype name temp complex-decls env))\n ,@complex-decls\n (comment \"fbind: Lambdas\")\n (labels (,@(loop for (name lambda) in lambda\n collect `(,name ,@(cdr lambda))))\n ,@lambda-decls\n (comment \"fbind: Interleave unreferenced and complex bindings in order.\")\n ,@(remove nil\n (loop for (name nil) in bindings\n append (or (loop for (uname init) in unref\n if (eql uname name)\n return (list init))\n (loop for (cname init) in complex\n for temp in temps\n if (eql cname name)\n return `((setf ,temp (ensure-function ,init)))))))\n (comment \"fbind: Set the `env` variables for the lambdas\")\n (setf ,@(apply #'append env))\n (locally ,@others\n ,@body))))))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(c-lambda)\n\nPattern to recognize: Macro call that should be transformed by C-LAMBDA", "input": "(c-lambda)", "output": "(defmacro c-lambda (&body body)\n `(c-lambda-var (slot-c) ,@body))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda-ematch1 common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-EMATCH1", "input": "(lambda-ematch1 common-lisp:nil)", "output": "(defmacro lambda-ematch1 (pattern &body body)\n \"Equivalent to (lambda (arg) (ematch arg (PATTERN BODY...))).\"\n `(lambda-ematch (,pattern ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-hook-restart)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-HOOK-RESTART", "input": "(with-hook-restart)", "output": "(defmacro with-hook-restart (&body body)\n `(with-simple-restart (continue \"Call next function in hook ~s\" *hook*)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(do-generators nil)\n\nProblem: Macro call that should be transformed by DO-GENERATORS", "input": "(do-generators nil)", "output": "(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)))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "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", "input": "(with-collectors nil\n :key\n nil)", "output": "(defmacro WITH-COLLECTORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(call-method 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by CALL-METHOD", "input": "(call-method 'lol-gen::some-name)", "output": "(defmacro call-method (method &optional methods)\n `(cl:call-method ,method ,methods))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(xml)\n\nPattern to recognize: Macro call that should be transformed by XML", "input": "(xml)", "output": "(defmacro xml (&rest tags)\n `(with-doctype :xml\n (loop for tag in ',tags\n append (tag->string tag))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(dynamic-wind\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DYNAMIC-WIND", "input": "(dynamic-wind\n nil\n (progn))", "output": "(defmacro DYNAMIC-WIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(one-value nil nil)\n\nProblem: Macro call that should be transformed by ONE-VALUE", "input": "(one-value nil nil)", "output": "(defmacro ONE-VALUE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-local-class-registry nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITH-LOCAL-CLASS-REGISTRY", "input": "(with-local-class-registry nil\n :key\n nil)", "output": "(defmacro with-local-class-registry ((&key inherit) &body body)\n \"Run BODY in a dynamic environment where *CLASS-REGISTRY* is a\ntemporary local list. If :INHERIT is non-null, the local registry\nshall initially have the same content as the exterior *CLASS-REGISTRY*, \notherwise it shall be NIL.\"\n `(let ((*class-registry*\n ,(if inherit\n `(copy-alist\n ,(if (eql inherit t) '*class-registry* inherit)))))\n ,@body))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fn 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by FN", "input": "(fn 'lol-gen::some-name)", "output": "(defmacro FN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(eval-and-compile\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by EVAL-AND-COMPILE", "input": "(eval-and-compile\n nil\n (progn))", "output": "(defmacro eval-and-compile (&body body)\n \"Emacs's `eval-and-compile'.\nAlias for `eval-always'.\"\n `(eval-always\n ,@body))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(->>\n nil\n nil)\n\nProblem: Macro call that should be transformed by ->>", "input": "(->>\n nil\n nil)", "output": "(defmacro ->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ensure-functionf nil (progn))\n\nProblem: Macro call that should be transformed by ENSURE-FUNCTIONF", "input": "(ensure-functionf nil (progn))", "output": "(defmacro ensure-functionf (&rest places)\n \"Multiple-place modify macro for ENSURE-FUNCTION: ensures that each of\nPLACES contains a function.\"\n `(progn ,@(mapcar (lambda (x) `(ensure-functionf/1 ,x)) places)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(assert 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ASSERT", "input": "(assert 'lol-gen::some-name)", "output": "(defmacro ASSERT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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 ~>", "input": "(~> nil nil)", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(v-define-compiler-macro nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by V-DEFINE-COMPILER-MACRO", "input": "(v-define-compiler-macro nil\n :key\n nil)", "output": "(defmacro v-define-compiler-macro (name lambda-list &body body)\n `(define-vari-compiler-macro ,name ,lambda-list ,@body))", "category": "dsl", "technique": "compiler-macro", "complexity": "basic", "quality_score": 0.7875} {"instruction": "Generate a defmacro form that transforms code like this:\n(order-by nil nil)\n\nPattern to recognize: Macro call that should be transformed by ORDER-BY", "input": "(order-by nil nil)", "output": "(defmacro order-by (&rest expressions)\n `(make-clause :order-by ,@(expand-expression expressions)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-html-string\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WITH-HTML-STRING", "input": "(with-html-string\n 'lol-gen::some-name)", "output": "(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)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-properties nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-PROPERTIES", "input": "(with-properties nil\n :key\n nil)", "output": "(defmacro WITH-PROPERTIES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ftype common-lisp:nil\n :key\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by FTYPE", "input": "(ftype common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro FTYPE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(fbindrec* nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by FBINDREC*", "input": "(fbindrec* nil\n nil)", "output": "(defmacro fbindrec* (bindings &body body &environment *lexenv*)\n \"Like `fbindrec`, but the function defined in each binding can be\nused in successive bindings.\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbindrec* `(locally ,@body)))\n (mvlet* ((env env-decls binds lambdas (analyze-fbinds bindings *lexenv*))\n (simple complex lambda unref\n (partition-fbinds (append binds lambdas)\n body))\n (temps (mapcar (op (gensym (string (first _)))) complex))\n (body decls (parse-body body))\n (simple-decls complex-decls lambda-decls others\n (partition-declarations-by-kind simple complex lambda decls)))\n `(let\n ;; Use dummies when we can (with ensure-function).\n ,(loop for (var init) in env\n collect (if (and (listp init)\n (eql (car init) 'ensure-function))\n `(,var #'invalid)\n var))\n ,@(unsplice (and env-decls `(declare ,@env-decls)))\n (comment \"fbind: Simple bindings\")\n (fbind ,simple\n ,@simple-decls\n (comment \"fbind: Temps for complex bindings\")\n (let ,(loop for temp in temps collect `(,temp #'invalid))\n (declare ,@(loop for temp in temps collect `(function ,temp)))\n (flet ,(loop for (name nil) in complex\n for temp in temps\n collect (build-bind/ftype name temp complex-decls env))\n ,@complex-decls\n (comment \"fbind: Lambdas\")\n (labels (,@(loop for (name lambda) in lambda\n collect `(,name ,@(cdr lambda))))\n ,@lambda-decls\n (comment \"fbind: Interleave unreferenced and complex bindings in order.\")\n ,@(remove nil\n (loop for (name nil) in bindings\n append (or (loop for (uname init) in unref\n if (eql uname name)\n return (list init))\n (loop for (cname init) in complex\n for temp in temps\n if (eql cname name)\n return `((setf ,temp (ensure-function ,init)))))))\n (comment \"fbind: Set the `env` variables for the lambdas\")\n (setf ,@(apply #'append env))\n (locally ,@others\n ,@body))))))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond-let nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by COND-LET", "input": "(cond-let nil\n (progn))", "output": "(defmacro cond-let (var &body clauses)\n \"Cross between COND and LET.\n\n (cond-let x ((test ...)))\n \u2261 (let (x)\n (cond ((setf x test) ...)))\n\nCf. `acond' in Anaphora.\"\n (match clauses\n (() nil)\n ((list* (list test) clauses)\n `(if-let1 ,var ,test\n ,var\n (cond-let ,var ,@clauses)))\n ((list* (list* t body) _)\n `(progn ,@body))\n ((list* (list* test body) clauses)\n `(let ((,var ,test))\n (if ,var\n ;; Rebind the variables for declarations.\n (let1 ,var ,var\n ,@body)\n (cond-let ,var ,@clauses))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(multiple-value-bind nil nil)\n\nProblem: Macro call that should be transformed by MULTIPLE-VALUE-BIND", "input": "(multiple-value-bind nil nil)", "output": "(defmacro MULTIPLE-VALUE-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(psetf)\n\nPattern to recognize: Macro call that should be transformed by PSETF", "input": "(psetf)", "output": "(defmacro PSETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-screamer-package nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-SCREAMER-PACKAGE", "input": "(define-screamer-package nil\n (progn))", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(select-dao 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by SELECT-DAO", "input": "(select-dao 'lol-gen::some-name)", "output": "(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))))", "category": "efficiency", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lret* 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by LRET*", "input": "(lret* 'lol-gen::some-name)", "output": "(defmacro lret* ((&rest bindings) &body body)\n \"Cf. `lret'.\"\n `(lret-aux let* ,bindings\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(assert nil (progn))\n\nIssue: Macro call that should be transformed by ASSERT", "input": "(assert nil (progn))", "output": "(defmacro ASSERT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(across nil)\n\nWhat needs to change: Macro call that should be transformed by ACROSS", "input": "(across nil)", "output": "(defmacro ACROSS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(swhen nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by SWHEN", "input": "(swhen nil\n nil)", "output": "(defmacro swhen (test &body body)\n \"Like WHEN, except binds the test form to IT (via SYMBOL-MACROLET) for the\nscope of the body. IT can be set with SETF.\"\n `(symbolic when ,test ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(return 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by RETURN", "input": "(return 'lol-gen::some-name)", "output": "(defmacro RETURN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(continue-whopper)\n\nWrite a macro that addresses: Macro call that should be transformed by CONTINUE-WHOPPER", "input": "(continue-whopper)", "output": "(defmacro CONTINUE-WHOPPER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(prog1 nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by PROG1", "input": "(prog1 nil :key nil)", "output": "(defmacro PROG1 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(-> nil :key nil)\n\nIssue: Macro call that should be transformed by ->", "input": "(-> nil :key nil)", "output": "(defmacro -> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defpackage nil nil)\n\nIssue: Macro call that should be transformed by DEFPACKAGE", "input": "(defpackage nil nil)", "output": "(defmacro DEFPACKAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(ccase 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by CCASE", "input": "(ccase 'lol-gen::some-name)", "output": "(defmacro CCASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(collect-first nil)\n\nProblem: Macro call that should be transformed by COLLECT-FIRST", "input": "(collect-first nil)", "output": "(defmacro COLLECT-FIRST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(walk-environment\n nil\n (progn))\n\nIssue: Macro call that should be transformed by WALK-ENVIRONMENT", "input": "(walk-environment\n nil\n (progn))", "output": "(defmacro WALK-ENVIRONMENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(for-effects\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by FOR-EFFECTS", "input": "(for-effects\n nil\n (progn))", "output": "(defmacro FOR-EFFECTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(finalize-dispatch-method nil (progn))\n\nProblem: Macro call that should be transformed by FINALIZE-DISPATCH-METHOD", "input": "(finalize-dispatch-method nil (progn))", "output": "(defmacro finalize-dispatch-method (generic-function &rest args)\n \"add a body to the method which dispatched the hooks for the given specialized-lambda-list\nuseful if you wanted to use call-next-method\n\nFor the definition to be effective, it must be defined after every specific hook for the same method hence finalize.\n\nSee defhook\"\n (%destructure-defhook-args args\n (with-effective-qualifier generic-function qualifier\n (destructure-specialized-lambda-list descriptive-lambda-list vanilla-lambda-list type-list specialized-lambda-list\n `(%lay-method-base-for-dispatch ,generic-function ,qualifier ,type-list ,descriptive-lambda-list\n ,@body)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(wtrc 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WTRC", "input": "(wtrc 'lol-gen::some-name)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(-> nil)\n\nWhat needs to change: Macro call that should be transformed by ->", "input": "(-> nil)", "output": "(defmacro -> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(collect-nth nil nil)\n\nPattern to recognize: Macro call that should be transformed by COLLECT-NTH", "input": "(collect-nth nil nil)", "output": "(defmacro COLLECT-NTH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c?once\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by C?ONCE", "input": "(c?once\n nil\n :key\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(export\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by EXPORT", "input": "(export\n 'lol-gen::some-name)", "output": "(defmacro EXPORT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defjsmacro nil :key nil)\n\nProblem: Macro call that should be transformed by DEFJSMACRO", "input": "(defjsmacro nil :key nil)", "output": "(defmacro DEFJSMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(check-type nil (progn))\n\nPattern to recognize: Macro call that should be transformed by CHECK-TYPE", "input": "(check-type nil (progn))", "output": "(defmacro CHECK-TYPE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defmethod nil nil)\n\nIssue: Macro call that should be transformed by DEFMETHOD", "input": "(defmethod nil nil)", "output": "(defmacro DEFMETHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-guessing-encoder\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-GUESSING-ENCODER", "input": "(with-guessing-encoder\n 'lol-gen::some-name)", "output": "(defmacro with-guessing-encoder (&body body)\n `(with-local-encoder (use-guessing-encoder)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-read-only-vars 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-READ-ONLY-VARS", "input": "(with-read-only-vars 'lol-gen::some-name)", "output": "(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))))", "category": "anaphoric", "technique": "symbol-macrolet,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8325} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(prepare nil)\n\nWhat needs to change: Macro call that should be transformed by PREPARE", "input": "(prepare nil)", "output": "(defmacro prepare (query &optional (format :rows))\n \"Wraps a query into a function that can be used as the interface to a prepared\nstatement. The given query (either a string or an S-SQL form) may contain\nplaceholders, which look like $1, $2, etc. The resulting function takes one\nargument for every placeholder in the query, executes the prepared query, and\nreturns the result in the format specified. (Allowed formats are the same as for\nquery.)\n\nFor queries that have to be run very often, especially when they are complex,\nit may help performance since the server only has to plan them once. See the\nhttp://www.postgresql.org/docs/current/static/sql-prepare.html\nin the PostgreSQL manual for details.\n\nIn some cases, the server will complain about not being able to deduce the type\nof the arguments in a statement. In that case you should add type\ndeclarations (either with the PostgreSQL's CAST SQL-conforming syntax or\nhistorical :: syntax, or with S-SQL's :type construct) to help it out.\n\nNote that it will attempt to automatically reconnect if database-connection-error,\nor admin-shutdown. It will reset prepared statements triggering an\ninvalid-sql-statement-name error. It will overwrite old prepared statements\ntriggering a duplicate-prepared-statement error.\"\n `(let ((overwrite ,*allow-overwriting-prepared-statements*))\n ,(generate-prepared '(lambda) (next-statement-id) query format)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fail 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by FAIL", "input": "(fail 'lol-gen::some-name)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(sif nil (progn))\n\nIssue: Macro call that should be transformed by SIF", "input": "(sif nil (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(xml 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by XML", "input": "(xml 'lol-gen::some-name)", "output": "(defmacro xml (&rest tags)\n `(with-doctype :xml\n (loop for tag in ',tags\n append (tag->string tag))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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 -<>>", "input": "(-<>> nil nil)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(distinct-on nil)\n\nIssue: Macro call that should be transformed by DISTINCT-ON", "input": "(distinct-on nil)", "output": "(defmacro distinct-on (columns &rest fields)\n `(make-clause :distinct-on (list ,@columns) ,@(mapcar #'expand-op fields)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-simple-documentation-lookup nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-SIMPLE-DOCUMENTATION-LOOKUP", "input": "(define-simple-documentation-lookup nil (progn))", "output": "(defmacro define-simple-documentation-lookup (class documentation-type)\n `(defmethod documentation ((,class ,class))\n ,(if (eql documentation-type T)\n `(cl:documentation (object ,class) 'T)\n `(cl:documentation (designator ,class) ',documentation-type))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(c_in\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by C_IN", "input": "(c_in\n nil\n (progn))", "output": "(defmacro c_in (&body body)\n `(c-input (:lazy :once-asked) (progn ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(all-values\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by ALL-VALUES", "input": "(all-values\n nil\n nil)", "output": "(defmacro ALL-VALUES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(some->> nil (progn))\n\nProblem: Macro call that should be transformed by SOME->>", "input": "(some->> nil (progn))", "output": "(defmacro SOME->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(example)\n\nPattern to recognize: Macro call that should be transformed by EXAMPLE", "input": "(example)", "output": "(defmacro example (&body body)\n \"Like `comment'.\"\n `(comment ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(xor nil)\n\nPattern to recognize: Macro call that should be transformed by XOR", "input": "(xor nil)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(psetf)\n\nProblem: Macro call that should be transformed by PSETF", "input": "(psetf)", "output": "(defmacro PSETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dowhile-it nil\n (progn))\n\nIssue: Macro call that should be transformed by DOWHILE-IT", "input": "(dowhile-it nil\n (progn))", "output": "(defmacro dowhile-it (test &body body)\n \"Like DOWHILE. IT is bound to TEST.\"\n `(do ((it ,test ,test))\n ((not it))\n ,@body))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(shift-incf nil nil)\n\nPattern to recognize: Macro call that should be transformed by SHIFT-INCF", "input": "(shift-incf nil nil)", "output": "(defmacro SHIFT-INCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond-bind nil)\n\nPattern to recognize: Macro call that should be transformed by COND-BIND", "input": "(cond-bind nil)", "output": "(defmacro COND-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(ps-inline 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by PS-INLINE", "input": "(ps-inline 'lol-gen::some-name)", "output": "(defmacro PS-INLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c-lambda\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by C-LAMBDA", "input": "(c-lambda\n 'lol-gen::some-name)", "output": "(defmacro c-lambda (&body body)\n `(c-lambda-var (slot-c) ,@body))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "basic", "quality_score": 0.7925} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(sum-of nil\n (progn))\n\nProblem: Macro call that should be transformed by SUM-OF", "input": "(sum-of nil\n (progn))", "output": "(defmacro SUM-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(static-load-time-value 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by STATIC-LOAD-TIME-VALUE", "input": "(static-load-time-value 'lol-gen::some-name)", "output": "(defmacro static-load-time-value\n (form &optional (read-only-p nil read-only-p-supplied?))\n \"Like `load-time-value', but signals an error if it cannot preserve identity.\n\nOn close reading of the standard, in a function that is evaluated but\nnot compiled, it is permissible for implementations to repeatedly\nexecute a `load-time-value' form, and in fact some implementations do\nthis \\(including, at the time of writing, ABCL, CLISP, Allegro and\nLispWorks).\n\nWhen `static-load-time-value' is compiled, it behaves exactly like\n`load-time-value'. Otherwise it conducts a run-time check to ensure\nthat `load-time-value' preserves identity.\"\n ;; Thanks to Jean-Philippe Paradis and Micha\u0142 Herda for helping to\n ;; diagnose and treat the problem here.\n (if *compile-file-truename*\n `(load-time-value ,form\n ,@(and read-only-p-supplied? (list read-only-p)))\n `(progn\n (flet ((fn () (load-time-value (random most-positive-fixnum))))\n (declare (dynamic-extent #'fn) (ignorable #'fn)\n #+LispWorks (notinline fn))\n ;; Do the actual test out of line.\n (test-load-time-value #'fn ',form ',read-only-p))\n (load-time-value ,form\n ,@(and read-only-p-supplied? (list read-only-p))))))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(alambda nil)\n\nProblem: Macro call that should be transformed by ALAMBDA", "input": "(alambda nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-type-dispatch nil\n nil)\n\nProblem: Macro call that should be transformed by DEFINE-TYPE-DISPATCH", "input": "(define-type-dispatch nil\n nil)", "output": "(defmacro DEFINE-TYPE-DISPATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(dict-of nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DICT-OF", "input": "(dict-of nil (progn))", "output": "(defmacro DICT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(as-object-member 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by AS-OBJECT-MEMBER", "input": "(as-object-member 'lol-gen::some-name)", "output": "(defmacro as-object-member ((key &optional (stream '*json-output*))\n &body body)\n \"BODY should be a program which writes exactly one JSON datum to\nSTREAM. AS-OBJECT-MEMBER ensures that the datum is properly formatted\nas a Member of an Object, i. e. preceded by the (encoded) KEY and\ncolon, and separated by comma from any preceding or following Member.\"\n `(progn\n (next-aggregate-member 'object ,stream)\n (let ((key (encode-json-to-string ,key)))\n (if (char= (aref key 0) #\\\")\n (progn (write-string key ,stream) nil)\n (encode-json key ,stream)))\n (write-char #\\: ,stream)\n ,@body))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-column-writers nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-COLUMN-WRITERS", "input": "(with-column-writers nil\n :key\n nil)", "output": "(defmacro with-column-writers ((&rest defs) &body body)\n \"Provides control over the way get-dao, select-dao, and query-dao read values\nfrom the database. This is not commonly needed, but can be used to reduce the\namount of queries a system makes. writers should be a list of alternating\ncolumn names (strings or symbols) and writers, where writers are either\nsymbols referring to a slot in the objects, or functions taking two arguments \u2015\nan instance and a value \u2015 which can be used to somehow store the value in the\nnew instance. When any DAO-fetching function is called in the body, and\ncolumns matching the given names are encountered in the result, the writers\nare used instead of the default behaviour (try and store the value in the slot\nthat matches the column name).\n\nAn example of using this is to add some non-column slots to a DAO class, and\nuse query-dao within a with-column-writers form to pull in extra information\nabout the objects, and immediately store it in the new instances.\"\n `(let ((*custom-column-writers*\n (append (list ,@(loop :for (field writer) :on defs :by #'cddr\n :collect `(cons (to-sql-name ,field nil) ,writer)))\n *custom-column-writers*)))\n ,@body))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(known? 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by KNOWN?", "input": "(known? 'lol-gen::some-name)", "output": "(defmacro KNOWN? ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(cond-> 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by COND->", "input": "(cond-> 'lol-gen::some-name)", "output": "(defmacro COND-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(receive nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by RECEIVE", "input": "(receive nil\n nil)", "output": "(defmacro receive (formals expr &body body)\n \"Stricter version of `multiple-value-bind'.\n\nUse `receive' when you want to enforce that EXPR should return a\ncertain number of values, or a minimum number of values.\n\nIf FORMALS is a proper list, then EXPR must return exactly as many\nvalues -- no more and no less -- as there are variables in FORMALS.\n\nIf FORMALS is an improper list (VARS . REST), then EXPR must return at\nleast as many values as there are VARS, and any further values are\nbound, as a list, to REST.\n\nLastly, if FORMALS is a symbol, bind that symbol to all the values\nreturned by EXPR, as if by `multiple-value-list'.\n\nFrom Scheme (SRFI-8).\"\n ;; It's probably not worth stack-allocating the thunk.\n (cond ((null formals)\n `(multiple-value-call\n (lambda ()\n ,@body)\n ,expr))\n ((atom formals)\n ;; This could also be written:\n #+(or) `(let ((,formals (multiple-value-list ,expr)))\n ,@body)\n ;; But I want it to be possible to declare FORMALS to have\n ;; dynamic extent, and most Lisps support that for &rest\n ;; lists.\n `(multiple-value-call\n (lambda (&rest ,formals)\n ,@body)\n ,expr))\n ((proper-list-p formals)\n (when (intersection formals lambda-list-keywords)\n (error \"Lambda list keywords in formals: ~a\" formals))\n `(multiple-value-call\n (lambda ,formals\n ,@body)\n ,expr))\n (t (let* ((last (last formals))\n (vars (append (butlast formals)\n (list (car last))))\n (rest (cdr last)))\n (when (intersection (cons rest vars) lambda-list-keywords)\n (error \"Lambda list keywords in formals: ~a\" formals))\n `(multiple-value-call\n (lambda (,@vars &rest ,rest)\n ,@body)\n ,expr)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dict-of 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DICT-OF", "input": "(dict-of 'lol-gen::some-name)", "output": "(defmacro DICT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(pprint-coalton-codegen-ast\n common-lisp:nil\n :key\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-AST", "input": "(pprint-coalton-codegen-ast\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro PPRINT-COALTON-CODEGEN-AST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is-type nil (progn))\n\nProblem: Macro call that should be transformed by IS-TYPE", "input": "(is-type nil (progn))", "output": "(defmacro is-type (got expected-type &optional desc)\n (with-gensyms (duration result)\n (once-only (desc expected-type)\n `(with-catching-errors (:description ,desc :expected ,expected-type)\n (with-duration ((,duration ,result) ,got)\n (test ,result ,expected-type ,desc\n :duration ,duration\n :got-form ',got\n :test-fn #'typep\n :report-expected-label \"be a type of\"))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(documentation common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by DOCUMENTATION", "input": "(documentation common-lisp:nil)", "output": "(defmacro DOCUMENTATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(iter\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by ITER", "input": "(iter\n nil\n :key\n nil)", "output": "(defmacro ITER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(resolving\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by RESOLVING", "input": "(resolving\n nil)", "output": "(defmacro RESOLVING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-layered-class nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-LAYERED-CLASS", "input": "(define-layered-class nil)", "output": "(defmacro DEFINE-LAYERED-CLASS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(and nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AND", "input": "(and nil)", "output": "(defmacro AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defpattern nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPATTERN", "input": "(defpattern nil\n (progn))", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(nix)\n\nWhat needs to change: Macro call that should be transformed by NIX", "input": "(nix)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.815} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond-every\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by COND-EVERY", "input": "(cond-every\n nil\n nil)", "output": "(defmacro cond-every (&body clauses)\n \"Like `cond', but instead of stopping after the first clause that\nsucceeds, run all the clauses that succeed.\n\nReturn the value of the last successful clause.\n\nIf a clause begins with `cl:otherwise', it runs only if no preceding\nform has succeeded.\n\nNote that this does *not* do the same thing as a series of `when'\nforms: `cond-every' evaluates *all* the tests *before* it evaluates\nany of the forms.\n\nFrom Zetalisp.\"\n (let* ((otherwise-clause (find 'otherwise clauses :key #'car))\n (test-clauses (remove otherwise-clause clauses))\n (temps (make-gensym-list (length test-clauses))))\n `(let* ,(loop for temp in temps\n for (test . nil) in test-clauses\n collect `(,temp ,test))\n ;; Work around Iterate bug. See\n ;; .\n (if (or ,@temps)\n ,(with-gensyms (ret)\n `(let (,ret)\n ,@(loop for temp in temps\n for (nil . body) in test-clauses\n collect `(when ,temp\n (setf ,ret\n ,(if (null body)\n temp\n `(progn ,@body)))))\n ,ret))\n (progn ,@(rest otherwise-clause))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(|^K1|)\n\nIssue: Macro call that should be transformed by ^K1", "input": "(|^K1|)", "output": "(defmacro ^k1 () `(kid1 self))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-alist nil (progn))\n\nWhat needs to change: Macro call that should be transformed by COLLECT-ALIST", "input": "(collect-alist nil (progn))", "output": "(defmacro COLLECT-ALIST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(reduced-typecase nil (progn))\n\nIssue: Macro call that should be transformed by REDUCED-TYPECASE", "input": "(reduced-typecase nil (progn))", "output": "(defmacro REDUCED-TYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c_1\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by C_1", "input": "(c_1\n 'lol-gen::some-name)", "output": "(defmacro c_1 (&body body)\n `(make-c-dependent\n :code '(without-c-dependency ,@body)\n :inputp nil\n :lazy t\n :value-state :unevaluated\n :rule (c-lambda (without-c-dependency ,@body))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(etypecase nil (progn))\n\nIssue: Macro call that should be transformed by ETYPECASE", "input": "(etypecase nil (progn))", "output": "(defmacro ETYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(all-values\n nil)\n\nPattern to recognize: Macro call that should be transformed by ALL-VALUES", "input": "(all-values\n nil)", "output": "(defmacro ALL-VALUES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-implicit-conversion 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-IMPLICIT-CONVERSION", "input": "(with-implicit-conversion 'lol-gen::some-name)", "output": "(defmacro WITH-IMPLICIT-CONVERSION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(incf-pointer nil (progn))\n\nWhat needs to change: Macro call that should be transformed by INCF-POINTER", "input": "(incf-pointer nil (progn))", "output": "(defmacro INCF-POINTER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond-> nil)\n\nPattern to recognize: Macro call that should be transformed by COND->", "input": "(cond-> nil)", "output": "(defmacro cond-> (init &body exps) (cond-arrow-macro init exps))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(def-fixture nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEF-FIXTURE", "input": "(def-fixture nil\n :key\n nil)", "output": "(defmacro def-fixture (name (&rest args) &body body)\n \"Defines a fixture named NAME. A fixture is very much like a\nmacro but is used only for simple templating. A fixture created\nwith DEF-FIXTURE is a macro which can use the special macrolet\n&BODY to specify where the body should go.\n\nSee Also: WITH-FIXTURE\n\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (get-fixture ',name) (cons ',args ',body))\n ',name))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-screamer-package nil)\n\nIssue: Macro call that should be transformed by DEFINE-SCREAMER-PACKAGE", "input": "(define-screamer-package nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-dot nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-DOT", "input": "(with-dot nil\n :key\n nil)", "output": "(defmacro with-dot (() &body body)\n `(progn ,@(replace-dot-calls body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(query-dao nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by QUERY-DAO", "input": "(query-dao nil (progn))", "output": "(defmacro query-dao (type query &rest args)\n \"Execute the given query (which can be either a string or an S-SQL expression)\nand return the result as DAOs of the given type. If the query contains\nplaceholders ($1, $2, etc) their values can be given as extra arguments. The\nnames of the fields returned by the query must either match slots in the DAO\nclass, or be bound through with-column-writers.\"\n `(query-dao% ,type ,(real-query query) (dao-row-reader (find-class ,type)) ,@args))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ignore-some-conditions nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by IGNORE-SOME-CONDITIONS", "input": "(ignore-some-conditions nil\n (progn))", "output": "(defmacro ignore-some-conditions ((&rest conditions) &body body)\n \"Similar to CL:IGNORE-ERRORS but the (unevaluated) CONDITIONS\nlist determines which specific conditions are to be ignored.\"\n `(handler-case\n (progn ,@body)\n ,@(loop for condition in conditions collect\n `(,condition (c) (values nil c)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ensure-gethash nil :key nil)\n\nProblem: Macro call that should be transformed by ENSURE-GETHASH", "input": "(ensure-gethash nil :key nil)", "output": "(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))))))", "category": "anaphoric", "technique": "once-only,anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(n^ nil)\n\nIssue: Macro call that should be transformed by N^", "input": "(n^ nil)", "output": "(defmacro n^ (type)\n `(nearest self ,type))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-array nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-ARRAY", "input": "(with-array nil\n :key\n nil)", "output": "(defmacro with-array ((&optional (stream '*json-output*)) &body body)\n \"Open a JSON Array, run BODY, then close the Array. Inside the BODY,\nAS-ARRAY-MEMBER or ENCODE-ARRAY-MEMBER should be called to encode\nMembers of the Array.\"\n `(with-aggregate (array #\\[ #\\] ,stream) ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make-window-or-instance nil nil)\n\nWhat needs to change: Macro call that should be transformed by MAKE-WINDOW-OR-INSTANCE", "input": "(make-window-or-instance nil nil)", "output": "(defmacro MAKE-WINDOW-OR-INSTANCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(accase nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by ACCASE", "input": "(accase nil\n (progn))", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fm! 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by FM!", "input": "(fm! 'lol-gen::some-name)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-truncated-stack nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-TRUNCATED-STACK", "input": "(with-truncated-stack nil)", "output": "(defmacro with-truncated-stack (() &body body)\n `(stack-truncator (lambda () ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(advisable-lambda nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ADVISABLE-LAMBDA", "input": "(advisable-lambda nil)", "output": "(defmacro ADVISABLE-LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(select nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by SELECT", "input": "(select nil\n nil)", "output": "(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))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(mvlet nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MVLET", "input": "(mvlet nil)", "output": "(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))))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8274999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-inactive-layers nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-INACTIVE-LAYERS", "input": "(with-inactive-layers nil\n nil)", "output": "(defmacro WITH-INACTIVE-LAYERS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cond-it\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COND-IT", "input": "(cond-it\n 'lol-gen::some-name)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(stypecase nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by STYPECASE", "input": "(stypecase nil\n :key\n nil)", "output": "(defmacro stypecase (keyform &body cases)\n \"Like TYPECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for the\nscope of the cases. IT can be set with SETF.\"\n `(symbolic typecase ,keyform ,@cases))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(dccase nil)\n\nPattern to recognize: Macro call that should be transformed by DCCASE", "input": "(dccase nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(bgo 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by BGO", "input": "(bgo 'lol-gen::some-name)", "output": "(defmacro bgo (msg)\n `(break \"BGO ~a\" ',msg))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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*", "input": "(lambda* nil\n nil)", "output": "(defmacro LAMBDA* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(doseq 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DOSEQ", "input": "(doseq 'lol-gen::some-name)", "output": "(defmacro doseq (name/seq &body body)\n \"Iterate over the elements of a single sequence SEQUENCE.\n\n Same as DO-SEQUENCES but 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 (ELEMENT SEQUENCE &REST ARGS) &BODY BODY)\n\n 2. ((ELEMENT SEQUENCE &REST ARGS) &BODY BODY)\n\n NAME is the block name, NIL if not given.\n\n ELEMENT is the variable to which each element of the sequence is\n bound.\n\n SEQUENCE is the sequence, with ARGS being the remaining arguments\n passed to the ITERATOR function.\n\n BODY is the list of forms evaluated on each iteration.\"\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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fn* 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by FN*", "input": "(fn* 'lol-gen::some-name)", "output": "(defmacro fn* (form &environment env)\n (fn*-internals form env))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Generate a defmacro form that transforms code like this:\n(->>)\n\nPattern to recognize: Macro call that should be transformed by ->>", "input": "(->>)", "output": "(defmacro ->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "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", "input": "(removef nil (progn))", "output": "(defmacro REMOVEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fbind nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by FBIND", "input": "(fbind nil\n (progn))", "output": "(defmacro fbind (bindings &body body &environment *lexenv*)\n \"Binds values in the function namespace.\n\nThat is,\n (fbind ((fn (lambda () ...))))\n \u2261 (flet ((fn () ...))),\n\nexcept that a bare symbol in BINDINGS is rewritten as (symbol\nsymbol).\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbind `(locally ,@body)))\n ;; When possible (if the binding expands to a simple\n ;; let-over-lambda), we hoist the bindings to the top and bind\n ;; the lambda directly with flet.\n\n ;; Failing that, if we know that the function is never directly\n ;; dereferenced with sharp-quote, we can bind with `macrolet'\n ;; instead of `flet', leaving no runtime overhead vs. `funcall'.\n (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))\n (macro-vars\n (merely-syntactic-functions (mapcar #'first bindings)\n body\n *lexenv*))\n (vars (mapcar #'first bindings))\n (exprs (mapcar #'second bindings))\n (temps (mapcar #'string-gensym vars))\n (body decls (parse-body body)))\n `(let ,env\n ,@(unsplice (and env-decls `(declare ,@env-decls)))\n (comment \"fbind: Hidden variable bindings to close over.\")\n (let ,(loop for temp in temps\n for expr in exprs\n collect `(,temp (ensure-function ,expr)))\n ,@(when temps\n (unsplice\n `(declare (function ,@temps))))\n (comment \"fbind: Hidden variable bindings for function values.\")\n (flet (,@(loop for (name lambda) in lambdas\n collect `(,name ,@(cdr lambda)))\n ,@(loop for var in vars\n for temp in temps\n unless (member var macro-vars)\n collect (build-bind/ftype var temp decls env)))\n #-sbcl (declare (inline ,@(set-difference vars macro-vars)))\n ,@decls\n (comment \"fbind: Functions that might be sharp-quoted.\")\n (macrolet (,@(loop for var in vars\n for temp in temps\n when (member var macro-vars)\n collect `(,var\n (&rest args)\n (list* 'funcall ',temp args))))\n (comment \"fbind: Macros for functions provably never sharp-quoted.\")\n ,@body))))))", "category": "control-flow", "technique": "macrolet,gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(named-lambda nil\n (progn))\n\nIssue: Macro call that should be transformed by NAMED-LAMBDA", "input": "(named-lambda nil\n (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(call-method nil)\n\nPattern to recognize: Macro call that should be transformed by CALL-METHOD", "input": "(call-method nil)", "output": "(defmacro CALL-METHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(drop-table 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DROP-TABLE", "input": "(drop-table 'lol-gen::some-name)", "output": "(defmacro drop-table (table &key if-exists)\n `(make-statement :drop-table\n ,(expand-expression table) :if-exists ,if-exists))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(unwind-protect nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by UNWIND-PROTECT", "input": "(unwind-protect nil\n :key\n nil)", "output": "(defmacro UNWIND-PROTECT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(nunionf nil (progn))\n\nWhat needs to change: Macro call that should be transformed by NUNIONF", "input": "(nunionf nil (progn))", "output": "(defmacro NUNIONF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-values nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-VALUES", "input": "(define-values nil\n nil)", "output": "(defmacro define-values (values &body (expr))\n \"Like `def', but for multiple values.\nEach variable in VALUES is given a global, lexical binding, as with\n`def', then set all at once, as with `multiple-value-setq'.\"\n `(progn\n ,@(loop for v in values collect `(def ,v nil))\n (setf (values ,@values) ,expr)\n (values ,@(loop for v in values collect `(quote ,v)))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(boolean-unless nil)\n\nProblem: Macro call that should be transformed by BOOLEAN-UNLESS", "input": "(boolean-unless nil)", "output": "(defmacro boolean-unless (branch &body body &environment env)\n \"Includes some forms based on whether a macroexpand-time branch is false. The\nfirst argument must be a symbol naming a branch in the lexically enclosing\nWITH-BOOLEAN form.\n\\\nIt is an error to use this macro outside the lexical environment established by\nWITH-BOOLEAN.\"\n (cond (*boolean-bypass*\n `(unless ,branch ,@body))\n ((not (member branch (macroexpand-1 '%all-branches% env)))\n (missing-branch branch))\n ((not (macroexpand-1 '%in-branching% env))\n (conditional-error 'unless))\n ((member branch (macroexpand-1 '%true-branches% env))\n `(progn))\n ((= 0 (length body))\n `(progn))\n ((= 1 (length body))\n (car body))\n (t `(progn ,@body))))", "category": "anaphoric", "technique": "nested-backquote,anaphor", "complexity": "advanced", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(destructuring-match nil)\n\nWhat needs to change: Macro call that should be transformed by DESTRUCTURING-MATCH", "input": "(destructuring-match nil)", "output": "(defmacro DESTRUCTURING-MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defmethod nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFMETHOD", "input": "(defmethod nil\n :key\n nil)", "output": "(defmacro DEFMETHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(aprog1 nil)\n\nIssue: Macro call that should be transformed by APROG1", "input": "(aprog1 nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ctypecase nil)\n\nProblem: Macro call that should be transformed by CTYPECASE", "input": "(ctypecase nil)", "output": "(defmacro CTYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(v-defstruct nil\n (progn))\n\nIssue: Macro call that should be transformed by V-DEFSTRUCT", "input": "(v-defstruct nil\n (progn))", "output": "(defmacro v-defstruct (name context &body slots)\n `(define-vari-struct ,name ,context ,@slots))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(initially nil (progn))\n\nWhat needs to change: Macro call that should be transformed by INITIALLY", "input": "(initially nil (progn))", "output": "(defmacro INITIALLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(nodelist 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by NODELIST", "input": "(nodelist 'lol-gen::some-name)", "output": "(defmacro NODELIST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(f-find nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by F-FIND", "input": "(f-find nil :key nil)", "output": "(defmacro f-find (synapse-id sought where)\n `(call-f-find ,synapse-id ,sought ,where))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-integrity nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-INTEGRITY", "input": "(with-integrity nil nil)", "output": "(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)))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fail-compile 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by FAIL-COMPILE", "input": "(fail-compile 'lol-gen::some-name)", "output": "(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))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(skip nil\n nil)\n\nProblem: Macro call that should be transformed by SKIP", "input": "(skip nil\n nil)", "output": "(defmacro skip (desc &body tests)\n `(with-forced-status (:skipped ,@(if (listp desc) desc (list desc)))\n ,@tests))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c?n-until nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by C?N-UNTIL", "input": "(c?n-until nil\n (progn))", "output": "(defmacro c?n-until (args &body body)\n `(make-c-dependent\n :optimize :when-value-t\n :code ',body\n :inputp t\n :value-state :unevaluated\n :rule (c-lambda ,@body)\n ,@args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(->* nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by ->*", "input": "(->* nil :key nil)", "output": "(defmacro ->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(producing)\n\nProblem: Macro call that should be transformed by PRODUCING", "input": "(producing)", "output": "(defmacro PRODUCING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-processor)\n\nIssue: Macro call that should be transformed by DEFINE-PROCESSOR", "input": "(define-processor)", "output": "(defmacro define-processor (&key name file-reader string-reader extra-traverser)\n (let ((extras (loop for i in extra-traverser collect\n\t\t\t `(traverser (make-instance ',i) tree 0))))\n `(defun ,name (args)\n (multiple-value-bind (input output debug) (parse-cmdline args ,string-reader)\n\t (when input\n\t (let ((tree nil)\n\t\t (pprint (make-instance 'pretty-printer)))\n\t (setf tree (,file-reader input))\n\t ,@extras\n\t (if output\n\t\t (with-open-file\n\t\t (stream output :direction :output\n\t\t\t\t :if-exists :supersede\n\t\t\t\t :if-does-not-exist :create)\n\t\t (setf (slot-value pprint 'stream) stream)\n\t\t (traverser pprint tree 0))\n\t\t (progn\n\t\t (setf (slot-value pprint 'stream) *standard-output*)\n\t\t (traverser pprint tree 0)\n\t\t (format t \"~&\")))\n\t ))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-contracts-enabled nil)\n\nProblem: Macro call that should be transformed by WITH-CONTRACTS-ENABLED", "input": "(with-contracts-enabled nil)", "output": "(defmacro with-contracts-enabled\n ((&rest args &key invariants preconditions postconditions) &body body)\n \"Enables/disables contracts for the extent of this form, restoring them to\n their prior values upon exit.\"\n (declare (ignore invariants preconditions postconditions))\n (let ((enabled-contracts (gensym \"ENABLED-CONTRACTS-\")))\n `(let ((,enabled-contracts (enabled-contracts)))\n (unwind-protect\n (progn (enable-contracts ,@args)\n ,@body)\n (apply #'enable-contracts ,enabled-contracts)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(on-duplicate-key-update nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ON-DUPLICATE-KEY-UPDATE", "input": "(on-duplicate-key-update nil :key nil)", "output": "(defmacro on-duplicate-key-update (&rest args)\n `(make-clause :on-duplicate-key-update ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collecting-into-and-returning 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COLLECTING-INTO-AND-RETURNING", "input": "(collecting-into-and-returning 'lol-gen::some-name)", "output": "(defmacro COLLECTING-INTO-AND-RETURNING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(let-match1 common-lisp:nil\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LET-MATCH1", "input": "(let-match1 common-lisp:nil\n common-lisp:nil)", "output": "(defmacro let-match1 (pattern arg &body body)\n \"Equivalent to (let-match ((PATTERN ARG)) BODY...).\"\n `(let-match ((,pattern ,arg)) ,.body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-alias nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-ALIAS", "input": "(define-alias nil\n (progn))", "output": "(defmacro DEFINE-ALIAS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defpattern nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFPATTERN", "input": "(defpattern nil\n :key\n nil)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make-kid nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-KID", "input": "(make-kid nil nil)", "output": "(defmacro make-kid (class &rest ia)\n (with-gensyms (c)\n `(let ((,c ,class))\n (make-instance ,c\n ,@ia\n :fm-parent (progn (assert self () \"make-kid: self nil making ~a\" ,c)\n self)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cmatch* common-lisp:nil\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by CMATCH*", "input": "(cmatch* common-lisp:nil\n common-lisp:nil)", "output": "(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))))))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(gathering nil\n (progn))\n\nProblem: Macro call that should be transformed by GATHERING", "input": "(gathering nil\n (progn))", "output": "(defmacro GATHERING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(psetq nil nil)\n\nProblem: Macro call that should be transformed by PSETQ", "input": "(psetq nil nil)", "output": "(defmacro PSETQ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(mvlet* nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by MVLET*", "input": "(mvlet* nil\n nil)", "output": "(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))))))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(aprog1 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by APROG1", "input": "(aprog1 'lol-gen::some-name)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(|GETSET#| nil :key nil)\n\nIssue: Macro call that should be transformed by GETSET#", "input": "(|GETSET#| nil :key nil)", "output": "(defmacro GETSET# ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(collect-and nil)\n\nPattern to recognize: Macro call that should be transformed by COLLECT-AND", "input": "(collect-and nil)", "output": "(defmacro COLLECT-AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(lret nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by LRET", "input": "(lret nil\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(shiftf nil (progn))\n\nPattern to recognize: Macro call that should be transformed by SHIFTF", "input": "(shiftf nil (progn))", "output": "(defmacro SHIFTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(export-structure\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by EXPORT-STRUCTURE", "input": "(export-structure\n 'lol-gen::some-name)", "output": "(defmacro EXPORT-STRUCTURE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(collect nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECT", "input": "(collect nil (progn))", "output": "(defmacro COLLECT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fail)\n\nProblem: Macro call that should be transformed by FAIL", "input": "(fail)", "output": "(defmacro fail (&rest message-args)\n \"Simply generate a FAIL.\"\n `(process-failure ',message-args\n ,@message-args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c-envalue\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by C-ENVALUE", "input": "(c-envalue\n 'lol-gen::some-name)", "output": "(defmacro c-envalue (&body body)\n `(make-c-envaluer\n :envalue-rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(distinct-on 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DISTINCT-ON", "input": "(distinct-on 'lol-gen::some-name)", "output": "(defmacro distinct-on (columns &rest fields)\n `(make-clause :distinct-on (list ,@columns) ,@(mapcar #'expand-op fields)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(example\n nil)\n\nProblem: Macro call that should be transformed by EXAMPLE", "input": "(example\n nil)", "output": "(defmacro example (&body body)\n \"Like `comment'.\"\n `(comment ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dccase 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DCCASE", "input": "(dccase 'lol-gen::some-name)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(v-defun nil\n (progn))\n\nProblem: Macro call that should be transformed by V-DEFUN", "input": "(v-defun nil\n (progn))", "output": "(defmacro v-defun (name args &body body)\n `(define-vari-function ,name ,args ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(def-test nil\n nil)\n\nIssue: Macro call that should be transformed by DEF-TEST", "input": "(def-test nil\n nil)", "output": "(defmacro def-test (name (&key depends-on (suite '*suite* suite-p) fixture\n (compile-at *default-test-compilation-time*) profile)\n &body body)\n \"Create a test named NAME.\n\nNAME is the symbol which names the test.\n\nDEPENDS-ON is a list of the form:\n\n (AND . test-names) - This test is run only if all of the tests\n in TEST-NAMES have passed, otherwise a single test-skipped\n result is generated.\n\n (OR . test-names) - If any of TEST-NAMES has passed this test is\n run, otherwise a test-skipped result is generated.\n\n (NOT test-name) - This is test is run only if TEST-NAME failed.\n\nAND, OR and NOT can be combined to produce complex dependencies.\n\nIf DEPENDS-ON is a symbol it is interpreted as `(AND\n,depends-on), this is accomadate the common case of one test\ndepending on another.\n\nFIXTURE specifies a fixture to wrap the body in.\n\nIf PROFILE is T profiling information will be collected as well.\"\n (check-type compile-at (member :run-time :definition-time))\n (multiple-value-bind (forms decls docstring)\n (parse-body body :documentation t :whole name)\n (let* ((description (or docstring \"\"))\n (body-forms (append decls forms))\n (suite-form (if suite-p\n `(get-test ',suite)\n (or suite '*suite*)))\n (effective-body (if fixture\n (destructuring-bind (name &rest args)\n (ensure-list fixture)\n `((with-fixture ,name ,args ,@body-forms)))\n body-forms)))\n `(progn\n (register-test ',name ,description ',effective-body ,suite-form ',depends-on ,compile-at ,profile)\n (when *run-test-when-defined*\n (run! ',name))\n ',name))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(acond\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by ACOND", "input": "(acond\n nil\n nil)", "output": "(defmacro ACOND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(nsplice-seqf nil (progn))\n\nPattern to recognize: Macro call that should be transformed by NSPLICE-SEQF", "input": "(nsplice-seqf nil (progn))", "output": "(defmacro NSPLICE-SEQF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(callf2 nil :key nil)\n\nIssue: Macro call that should be transformed by CALLF2", "input": "(callf2 nil :key nil)", "output": "(defmacro callf2 (function arg1 place &rest args)\n \"Like CALLF, but with the place as the second argument.\"\n `(callf (curry ,function ,arg1) ,place ,@args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(send nil)\n\nProblem: Macro call that should be transformed by SEND", "input": "(send nil)", "output": "(defmacro SEND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(modf-eval)\n\nWhat needs to change: Macro call that should be transformed by MODF-EVAL", "input": "(modf-eval)", "output": "(defmacro modf-eval (&rest args)\n `(progn ,@args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(shift-decf 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by SHIFT-DECF", "input": "(shift-decf 'lol-gen::some-name)", "output": "(defmacro SHIFT-DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(collect-nth nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by COLLECT-NTH", "input": "(collect-nth nil :key nil)", "output": "(defmacro COLLECT-NTH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fm-collect nil)\n\nIssue: Macro call that should be transformed by FM-COLLECT", "input": "(fm-collect nil)", "output": "(defmacro fm-collect (md-name &key (must-find t))\n `(fm-find-all self ',md-name :must-find ,must-find))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cmatch common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by CMATCH", "input": "(cmatch common-lisp:nil\n :key\n common-lisp:nil)", "output": "(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))))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(or nil :key nil)\n\nIssue: Macro call that should be transformed by OR", "input": "(or nil :key nil)", "output": "(defmacro OR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(and-let* nil\n (progn))\n\nProblem: Macro call that should be transformed by AND-LET*", "input": "(and-let* nil\n (progn))", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(eval-always)\n\nWrite a macro that addresses: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always)", "output": "(defmacro EVAL-ALWAYS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(when-it 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WHEN-IT", "input": "(when-it 'lol-gen::some-name)", "output": "(defmacro when-it (test &body body)\n \"Like WHEN. IT is bound to TEST.\"\n `(let ((it ,test))\n (when it\n ,@body)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(the-kids nil nil)\n\nProblem: Macro call that should be transformed by THE-KIDS", "input": "(the-kids nil nil)", "output": "(defmacro the-kids (&rest kids)\n `(let ((*parent* self))\n (packed-flat! ,@kids)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(gen-lambda nil\n (progn))\n\nProblem: Macro call that should be transformed by GEN-LAMBDA", "input": "(gen-lambda nil\n (progn))", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(defmacro-clause 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DEFMACRO-CLAUSE", "input": "(defmacro-clause 'lol-gen::some-name)", "output": "(defmacro defmacro-clause (clause-template &body body)\n \"Create your own iterate clauses\"\n (define-clause 'defmacro clause-template body nil))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ith-value nil nil)\n\nIssue: Macro call that should be transformed by ITH-VALUE", "input": "(ith-value nil nil)", "output": "(defmacro ITH-VALUE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(multiple-value-ematch nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by MULTIPLE-VALUE-EMATCH", "input": "(multiple-value-ematch nil\n nil)", "output": "(defmacro multiple-value-ematch (values-form &body clauses)\n \"Same as MULTIPLE-VALUE-MATCH, except MATCH-ERROR will be raised if\nnot matched.\"\n (let* ((values (gensym \"VALUES\"))\n (else `(error '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))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-definition-resolver nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-DEFINITION-RESOLVER", "input": "(define-definition-resolver nil\n nil)", "output": "(defmacro define-definition-resolver (name args &body body)\n `(progn (setf (definition-resolver ',name)\n (lambda ,args ,@body))\n ',name))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda-ematch1 common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by LAMBDA-EMATCH1", "input": "(lambda-ematch1 common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro lambda-ematch1 (pattern &body body)\n \"Equivalent to (lambda (arg) (ematch arg (PATTERN BODY...))).\"\n `(lambda-ematch (,pattern ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(flet* nil)\n\nPattern to recognize: Macro call that should be transformed by FLET*", "input": "(flet* nil)", "output": "(defmacro FLET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fm-otherv? nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FM-OTHERV?", "input": "(fm-otherv? nil)", "output": "(defmacro fm-otherv? (md-name &optional (starting 'self) (global-search t))\n `(fm-other-v ,md-name ,starting ,global-search))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lret* nil)\n\nProblem: Macro call that should be transformed by LRET*", "input": "(lret* nil)", "output": "(defmacro lret* ((&rest bindings) &body body)\n \"Cf. `lret'.\"\n `(lret-aux let* ,bindings\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defun-match* common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by DEFUN-MATCH*", "input": "(defun-match* common-lisp:nil\n (common-lisp:progn))", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(gen-lambda-with-sticky-stop nil (progn))\n\nIssue: Macro call that should be transformed by GEN-LAMBDA-WITH-STICKY-STOP", "input": "(gen-lambda-with-sticky-stop nil (progn))", "output": "(defmacro gen-lambda-with-sticky-stop (&rest rest)\n `(make-instance \n 'basic-generator \n :function (sticky-stop-lambda ,@rest)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(special-symbol-reprogv nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by SPECIAL-SYMBOL-REPROGV", "input": "(special-symbol-reprogv nil\n :key\n nil)", "output": "(defmacro SPECIAL-SYMBOL-REPROGV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(multiple-value-prog2 nil\n (progn))\n\nIssue: Macro call that should be transformed by MULTIPLE-VALUE-PROG2", "input": "(multiple-value-prog2 nil\n (progn))", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fsetf nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FSETF", "input": "(fsetf nil nil)", "output": "(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)))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-ps-symbol-macro nil nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-PS-SYMBOL-MACRO", "input": "(define-ps-symbol-macro nil nil)", "output": "(defmacro DEFINE-PS-SYMBOL-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(destructuring-case nil\n (progn))\n\nProblem: Macro call that should be transformed by DESTRUCTURING-CASE", "input": "(destructuring-case nil\n (progn))", "output": "(defmacro DESTRUCTURING-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(xhtml)\n\nWhat needs to change: Macro call that should be transformed by XHTML", "input": "(xhtml)", "output": "(defmacro xhtml (&rest tags)\n `(with-doctype :xhtml\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda* 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA*", "input": "(lambda* 'lol-gen::some-name)", "output": "(defmacro LAMBDA* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(is-expand nil :key nil)\n\nIssue: Macro call that should be transformed by IS-EXPAND", "input": "(is-expand nil :key nil)", "output": "(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))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(labels* nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by LABELS*", "input": "(labels* nil\n :key\n nil)", "output": "(defmacro LABELS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c_?dbg\n nil)\n\nProblem: Macro call that should be transformed by C_?DBG", "input": "(c_?dbg\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(unless-match common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by UNLESS-MATCH", "input": "(unless-match common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro unless-match (pattern arg &body body)\n \"Equivalent to (match ARG (PATTERN) (_ BODY...)).\"\n `(match ,arg\n (,pattern)\n (_ ,.body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(if-not-let nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IF-NOT-LET", "input": "(if-not-let nil\n nil)", "output": "(defmacro if-not-let (bindings &body (then-form &optional else-form))\n \"Creates new variable bindings, and conditionally executes either\nTHEN-FORM or ELSE-FORM. ELSE-FORM defaults to NIL.\nBINDINGS must be either single binding of the form:\n (variable initial-form)\nor a list of bindings of the form:\n ((variable-1 initial-form-1)\n (variable-2 initial-form-2)\n ...\n (variable-n initial-form-n))\nAll initial-forms are executed sequentially in the specified order. Then all\nthe variables are bound to the corresponding values.\nIf one of the variables was bound to NIL, the THEN-FORM is executed with the\nbindings in effect, otherwise the ELSE-FORM is executed with the bindings in\neffect.\nAdapted from Alexandria if-let.\"\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 (if-not (and ,@variables)\n\t ,then-form\n\t ,else-form))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(some->> 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by SOME->>", "input": "(some->> 'lol-gen::some-name)", "output": "(defmacro SOME->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda-bind nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by LAMBDA-BIND", "input": "(lambda-bind nil\n :key\n nil)", "output": "(defmacro lambda-bind ((&rest instrs) &body body)\n \"Use `bind' to allow restructuring of argument to lambda expressions.\n\nThis lets you funcall and destructure simultaneously. For example\n\n (let ((fn (lambda-bind ((a b) c) (cons a c))))\n (funcall fn '(1 2) 3))\n ;; => (1 . 3)\n\nVia eschulte (see git://gist.github.com/902174.git).\n\"\n #+(or)\n (declare (indent 1))\n (let* ((evald-instrs instrs)\n (syms (mapcar (lambda (_)\n\t\t\t (declare (ignore _))\n\t\t\t (gensym))\n\t\t evald-instrs)))\n `(lambda ,syms (bind ,(mapcar #'list evald-instrs syms) ,@body))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defpsmacro nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFPSMACRO", "input": "(defpsmacro nil\n (progn))", "output": "(defmacro DEFPSMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(->> nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ->>", "input": "(->> nil\n nil)", "output": "(defmacro ->> (init &body exps) (arrow-macro init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fm^v nil)\n\nProblem: Macro call that should be transformed by FM^V", "input": "(fm^v nil)", "output": "(defmacro fm^v (id)\n `(value (fm^ ,id)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fail nil nil)\n\nProblem: Macro call that should be transformed by FAIL", "input": "(fail nil nil)", "output": "(defmacro fail (&rest message-args)\n \"Simply generate a FAIL.\"\n `(process-failure ',message-args\n ,@message-args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda-cmatch1 common-lisp:nil\n :key\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by LAMBDA-CMATCH1", "input": "(lambda-cmatch1 common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro lambda-cmatch1 (pattern &body body)\n \"Equivalent to (lambda (arg) (cmatch arg (PATTERN BODY...))).\"\n `(lambda-cmatch (,pattern ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(match-of nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by MATCH-OF", "input": "(match-of nil\n :key\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(rem-bops nil nil)\n\nProblem: Macro call that should be transformed by REM-BOPS", "input": "(rem-bops nil nil)", "output": "(defmacro REM-BOPS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defvar* nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFVAR*", "input": "(defvar* nil (progn))", "output": "(defmacro DEFVAR* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(markup nil nil)\n\nWhat needs to change: Macro call that should be transformed by MARKUP", "input": "(markup nil nil)", "output": "(defmacro markup (&rest tags)\n `(%write-strings\n ,@(loop for tag in tags\n append (tag->string tag))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(foreign-funcall-pointer-varargs nil :key nil)\n\nIssue: Macro call that should be transformed by FOREIGN-FUNCALL-POINTER-VARARGS", "input": "(foreign-funcall-pointer-varargs nil :key nil)", "output": "(defmacro foreign-funcall-pointer-varargs (pointer options fixed-args\n &rest varargs)\n \"Wrapper around %FOREIGN-FUNCALL-POINTER that translates its\narguments and does type promotion for the variadic arguments.\"\n (foreign-funcall-varargs-form pointer options fixed-args varargs t))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "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", "input": "(special-symbol-progv nil\n nil)", "output": "(defmacro SPECIAL-SYMBOL-PROGV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(as 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by AS", "input": "(as 'lol-gen::some-name)", "output": "(defmacro as (type cl:&optional (expr cl:nil expr-supplied-p))\n \"A syntactic convenience for type casting.\n\n (as )\n\nis equivalent to\n\n (the (into ))\n\nand\n\n (as )\n\nis equivalent to\n\n (fn (expr) (the (into expr))).\n\nNote that this may copy the object or allocate memory.\"\n\n (cl:let ((into (cl:ignore-errors (cl:find-symbol \"INTO\" \"COALTON/CLASSES\"))))\n (cl:assert into () \"`as` macro does not have access to `into` yet.\")\n (cl:if expr-supplied-p\n `(the ,type (,into ,expr))\n (alexandria:with-gensyms (lexpr)\n `(fn (,lexpr)\n (the ,type (,into ,lexpr)))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(right nil nil)\n\nProblem: Macro call that should be transformed by RIGHT", "input": "(right nil nil)", "output": "(defmacro right (parser &rest parsers)\n \"Combination of parsers yielding the result of the rightmost one.\"\n `(*> ,parser ,@parsers))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(html5 nil (progn))\n\nPattern to recognize: Macro call that should be transformed by HTML5", "input": "(html5 nil (progn))", "output": "(defmacro html5 (&rest tags)\n `(with-doctype :html5\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make nil)\n\nWhat needs to change: Macro call that should be transformed by MAKE", "input": "(make nil)", "output": "(defmacro MAKE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-html\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-HTML", "input": "(with-html\n nil\n nil)", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(make-list)\n\nProblem: Macro call that should be transformed by MAKE-LIST", "input": "(make-list)", "output": "(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)))", "category": "control-flow", "technique": "nested-backquote", "complexity": "advanced", "quality_score": 0.815} {"instruction": "Generate a defmacro form that transforms code like this:\n(defpackage common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by DEFPACKAGE", "input": "(defpackage common-lisp:nil)", "output": "(defmacro DEFPACKAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(sunless nil\n (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-method-combination nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-METHOD-COMBINATION", "input": "(define-method-combination nil (progn))", "output": "(defmacro DEFINE-METHOD-COMBINATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(ensure-list nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by ENSURE-LIST", "input": "(ensure-list nil\n (progn))", "output": "(defmacro ensure-list (item &body body)\n `(let ((,item (if (listp ,item) ,item '(,item))))\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(initially 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by INITIALLY", "input": "(initially 'lol-gen::some-name)", "output": "(defmacro INITIALLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(make* nil)\n\nProblem: Macro call that should be transformed by MAKE*", "input": "(make* nil)", "output": "(defmacro MAKE* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(local*\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by LOCAL*", "input": "(local*\n nil\n (progn))", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(eval-and-compile\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by EVAL-AND-COMPILE", "input": "(eval-and-compile\n nil\n :key\n nil)", "output": "(defmacro eval-and-compile (&body body)\n \"Emacs's `eval-and-compile'.\nAlias for `eval-always'.\"\n `(eval-always\n ,@body))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(stop-when 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by STOP-WHEN", "input": "(stop-when 'lol-gen::some-name)", "output": "(defmacro STOP-WHEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(->>\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by ->>", "input": "(->>\n nil\n (progn))", "output": "(defmacro ->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(is nil (progn))\n\nPattern to recognize: Macro call that should be transformed by IS", "input": "(is nil (progn))", "output": "(defmacro is (test &rest reason-args)\n \"The DWIM checking operator.\n\nIf TEST returns a true value a test-passed result is generated,\notherwise a test-failure result is generated. The reason, unless\nREASON-ARGS is provided, is generated based on the form of TEST:\n\n (predicate expected actual) - Means that we want to check\n whether, according to PREDICATE, the ACTUAL value is\n in fact what we EXPECTED.\n\n (predicate value) - Means that we want to ensure that VALUE\n satisfies PREDICATE.\n\n Wrapping the TEST form in a NOT simply produces a negated reason\n string.\"\n (assert (listp test)\n (test)\n \"Argument to IS must be a list, not ~S\" test)\n (let (bindings effective-test default-reason-args)\n (with-gensyms (e a v)\n (flet ((process-entry (predicate expected actual &optional negatedp)\n ;; make sure EXPECTED is holding the entry that starts with 'values\n (when (and (consp actual)\n (eq (car actual) 'values))\n (assert (not (and (consp expected)\n (eq (car expected) 'values))) ()\n \"Both the expected and actual part is a values expression.\")\n (rotatef expected actual))\n (let ((setf-forms))\n (if (and (consp expected)\n (eq (car expected) 'values))\n (progn\n (setf expected (copy-list expected))\n (setf setf-forms (loop for cell = (rest expected) then (cdr cell)\n for i from 0\n while cell\n when (eq (car cell) '*)\n collect `(setf (elt ,a ,i) nil)\n and do (setf (car cell) nil)))\n (setf bindings (list (list e `(list ,@(rest expected)))\n (list a `(multiple-value-list ,actual)))))\n (setf bindings (list (list e expected)\n (list a actual))))\n (setf effective-test `(progn\n ,@setf-forms\n ,(if negatedp\n `(not (,predicate ,e ,a))\n `(,predicate ,e ,a)))))))\n (list-match-case test\n ((not (?predicate ?expected ?actual))\n (process-entry ?predicate ?expected ?actual t)\n (setf default-reason-args\n (list \"~2&~S~2% evaluated to ~2&~S~2% which is ~2&~S~2%to ~2&~S~2% (it should not be)\"\n `',?actual a `',?predicate e)))\n ((not (?satisfies ?value))\n (setf bindings (list (list v ?value))\n effective-test `(not (,?satisfies ,v))\n default-reason-args\n (list \"~2&~S~2% evaluated to ~2&~S~2% which satisfies ~2&~S~2% (it should not)\"\n `',?value v `',?satisfies)))\n ((?predicate ?expected ?actual)\n (process-entry ?predicate ?expected ?actual)\n (setf default-reason-args\n (list \"~2&~S~2% evaluated to ~2&~S~2% which is not ~2&~S~2% to ~2&~S~2%\"\n `',?actual a `',?predicate e)))\n ((?satisfies ?value)\n (setf bindings (list (list v ?value))\n effective-test `(,?satisfies ,v)\n default-reason-args\n (list \"~2&~S~2% evaluated to ~2&~S~2% which does not satisfy ~2&~S~2%\"\n `',?value v `',?satisfies)))\n (?_\n (setf bindings '()\n effective-test test\n default-reason-args (list \"~2&~S~2% was NIL.\" `',test)))))\n `(let ,bindings\n (if ,effective-test\n (add-result 'test-passed :test-expr ',test)\n (process-failure ',test\n ,@(or reason-args default-reason-args)))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(print-values)\n\nIssue: Macro call that should be transformed by PRINT-VALUES", "input": "(print-values)", "output": "(defmacro PRINT-VALUES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(on nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by ON", "input": "(on nil\n (progn))", "output": "(defmacro on (hook args &body body)\n \"Attach a handler with ARGS and BODY to the HOOK.\n\nARGS can be\n- A symbol if there's only one argument to the callback.\n- A list of arguments.\n- An empty list, if the hook handlers take no argument.\"\n (let ((handler-name (gensym \"on-hook-handler\"))\n (args (alexandria:ensure-list args)))\n `(add-hook\n ,hook (make-instance 'handler\n :fn (lambda ,args\n (declare (ignorable ,@args))\n ,@body)\n :name (quote ,handler-name)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defrte nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFRTE", "input": "(defrte nil nil)", "output": "(defmacro DEFRTE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(inline 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by INLINE", "input": "(inline 'lol-gen::some-name)", "output": "(defmacro INLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda ())\n\nPattern to recognize: Macro call that should be transformed by LAMBDA", "input": "(lambda ())", "output": "(defmacro LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(markup nil (progn))\n\nWhat needs to change: Macro call that should be transformed by MARKUP", "input": "(markup nil (progn))", "output": "(defmacro markup (&rest tags)\n `(%write-strings\n ,@(loop for tag in tags\n append (tag->string tag))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond-every\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by COND-EVERY", "input": "(cond-every\n 'lol-gen::some-name)", "output": "(defmacro cond-every (&body clauses)\n \"Like `cond', but instead of stopping after the first clause that\nsucceeds, run all the clauses that succeed.\n\nReturn the value of the last successful clause.\n\nIf a clause begins with `cl:otherwise', it runs only if no preceding\nform has succeeded.\n\nNote that this does *not* do the same thing as a series of `when'\nforms: `cond-every' evaluates *all* the tests *before* it evaluates\nany of the forms.\n\nFrom Zetalisp.\"\n (let* ((otherwise-clause (find 'otherwise clauses :key #'car))\n (test-clauses (remove otherwise-clause clauses))\n (temps (make-gensym-list (length test-clauses))))\n `(let* ,(loop for temp in temps\n for (test . nil) in test-clauses\n collect `(,temp ,test))\n ;; Work around Iterate bug. See\n ;; .\n (if (or ,@temps)\n ,(with-gensyms (ret)\n `(let (,ret)\n ,@(loop for temp in temps\n for (nil . body) in test-clauses\n collect `(when ,temp\n (setf ,ret\n ,(if (null body)\n temp\n `(progn ,@body)))))\n ,ret))\n (progn ,@(rest otherwise-clause))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "advanced", "quality_score": 0.825} {"instruction": "Generate a defmacro form that transforms code like this:\n(collect-plist nil (progn))\n\nPattern to recognize: Macro call that should be transformed by COLLECT-PLIST", "input": "(collect-plist nil (progn))", "output": "(defmacro COLLECT-PLIST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(who-ps-html nil (progn))\n\nWhat needs to change: Macro call that should be transformed by WHO-PS-HTML", "input": "(who-ps-html nil (progn))", "output": "(defmacro WHO-PS-HTML ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-unique-js-names nil (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-UNIQUE-JS-NAMES", "input": "(with-unique-js-names nil (progn))", "output": "(defmacro WITH-UNIQUE-JS-NAMES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-inactive-layers 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-INACTIVE-LAYERS", "input": "(with-inactive-layers 'lol-gen::some-name)", "output": "(defmacro WITH-INACTIVE-LAYERS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(string-ecase 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by STRING-ECASE", "input": "(string-ecase 'lol-gen::some-name)", "output": "(defmacro STRING-ECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lret* nil\n (progn))\n\nProblem: Macro call that should be transformed by LRET*", "input": "(lret* nil\n (progn))", "output": "(defmacro lret* ((&rest bindings) &body body)\n \"Cf. `lret'.\"\n `(lret-aux let* ,bindings\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(export-constructors\n common-lisp:nil\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EXPORT-CONSTRUCTORS", "input": "(export-constructors\n common-lisp:nil\n common-lisp:nil)", "output": "(defmacro EXPORT-CONSTRUCTORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(do-generators nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DO-GENERATORS", "input": "(do-generators nil\n :key\n nil)", "output": "(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)))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(select-dao nil)\n\nIssue: Macro call that should be transformed by SELECT-DAO", "input": "(select-dao nil)", "output": "(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))))))))))", "category": "capture-management", "technique": "macrolet,once-only,gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defconstant nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DEFCONSTANT", "input": "(defconstant nil :key nil)", "output": "(defmacro DEFCONSTANT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(f_%\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by F_%", "input": "(f_%\n nil\n nil)", "output": "(defmacro F_% ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(vect-of 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by VECT-OF", "input": "(vect-of 'lol-gen::some-name)", "output": "(defmacro VECT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(notinline 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by NOTINLINE", "input": "(notinline 'lol-gen::some-name)", "output": "(defmacro NOTINLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(atypecase nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by ATYPECASE", "input": "(atypecase nil\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(special)\n\nProblem: Macro call that should be transformed by SPECIAL", "input": "(special)", "output": "(defmacro SPECIAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(shift-decf nil nil)\n\nIssue: Macro call that should be transformed by SHIFT-DECF", "input": "(shift-decf nil nil)", "output": "(defmacro SHIFT-DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(->*\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ->*", "input": "(->*\n 'lol-gen::some-name)", "output": "(defmacro ->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(c?\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by C?", "input": "(c?\n nil\n nil)", "output": "(defmacro c? (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-standard-input-syntax\n nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-STANDARD-INPUT-SYNTAX", "input": "(with-standard-input-syntax\n nil\n (progn))", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(is-condition nil nil)\n\nIssue: Macro call that should be transformed by IS-CONDITION", "input": "(is-condition nil nil)", "output": "(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\"))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(collect-min nil (progn))\n\nPattern to recognize: Macro call that should be transformed by COLLECT-MIN", "input": "(collect-min nil (progn))", "output": "(defmacro COLLECT-MIN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(either)\n\nWrite a macro that addresses: Macro call that should be transformed by EITHER", "input": "(either)", "output": "(defmacro EITHER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-first 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by COLLECT-FIRST", "input": "(collect-first 'lol-gen::some-name)", "output": "(defmacro COLLECT-FIRST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ignore-errors 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by IGNORE-ERRORS", "input": "(ignore-errors 'lol-gen::some-name)", "output": "(defmacro IGNORE-ERRORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(finish 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by FINISH", "input": "(finish 'lol-gen::some-name)", "output": "(defmacro finish (form &optional description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'finishing-result\n :expression '(finish ,form)\n :body (lambda () ,form)\n ,@(when description\n `(:description (format NIL ,description ,@format-args))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(iterate nil)\n\nWhat needs to change: Macro call that should be transformed by ITERATE", "input": "(iterate nil)", "output": "(defmacro ITERATE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-metadata-kind nil\n nil)\n\nIssue: Macro call that should be transformed by DEFINE-METADATA-KIND", "input": "(define-metadata-kind nil\n nil)", "output": "(defmacro define-metadata-kind (name (&key conc-name (binds-to :value))\n &body slot-names)\n (check-metadata-slots slot-names)\n (let ((type (ecase binds-to\n (:value 'standard-value-metadata)\n (:scope 'standard-scope-metadata))))\n `(progn\n (eval-when (:compile-toplevel :load-toplevel :execute)\n (defclass ,name (,type)\n ,(mapcar \u03bb`(,_ :initform nil :initarg ,(kwd _))\n slot-names)))\n ,@(mapcar \u03bb`(defgeneric ,(if conc-name (symb conc-name _) _) (metadata))\n slot-names)\n ,@(mapcar \u03bb`(defmethod ,(if conc-name (symb conc-name _) _)\n ((metadata-collection list))\n (let ((data (cdr (assoc ',name metadata-collection))))\n (when data\n (slot-value data ',_))))\n slot-names)\n ,@(mapcar \u03bb`(defmethod ,(if conc-name (symb conc-name _) _)\n ((metadata ,name))\n (slot-value metadata ',_))\n slot-names)\n ,(when slot-names (gen-meta-init-check name slot-names))\n (defmethod print-object ((obj ,name) stream)\n (print-unreadable-object (obj stream :type t :identity t)\n (with-slots ,slot-names obj\n (format stream ,(format nil \"~{:~a ~~a~^ ~}\" slot-names)\n ,@slot-names))))\n (pushnew ',name *metadata-kinds*))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ecase-let 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ECASE-LET", "input": "(ecase-let 'lol-gen::some-name)", "output": "(defmacro ecase-let ((var expr) &body cases)\n \"Like (let ((VAR EXPR)) (ecase VAR ...)), with VAR read-only.\"\n `(let1 ,var ,expr\n (ecase ,var\n ,@cases)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(all 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ALL", "input": "(all 'lol-gen::some-name)", "output": "(defmacro all (parser &rest parsers)\n \"Combination of parsers yielding all results as a list.\"\n `(<*> ,parser ,@parsers))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(notinline common-lisp:nil\n :key\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by NOTINLINE", "input": "(notinline common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro NOTINLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(skip-on nil\n (progn))\n\nIssue: Macro call that should be transformed by SKIP-ON", "input": "(skip-on nil\n (progn))", "output": "(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)))))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(prog () (progn))\n\nPattern to recognize: Macro call that should be transformed by PROG", "input": "(prog () (progn))", "output": "(defmacro PROG ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(psib nil)\n\nWhat needs to change: Macro call that should be transformed by PSIB", "input": "(psib nil)", "output": "(defmacro psib (&optional (self-form 'self))\n (let ((self (gensym)))\n `(bwhen (,self ,self-form)\n (find-prior ,self (kids (fm-parent ,self))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(nconcf nil nil)\n\nPattern to recognize: Macro call that should be transformed by NCONCF", "input": "(nconcf nil nil)", "output": "(defmacro NCONCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(appending 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by APPENDING", "input": "(appending 'lol-gen::some-name)", "output": "(defmacro APPENDING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(rotatef nil)\n\nWhat needs to change: Macro call that should be transformed by ROTATEF", "input": "(rotatef nil)", "output": "(defmacro ROTATEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ematch common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by EMATCH", "input": "(ematch common-lisp:nil\n (common-lisp:progn))", "output": "(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))))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-html-string\n nil)\n\nProblem: Macro call that should be transformed by WITH-HTML-STRING", "input": "(with-html-string\n nil)", "output": "(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)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(check-declaration-env 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by CHECK-DECLARATION-ENV", "input": "(check-declaration-env 'lol-gen::some-name)", "output": "(defmacro CHECK-DECLARATION-ENV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(c?_\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by C?_", "input": "(c?_\n 'lol-gen::some-name)", "output": "(defmacro c?_ (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :lazy t\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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*", "input": "(defun-cmatch* common-lisp:nil\n (common-lisp:progn))", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(aprog1 nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by APROG1", "input": "(aprog1 nil\n :key\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(is-values nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IS-VALUES", "input": "(is-values nil nil)", "output": "(defmacro is-values (got expected &rest args)\n `(is (multiple-value-list ,got) ,expected ,@args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(declare-deprecated-operators 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DECLARE-DEPRECATED-OPERATORS", "input": "(declare-deprecated-operators 'lol-gen::some-name)", "output": "(defmacro DECLARE-DEPRECATED-OPERATORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(enable-static-dispatch)\n\nWhat needs to change: Macro call that should be transformed by ENABLE-STATIC-DISPATCH", "input": "(enable-static-dispatch)", "output": "(defmacro ENABLE-STATIC-DISPATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(pushnew nil (progn))\n\nWhat needs to change: Macro call that should be transformed by PUSHNEW", "input": "(pushnew nil (progn))", "output": "(defmacro PUSHNEW ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(decf nil)\n\nIssue: Macro call that should be transformed by DECF", "input": "(decf nil)", "output": "(defmacro DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(shift-incf nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SHIFT-INCF", "input": "(shift-incf nil)", "output": "(defmacro SHIFT-INCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(unless nil (progn))\n\nIssue: Macro call that should be transformed by UNLESS", "input": "(unless nil (progn))", "output": "(defmacro UNLESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(eval-when-compile\n common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by EVAL-WHEN-COMPILE", "input": "(eval-when-compile\n common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro EVAL-WHEN-COMPILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(some-<> nil (progn))\n\nWhat needs to change: Macro call that should be transformed by SOME-<>", "input": "(some-<> nil (progn))", "output": "(defmacro SOME-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fgather-result 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by FGATHER-RESULT", "input": "(fgather-result 'lol-gen::some-name)", "output": "(defmacro FGATHER-RESULT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defparameter* nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEFPARAMETER*", "input": "(defparameter* nil nil)", "output": "(defmacro DEFPARAMETER* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(fail nil :key nil)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(in-compile-time nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by IN-COMPILE-TIME", "input": "(in-compile-time nil\n nil)", "output": "(defmacro IN-COMPILE-TIME ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(print-values\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by PRINT-VALUES", "input": "(print-values\n 'lol-gen::some-name)", "output": "(defmacro PRINT-VALUES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(either\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EITHER", "input": "(either\n nil\n nil)", "output": "(defmacro EITHER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(lambda () nil)", "output": "(defmacro LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n;; Anonymous recursion requires explicit labels every time\n(labels ((self (n)\n (if (> n 0)\n (cons n (self (- n 1)))\n nil)))\n #'self)\n\n;; labels boilerplate obscures the recursive logic\n\nWhat needs to change: Need anonymous recursion without writing labels boilerplate \u2014 want implicit 'self' for recursion", "input": ";; Anonymous recursion requires explicit labels every time\n(labels ((self (n)\n (if (> n 0)\n (cons n (self (- n 1)))\n nil)))\n #'self)\n\n;; labels boilerplate obscures the recursive logic", "output": "(defmacro alambda (parms &body body)\n `(labels ((self ,parms ,@body))\n #'self))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.9125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(initially nil :key nil)\n\nProblem: Macro call that should be transformed by INITIALLY", "input": "(initially nil :key nil)", "output": "(defmacro INITIALLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(vect-of nil)\n\nPattern to recognize: Macro call that should be transformed by VECT-OF", "input": "(vect-of nil)", "output": "(defmacro VECT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-shuffling\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-SHUFFLING", "input": "(with-shuffling\n nil\n (progn))", "output": "(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))))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c_1\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by C_1", "input": "(c_1\n nil\n (progn))", "output": "(defmacro c_1 (&body body)\n `(make-c-dependent\n :code '(without-c-dependency ,@body)\n :inputp nil\n :lazy t\n :value-state :unevaluated\n :rule (c-lambda (without-c-dependency ,@body))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-symbol-access)\n\nPattern to recognize: Macro call that should be transformed by WITH-SYMBOL-ACCESS", "input": "(with-symbol-access)", "output": "(defmacro WITH-SYMBOL-ACCESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(-<>> 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by -<>>", "input": "(-<>> 'lol-gen::some-name)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(shrinkf nil nil)\n\nIssue: Macro call that should be transformed by SHRINKF", "input": "(shrinkf nil nil)", "output": "(defmacro SHRINKF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(.> 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by .>", "input": "(.> 'lol-gen::some-name)", "output": "(defmacro .> (cl:&rest items)\n \"Left associative compose operator. Creates a new functions that will run the\nfunctions left to right when applied. This is the same as the `pipe` macro without supplying\nthe value. The composition is thus the reverse order of `compose`.\n\n`(.> f g h)` creates the function `(fn (x) (h (g (f x))))`.\"\n (alexandria:with-gensyms (x)\n `(fn (,x)\n (pipe ,x ,@items))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(sum-of nil)\n\nProblem: Macro call that should be transformed by SUM-OF", "input": "(sum-of nil)", "output": "(defmacro SUM-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(gen-lambda-with-sticky-stop nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by GEN-LAMBDA-WITH-STICKY-STOP", "input": "(gen-lambda-with-sticky-stop nil nil)", "output": "(defmacro gen-lambda-with-sticky-stop (&rest rest)\n `(make-instance \n 'basic-generator \n :function (sticky-stop-lambda ,@rest)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ensure-get nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by ENSURE-GET", "input": "(ensure-get nil\n :key\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(inext nil)\n\nWrite a macro that addresses: Macro call that should be transformed by INEXT", "input": "(inext nil)", "output": "(defmacro INEXT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(html nil nil)\n\nIssue: Macro call that should be transformed by HTML", "input": "(html nil nil)", "output": "(defmacro html (&rest tags)\n `(with-doctype :html\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n($slot nil)\n\nIssue: Macro call that should be transformed by $SLOT", "input": "($slot nil)", "output": "(defmacro $SLOT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-connection nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-CONNECTION", "input": "(with-connection nil\n nil)", "output": "(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*))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(notinline common-lisp:nil\n (common-lisp:progn))\n\nWrite a macro that addresses: Macro call that should be transformed by NOTINLINE", "input": "(notinline common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro NOTINLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(js nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by JS", "input": "(js nil :key nil)", "output": "(defmacro JS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(destructuring-ccase-of nil\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fm-otherx 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by FM-OTHERX", "input": "(fm-otherx 'lol-gen::some-name)", "output": "(defmacro fm-otherx (md-name &key (starting 'self) skip-tree)\n (if (eql starting 'self)\n `(or (fm-find-one ,starting ,(if (consp md-name)\n `(list ',(car md-name) ,(cadr md-name))\n `',md-name)\n :must-find t\n :skip-tree ,skip-tree\n :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 t\n :skip-tree ,skip-tree\n :global-search t)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make-$instance nil nil)\n\nWhat needs to change: Macro call that should be transformed by MAKE-$INSTANCE", "input": "(make-$instance nil nil)", "output": "(defmacro MAKE-$INSTANCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(gatherer nil)\n\nIssue: Macro call that should be transformed by GATHERER", "input": "(gatherer nil)", "output": "(defmacro GATHERER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda () (progn))\n\nWhat needs to change: Macro call that should be transformed by LAMBDA", "input": "(lambda () (progn))", "output": "(defmacro LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dowhile-it nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DOWHILE-IT", "input": "(dowhile-it nil)", "output": "(defmacro dowhile-it (test &body body)\n \"Like DOWHILE. IT is bound to TEST.\"\n `(do ((it ,test ,test))\n ((not it))\n ,@body))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(eif nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by EIF", "input": "(eif nil (progn))", "output": "(defmacro eif (&whole whole test then &optional (else nil else?))\n \"Like `cl:if', but expects two branches.\n\nIf there is only one branch a warning is signaled.\n\nThis macro is useful when writing explicit decision trees; it will\nwarn you if you forget a branch.\n\nShort for \u201cexhaustive if\u201d.\"\n (unless else?\n (warn \"Missing else-branch in eif form:~%~a\"\n whole))\n `(if ,test ,then ,else))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ekx nil nil)\n\nWhat needs to change: Macro call that should be transformed by EKX", "input": "(ekx nil nil)", "output": "(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)))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-ps-gensyms nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-PS-GENSYMS", "input": "(with-ps-gensyms nil\n :key\n nil)", "output": "(defmacro WITH-PS-GENSYMS ...)", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(multiple-value-bind nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by MULTIPLE-VALUE-BIND", "input": "(multiple-value-bind nil :key nil)", "output": "(defmacro MULTIPLE-VALUE-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(etypecase-of nil\n nil)\n\nIssue: Macro call that should be transformed by ETYPECASE-OF", "input": "(etypecase-of nil\n nil)", "output": "(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)))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ps-once-only nil)\n\nProblem: Macro call that should be transformed by PS-ONCE-ONLY", "input": "(ps-once-only nil)", "output": "(defmacro PS-ONCE-ONLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defobserver nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFOBSERVER", "input": "(defobserver nil nil)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(collecting-into 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECTING-INTO", "input": "(collecting-into 'lol-gen::some-name)", "output": "(defmacro COLLECTING-INTO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-product nil (progn))\n\nWhat needs to change: Macro call that should be transformed by COLLECT-PRODUCT", "input": "(collect-product nil (progn))", "output": "(defmacro COLLECT-PRODUCT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defvar nil nil)\n\nIssue: Macro call that should be transformed by DEFVAR", "input": "(defvar nil nil)", "output": "(defmacro DEFVAR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda-match\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LAMBDA-MATCH", "input": "(lambda-match\n nil\n nil)", "output": "(defmacro LAMBDA-MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(resolving\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by RESOLVING", "input": "(resolving\n nil\n :key\n nil)", "output": "(defmacro RESOLVING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(order-by nil :key nil)\n\nProblem: Macro call that should be transformed by ORDER-BY", "input": "(order-by nil :key nil)", "output": "(defmacro ORDER-BY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(dynamic-progv nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DYNAMIC-PROGV", "input": "(dynamic-progv nil\n nil)", "output": "(defmacro DYNAMIC-PROGV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(send nil (progn))\n\nIssue: Macro call that should be transformed by SEND", "input": "(send nil (progn))", "output": "(defmacro SEND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(dynamic-extent common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by DYNAMIC-EXTENT", "input": "(dynamic-extent common-lisp:nil)", "output": "(defmacro DYNAMIC-EXTENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-type-alias 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-TYPE-ALIAS", "input": "(define-type-alias 'lol-gen::some-name)", "output": "(defmacro DEFINE-TYPE-ALIAS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(disable-quasiquote-2.0)\n\nIssue: Macro call that should be transformed by DISABLE-QUASIQUOTE-2.0", "input": "(disable-quasiquote-2.0)", "output": "(defmacro DISABLE-QUASIQUOTE-2.0 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fm-other nil)\n\nIssue: Macro call that should be transformed by FM-OTHER", "input": "(fm-other nil)", "output": "(defmacro fm-other (md-name &key (starting 'self) skip-tree (test '#'true-that))\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 :skip-tree ,skip-tree\n :global-search t\n :test ,test))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(f_\n nil)\n\nPattern to recognize: Macro call that should be transformed by F_", "input": "(f_\n nil)", "output": "(defmacro F_ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-constant-inject-hook nil)\n\nIssue: Macro call that should be transformed by WITH-CONSTANT-INJECT-HOOK", "input": "(with-constant-inject-hook nil)", "output": "(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)))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(defrule nil)\n\nPattern to recognize: Macro call that should be transformed by DEFRULE", "input": "(defrule nil)", "output": "(defmacro DEFRULE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-access-values nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-ACCESS-VALUES", "input": "(with-access-values nil\n nil)", "output": "(defmacro with-access-values ((&rest bindings) obj &body body)\n \"A macro which binds local variables from accessed values on object\n according to bindings\n\n bindings: (local-symbol-and-access-key\n or (local-symbol access-key)\n ...)\n obj: the thing we are accessing data from\n \"\n (flet ((key-for (it)\n (etypecase it\n (symbol `(quote ,it))\n ((or string keyword list) it))))\n (let* ((o (gensym \"OBJ\"))\n (expanded-bindings\n (iter (for b in (ensure-list bindings))\n (when (first-iteration-p)\n (collect `(,o ,obj)))\n (typecase b\n (null)\n (list (collect `(,(first b) (access ,o ,(key-for (second b))))))\n (symbol (collect `(,b (access ,o ,(key-for b)))))))))\n `(let* ,expanded-bindings\n ,@body))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7424999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-class nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-CLASS", "input": "(define-class nil\n :key\n nil)", "output": "(defmacro DEFINE-CLASS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(collect-nconc nil)\n\nProblem: Macro call that should be transformed by COLLECT-NCONC", "input": "(collect-nconc nil)", "output": "(defmacro COLLECT-NCONC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(dispatch-caseql 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DISPATCH-CASEQL", "input": "(dispatch-caseql 'lol-gen::some-name)", "output": "(defmacro dispatch-caseql ((&rest exprs-and-types) &body clauses)\n \"Like `dispatch-case', but types in clauses are implicitly wrapped in `eql'.\nThe syntax of `dispatch-caseql' is tohus closer to `case' than to\n`typecase'.\"\n (expect-form-list\n `(dispatch-case ,exprs-and-types\n ,@(expand-dispatch-caseql-clauses clauses))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-access nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-ACCESS", "input": "(with-access nil\n (progn))", "output": "(defmacro with-access ((&rest keys) val-form &body body)\n \"Similar to with-accessors except using the access functions\"\n (let* ((gval (gensym \"val\"))\n (forms\n (iter (for k in keys)\n (for (k-to k-from) = (if (listp k) k (list k k)))\n (collect `(,k-to (access ,gval ',k-from))))))\n `(let ((,gval ,val-form))\n (declare (ignorable ,gval))\n (symbol-macrolet (,@forms)\n ,@body\n ))))", "category": "dispatch", "technique": "symbol-macrolet,gensym", "complexity": "intermediate", "quality_score": 0.88} {"instruction": "Generate a defmacro form that transforms code like this:\n(loop)\n\nPattern to recognize: Macro call that should be transformed by LOOP", "input": "(loop)", "output": "(defmacro LOOP ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(incf nil)\n\nWhat needs to change: Macro call that should be transformed by INCF", "input": "(incf nil)", "output": "(defmacro INCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(do-tags-in-lexenv 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DO-TAGS-IN-LEXENV", "input": "(do-tags-in-lexenv 'lol-gen::some-name)", "output": "(defmacro DO-TAGS-IN-LEXENV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(iterate\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ITERATE", "input": "(iterate\n 'lol-gen::some-name)", "output": "(defmacro iterate (&body body)\n \"Jonathan Amsterdam's powerful iteration facility\"\n `(iter .,body))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda-match*)\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-MATCH*", "input": "(lambda-match*)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(as-> nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by AS->", "input": "(as-> nil\n (progn))", "output": "(defmacro as-> (init var &body exps)\n `(let ((,var ,init))\n ,var\n ,@(loop for (exp next-exp) on exps\n collect (if next-exp `(setf ,var ,exp) exp))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-contracts-enabled nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-CONTRACTS-ENABLED", "input": "(with-contracts-enabled nil\n (progn))", "output": "(defmacro with-contracts-enabled\n ((&rest args &key invariants preconditions postconditions) &body body)\n \"Enables/disables contracts for the extent of this form, restoring them to\n their prior values upon exit.\"\n (declare (ignore invariants preconditions postconditions))\n (let ((enabled-contracts (gensym \"ENABLED-CONTRACTS-\")))\n `(let ((,enabled-contracts (enabled-contracts)))\n (unwind-protect\n (progn (enable-contracts ,@args)\n ,@body)\n (apply #'enable-contracts ,enabled-contracts)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-slots nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-SLOTS", "input": "(with-slots nil\n (progn))", "output": "(defmacro WITH-SLOTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(order-by 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by ORDER-BY", "input": "(order-by 'lol-gen::some-name)", "output": "(defmacro order-by (&rest expressions)\n `(make-clause :order-by ,@(expand-expression expressions)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fm-map nil (progn))\n\nPattern to recognize: Macro call that should be transformed by FM-MAP", "input": "(fm-map nil (progn))", "output": "(defmacro fm-map (fn md-name)\n `(mapcar ,fn (fm-find-all self ',md-name)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fluid-bind 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by FLUID-BIND", "input": "(fluid-bind 'lol-gen::some-name)", "output": "(defmacro fluid-bind ((&rest bindings) &body body)\n \"Fluid-bind is an extension of bind that handles setting and resetting places. For example, suppose that an object of class foo has a slot named bar whose value is currently 3. The following code would evaluate the inner body with bar bound to 17 and restore it when the inner body is exited. \n\n\\(fluid-bind \\(\\(\\(bar foo\\) 17\\)\\)\n \\(print \\(bar foo\\)\\)\\)\n\\(print \\(bar foo\\)\\)\n==> \\(prints 17, then 3\\)\n\nThis is similar to dynamic-binding but _much_ less robust.\"\n ;; does not handle declarations correctly\n (let ((setup-forms nil)\n (cleanup-forms nil)\n (gensyms nil))\n (loop for binding in bindings collect\n (destructuring-bind \n\t\t(setup-form cleanup-form)\n\t (cond ((consp binding)\n\t\t (destructuring-bind (var value) binding\n\t\t (let ((g (gensym)))\n\t\t\t (push g gensyms)\n\t\t\t (cond ((atom var)\n\t\t\t\t`((:bind (,var ,value)) nil)\n\t\t\t\t#+(or)\n\t\t\t\t;; lexical or special?\n\t\t\t\t(if (boundp var)\n\t\t\t\t `((:bind (,var ,value)) nil)\n\t\t\t\t `((:setf (setf ,g ,var ,var ,value))\n\t\t\t\t (setf ,var ,g))))\n\t\t\t ((and (fboundp (first var))\n\t\t\t\t (not (eq (first var) 'values)))\n\t\t\t\t;; putative place\n\t\t\t\t`((:setf (setf ,g ,var ,var ,value))\n\t\t\t\t (setf ,var ,g)))\n\t\t\t (t\n\t\t\t\t`((:bind (,var ,value)) nil))))))\n\t\t (t\n\t\t `((:bind (,binding nil)) nil)))\n (push setup-form setup-forms)\n (push cleanup-form cleanup-forms)))\n (let ((result body))\n (mapc (lambda (setup cleanup)\n (setf result\n (ecase (first setup)\n (:setf `((unwind-protect\n (progn\n ,(second setup)\n ,@result)\n ,cleanup)))\n (:bind `((bind (,(second setup))\n ,@result)))))\n result)\n setup-forms cleanup-forms)\n `(let ,gensyms\n (declare (ignorable ,@gensyms))\n ,@result))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "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", "input": "(match nil\n nil)", "output": "(defmacro MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with nil (progn))\n\nProblem: Macro call that should be transformed by WITH", "input": "(with nil (progn))", "output": "(defmacro WITH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(acase nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by ACASE", "input": "(acase nil\n (progn))", "output": "(defmacro acase (keyform &body cases)\n \"Like CASE, except binds the result of the keyform to IT (via LET) for the\nscope of the cases.\"\n `(anaphoric case ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(xor 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by XOR", "input": "(xor 'lol-gen::some-name)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Generate a defmacro form that transforms code like this:\n(cll-inner 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by CLL-INNER", "input": "(cll-inner 'lol-gen::some-name)", "output": "(defmacro cll-inner (expr)\n `(,expr outer-val))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(f-plusp 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by F-PLUSP", "input": "(f-plusp 'lol-gen::some-name)", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cond->> nil (progn))\n\nProblem: Macro call that should be transformed by COND->>", "input": "(cond->> nil (progn))", "output": "(defmacro COND->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-unknown-first-class-functions-allowed\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-UNKNOWN-FIRST-CLASS-FUNCTIONS-ALLOWED", "input": "(with-unknown-first-class-functions-allowed\n nil\n :key\n nil)", "output": "(defmacro with-unknown-first-class-functions-allowed (&body body)\n `(let ((*allow-call-function-signature* t))\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(type common-lisp:nil\n (common-lisp:progn))\n\nPattern to recognize: Macro call that should be transformed by TYPE", "input": "(type common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro TYPE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(alter-table nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by ALTER-TABLE", "input": "(alter-table nil\n :key\n nil)", "output": "(defmacro alter-table (table &body clauses)\n `(make-statement :alter-table\n ,(expand-expression table) ,@clauses))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(select nil)\n\nWhat needs to change: Macro call that should be transformed by SELECT", "input": "(select nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-method-combination 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DEFINE-METHOD-COMBINATION", "input": "(define-method-combination 'lol-gen::some-name)", "output": "(defmacro define-method-combination (name &rest args)\n `(progn\n (define-method-combination% ,name ,@args)\n (c2mop:define-method-combination ,name ,@args)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fn common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FN", "input": "(fn common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro FN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(w/uniqs nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by W/UNIQS", "input": "(w/uniqs nil\n nil)", "output": "(defmacro W/UNIQS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dispatch-case-let nil)\n\nWhat needs to change: Macro call that should be transformed by DISPATCH-CASE-LET", "input": "(dispatch-case-let nil)", "output": "(defmacro dispatch-case-let ((&rest bindings) &body clauses &environment env)\n \"Like `dispatch-case', but establish new bindings for each expression.\n\nFor example,\n\n (dispatch-case-let (((x string) (expr1))\n ((y string) (expr2)))\n ...)\n\nis equivalent to\n\n (let ((x (expr1))\n (y (expr2)))\n (dispatch-case ((x string)\n (y string))\n ...))\n\nIt may be helpful to think of this as a cross between\n`defmethod' (where the (variable type) notation is used in the lambda\nlist) and `let' (which has an obvious macro-expansion in terms of\n`lambda').\"\n (multiple-value-bind (vars types exprs)\n ;; Split the bindings and types.\n (with-collectors (vars-out types-out exprs-out)\n (flet ((vars-out (var) (vars-out (ensure-var var))))\n (dolist (binding bindings)\n (ematch binding\n ((list (and var (type symbol)) expr)\n (vars-out var)\n (types-out t)\n (exprs-out expr))\n ((list (list (and var (type symbol)) type) expr)\n (vars-out var)\n (types-out type)\n (exprs-out expr))))))\n (let ((normalized-clauses\n ;; Normalize asterisks into the types of the corresponding\n ;; variables.\n (loop for (clause-types . clause-body) in clauses\n collect (cons\n (loop for clause-type in clause-types\n for type in types\n if (eql clause-type '*)\n collect type\n else collect clause-type)\n clause-body))))\n (with-unique-names (block)\n (multiple-value-bind (tags final-clauses)\n (hoist-clause-bodies block normalized-clauses env)\n `(let ,(mapcar #'list vars exprs)\n (with-read-only-vars ,vars\n (block ,block\n (tagbody\n (dispatch-case/nobindings ,(mapcar #'list vars types)\n ,@final-clauses)\n ,@tags)))))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(static-load-time-value nil nil)\n\nProblem: Macro call that should be transformed by STATIC-LOAD-TIME-VALUE", "input": "(static-load-time-value nil nil)", "output": "(defmacro static-load-time-value\n (form &optional (read-only-p nil read-only-p-supplied?))\n \"Like `load-time-value', but signals an error if it cannot preserve identity.\n\nOn close reading of the standard, in a function that is evaluated but\nnot compiled, it is permissible for implementations to repeatedly\nexecute a `load-time-value' form, and in fact some implementations do\nthis \\(including, at the time of writing, ABCL, CLISP, Allegro and\nLispWorks).\n\nWhen `static-load-time-value' is compiled, it behaves exactly like\n`load-time-value'. Otherwise it conducts a run-time check to ensure\nthat `load-time-value' preserves identity.\"\n ;; Thanks to Jean-Philippe Paradis and Micha\u0142 Herda for helping to\n ;; diagnose and treat the problem here.\n (if *compile-file-truename*\n `(load-time-value ,form\n ,@(and read-only-p-supplied? (list read-only-p)))\n `(progn\n (flet ((fn () (load-time-value (random most-positive-fixnum))))\n (declare (dynamic-extent #'fn) (ignorable #'fn)\n #+LispWorks (notinline fn))\n ;; Do the actual test out of line.\n (test-load-time-value #'fn ',form ',read-only-p))\n (load-time-value ,form\n ,@(and read-only-p-supplied? (list read-only-p))))))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(summing-to-and-returning nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SUMMING-TO-AND-RETURNING", "input": "(summing-to-and-returning nil (progn))", "output": "(defmacro SUMMING-TO-AND-RETURNING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ecase-of nil\n (progn))\n\nIssue: Macro call that should be transformed by ECASE-OF", "input": "(ecase-of nil\n (progn))", "output": "(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)))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda-coro\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by LAMBDA-CORO", "input": "(lambda-coro\n nil\n (progn))", "output": "(defmacro LAMBDA-CORO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(isnt-values nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by ISNT-VALUES", "input": "(isnt-values nil\n (progn))", "output": "(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)))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(untrace nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by UNTRACE", "input": "(untrace nil (progn))", "output": "(defmacro UNTRACE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(synchronized nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SYNCHRONIZED", "input": "(synchronized nil\n nil)", "output": "(defmacro synchronized ((&optional (object nil objectp)) &body body &environment env)\n \"Run BODY holding a unique lock associated with OBJECT.\nIf no OBJECT is provided, run BODY as an anonymous critical section.\n\nIf BODY begins with a literal string, attach the string to the lock\nobject created (as the argument to `bt:make-recursive-lock').\"\n (multiple-value-bind (string? body)\n (if (stringp (first body))\n (values (first body) (rest body))\n (values nil body))\n (let* ((form (lock-form object objectp env string?)))\n (with-gensyms (lock)\n `(let ((,lock ,form))\n (bt:with-recursive-lock-held (,lock)\n ;; On some Lisps this would return T if empty.\n ,@(or body '(nil))))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-ps-gensyms 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-PS-GENSYMS", "input": "(with-ps-gensyms 'lol-gen::some-name)", "output": "(defmacro WITH-PS-GENSYMS ...)", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.7675} {"instruction": "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->*", "input": "(as->* nil (progn))", "output": "(defmacro AS->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(match* 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by MATCH*", "input": "(match* 'lol-gen::some-name)", "output": "(defmacro match* (whats &body clauses)\n #.+match*-doc+ \n `(match2* ,whats\n ,@clauses\n (_ nil)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defvar* nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFVAR*", "input": "(defvar* nil :key nil)", "output": "(defmacro DEFVAR* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(decf nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DECF", "input": "(decf nil (progn))", "output": "(defmacro DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(enable-dot-syntax)\n\nWhat needs to change: Macro call that should be transformed by ENABLE-DOT-SYNTAX", "input": "(enable-dot-syntax)", "output": "(defmacro enable-dot-syntax ()\n \"Enable reader syntax.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (%enable-dot-syntax)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond-bind 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by COND-BIND", "input": "(cond-bind 'lol-gen::some-name)", "output": "(defmacro COND-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(actypecase nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ACTYPECASE", "input": "(actypecase nil)", "output": "(defmacro actypecase (keyform &body cases)\n \"Like CTYPECASE, except binds the result of the keyform to IT (via LET) for\nthe scope of the cases. Unlike CTYPECASE, new values possible stored by the\nSTORE-VALUE restart are not received by the keyform/place, but by IT.\"\n `(anaphoric ctypecase ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(all nil)\n\nWhat needs to change: Macro call that should be transformed by ALL", "input": "(all nil)", "output": "(defmacro all (parser &rest parsers)\n \"Combination of parsers yielding all results as a list.\"\n `(<*> ,parser ,@parsers))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(when-let* nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WHEN-LET*", "input": "(when-let* nil\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defproto nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPROTO", "input": "(defproto nil)", "output": "(defmacro DEFPROTO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-global-var* nil (progn))\n\nIssue: Macro call that should be transformed by DEFINE-GLOBAL-VAR*", "input": "(define-global-var* nil (progn))", "output": "(defmacro DEFINE-GLOBAL-VAR* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(shiftf nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SHIFTF", "input": "(shiftf nil :key nil)", "output": "(defmacro SHIFTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-module nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by DEFINE-MODULE", "input": "(define-module nil\n :key\n nil)", "output": "(defmacro define-module (name &body options)\n (let ((name (string name))\n (package (gensym \"PACKAGE\")))\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (let ((,package (or (find-package ,name)\n (make-package ,name :use ()))))\n (modularize :package ,package :name ,name)\n (expand-module ,name ',options)\n ,package))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(reversef 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by REVERSEF", "input": "(reversef 'lol-gen::some-name)", "output": "(defmacro REVERSEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(the-kids nil)\n\nWhat needs to change: Macro call that should be transformed by THE-KIDS", "input": "(the-kids nil)", "output": "(defmacro the-kids (&rest kids)\n `(let ((*parent* self))\n (packed-flat! ,@kids)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(export-always nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EXPORT-ALWAYS", "input": "(export-always nil nil)", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda-match\n common-lisp:nil\n :key\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by LAMBDA-MATCH", "input": "(lambda-match\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-boolean nil)\n\nProblem: Macro call that should be transformed by WITH-BOOLEAN", "input": "(with-boolean nil)", "output": "(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)))))))))", "category": "anaphoric", "technique": "symbol-macrolet,macrolet,anaphor", "complexity": "intermediate", "quality_score": 0.8925} {"instruction": "Generate a defmacro form that transforms code like this:\n(current-decoder)\n\nPattern to recognize: Macro call that should be transformed by CURRENT-DECODER", "input": "(current-decoder)", "output": "(defmacro current-decoder (&rest keys)\n \"Capture current values of custom variables and return a custom\ndecoder which restores these values in its dynamic environment.\"\n (let (exterior-bindings customizations)\n (flet ((collect (key var)\n (let ((exterior (gensym)))\n (push (list exterior var) exterior-bindings)\n (push exterior customizations)\n (push key customizations))))\n (if keys\n (loop for key in keys\n do (collect key (custom-key-to-variable key)))\n (loop-on-custom (key var)\n do (collect key var)))\n `(let ,exterior-bindings\n (custom-decoder ,@customizations)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cond-> nil\n (progn))\n\nIssue: Macro call that should be transformed by COND->", "input": "(cond-> nil\n (progn))", "output": "(defmacro cond-> (init &body exps) (cond-arrow-macro init exps))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(for-all nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by FOR-ALL", "input": "(for-all nil\n :key\n nil)", "output": "(defmacro for-all (bindings &body body)\n \"Bind BINDINGS to random variables and test BODY *num-trials* times.\n\nBINDINGS is a list of binding forms, each element is a list\nof (BINDING VALUE &optional GUARD). Value, which is evaluated\nonce when the for-all is evaluated, must return a generator which\nbe called each time BODY is evaluated. BINDING is either a symbol\nor a list which will be passed to destructuring-bind. GUARD is a\nform which, if present, stops BODY from executing when IT returns\nNIL. The GUARDS are evaluated after all the random data has been\ngenerated and they can refer to the current value of any\nbinding. NB: Generator forms, unlike guard forms, can not contain\nreferences to the bound variables.\n\nExamples:\n\n (for-all ((a (gen-integer)))\n (is (integerp a)))\n\n (for-all ((a (gen-integer) (plusp a)))\n (is (integerp a))\n (is (plusp a)))\n\n (for-all ((less (gen-integer))\n (more (gen-integer) (< less more)))\n (is (<= less more)))\n\n (for-all (((a b) (gen-two-integers)))\n (is (integerp a))\n (is (integerp b)))\"\n (with-gensyms (test-lambda-args)\n `(perform-random-testing\n (list ,@(mapcar #'second bindings))\n (lambda (,test-lambda-args)\n (destructuring-bind ,(mapcar #'first bindings)\n ,test-lambda-args\n (if (and ,@(delete-if #'null (mapcar #'third bindings)))\n (progn ,@body)\n (throw 'run-once\n (list :guard-conditions-failed))))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-savepoint nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-SAVEPOINT", "input": "(with-savepoint nil\n :key\n nil)", "output": "(defmacro with-savepoint (name &body body)\n \"Can only be used within a transaction. Establishes a savepoint with the given\nname at the start of body, and binds the same name to a handle for that savepoint.\nThe body is executed and, at the end of body, the savepoint is released, unless a\ncondition is thrown, in which case it is rolled back. Execute the body within a\nsavepoint, releasing savepoint when the body exits normally, and rolling back\notherwise. NAME is both the variable that can be used to release or rolled back\nbefore the body unwinds, and the SQL name of the savepoint.\n\nAn example might look like this:\n\n(defun test12 (x &optional (y nil))\n (with-logical-transaction (lt1 :read-committed-rw)\n (execute (:insert-into 'test-data :set 'value 0))\n (with-savepoint sp1\n (execute (:insert-into 'test-data :set 'value 1))\n (if (< x 0)\n (rollback-savepoint sp1)\n (release-savepoint sp1)))\n (with-savepoint sp2\n (execute (:insert-into 'test-data :set 'value 2))\n (with-savepoint sp3\n (execute (:insert-into 'test-data :set 'value 3))\n (if (> x 0)\n (rollback-savepoint sp3)\n (release-savepoint sp3))\n (when y (rollback-savepoint sp2)))\n (if (= x 0)\n (rollback-savepoint sp2)\n (release-savepoint sp2)))\n (when (string= y \\\"abrt\\\")\n (abort-transaction lt1))))\"\n\n `(call-with-savepoint ',name (lambda (,name)\n (declare (ignorable ,name)) ,@body)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(untrace 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by UNTRACE", "input": "(untrace 'lol-gen::some-name)", "output": "(defmacro UNTRACE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(set-arg-list-key-value! nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by SET-ARG-LIST-KEY-VALUE!", "input": "(set-arg-list-key-value! nil :key nil)", "output": "(defmacro set-arg-list-key-value! (new ids place &key (test '#'equalper) (key '#'identity))\n `(progn\n (iter (for id in (ensure-list ,ids))\n (setf ,place (set-arg-list-key-value ,new id ,place :test ,test :key ,key)))\n ,place))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dynamic-reprogv nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DYNAMIC-REPROGV", "input": "(dynamic-reprogv nil\n nil)", "output": "(defmacro DYNAMIC-REPROGV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(match2+ common-lisp:nil\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by MATCH2+", "input": "(match2+ common-lisp:nil\n common-lisp:nil)", "output": "(defmacro match2+ (what type &body clauses)\n \"Variant of match2 : can specify the inferred type of the argument\"\n `(match2*+ (,what) (,type)\n ,@(mapcar (lambda-ematch0\n ((list* pattern body)\n (list* (list pattern) body)))\n clauses)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(assuref nil (progn))\n\nProblem: Macro call that should be transformed by ASSUREF", "input": "(assuref nil (progn))", "output": "(defmacro assuref (place type-spec)\n \"Like `(progn (check-type PLACE TYPE-SPEC) PLACE)`, but evaluates\nPLACE only once.\"\n (with-gensyms (temp)\n (let ((ts type-spec))\n `(the ,ts\n (values\n (let ((,temp ,place))\n (if (typep ,temp ',ts)\n ,temp\n (setf ,place (require-type-for ,temp ',ts ',place)))))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(prependf nil (progn))\n\nIssue: Macro call that should be transformed by PREPENDF", "input": "(prependf nil (progn))", "output": "(defmacro PREPENDF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defmacro-clause 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DEFMACRO-CLAUSE", "input": "(defmacro-clause 'lol-gen::some-name)", "output": "(defmacro DEFMACRO-CLAUSE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nsib nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NSIB", "input": "(nsib nil)", "output": "(defmacro nsib (&optional (self-form 'self))\n (let ((self (gensym)))\n `(bwhen (,self ,self-form)\n (cadr (member ,self (kids (fm-parent ,self)))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "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", "input": "(local\n nil\n nil)", "output": "(defmacro LOCAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(typecase-let 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by TYPECASE-LET", "input": "(typecase-let 'lol-gen::some-name)", "output": "(defmacro typecase-let ((var expr) &body cases)\n \"Like (let ((VAR EXPR)) (typecase VAR ...)), with VAR read-only.\"\n `(let1 ,var ,expr\n (typecase ,var\n ,@cases)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(defprepared nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFPREPARED", "input": "(defprepared nil (progn))", "output": "(defmacro defprepared (name query &optional (format :rows))\n \"This is another macro variant of prepare. It is like prepare, but gives the\nfunction a name which now becomes a top-level function for the prepared\nstatement. The name should not be a string but may be quoted.\"\n (when (consp name) (setf name (s-sql::dequote name)))\n `(let ((overwrite ,*allow-overwriting-prepared-statements*))\n ,(generate-prepared `(defun ,name) name query format)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda-cmatch*\n common-lisp:nil\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LAMBDA-CMATCH*", "input": "(lambda-cmatch*\n common-lisp:nil\n common-lisp:nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Generate a defmacro form that transforms code like this:\n(c-assert 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by C-ASSERT", "input": "(c-assert 'lol-gen::some-name)", "output": "(defmacro c-assert (assertion &optional places fmt$ &rest fmt-args)\n (declare (ignorable assertion places fmt$ fmt-args))\n #+(or)`(progn) \n `(unless *stop*\n (unless ,assertion\n ,(if fmt$\n `(c-break ,fmt$ ,@fmt-args)\n `(c-break \"failed assertion: ~a\" ',assertion)))))", "category": "control-flow", "technique": "nested-backquote", "complexity": "intermediate", "quality_score": 0.8725} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(make-nodelist 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by MAKE-NODELIST", "input": "(make-nodelist 'lol-gen::some-name)", "output": "(defmacro make-nodelist (items &key (prepend nil) (quoty nil))\n \"Build general or specific nodelist.\"\n (let ((prepend (if (listp prepend) prepend `(,prepend))))\n `(nodelist\n (list ,@(loop for i in items collect\n\t\t(if prepend\n\t\t (if quoty\n\t\t\t`(,@prepend (quoty ,i))\n\t\t\t`(,@prepend ,i))\n\t\t `(make-node-function (quoty ,i))))))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-test+run-interactively nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-TEST+RUN-INTERACTIVELY", "input": "(define-test+run-interactively nil\n nil)", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make-name-transformer nil (progn))\n\nWhat needs to change: Macro call that should be transformed by MAKE-NAME-TRANSFORMER", "input": "(make-name-transformer nil (progn))", "output": "(defmacro MAKE-NAME-TRANSFORMER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defplace nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPLACE", "input": "(defplace nil\n (progn))", "output": "(defmacro defplace (name args &body body)\n \"Define NAME and (SETF NAME) in one go.\n\nBODY is a list of forms, starting with an optional docstring. The last\nform in BODY, however, must be a single, setf-able expression.\"\n (match body\n ((list (type string))\n (error \"No form for ~s: ~a\" 'defplace body))\n ((last (cons (type string) nil) 1)\n `(defplace ,name ,args ,@(reverse body)))\n (otherwise\n (with-gensyms (value)\n `(progn\n (defun ,name ,args\n ,@body)\n (defun (setf ,name) (,value ,@args)\n ,@(butlast body)\n (setf ,(lastcar body) ,value)))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-condition-restarts nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-CONDITION-RESTARTS", "input": "(with-condition-restarts nil\n :key\n nil)", "output": "(defmacro WITH-CONDITION-RESTARTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-method-combination nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-METHOD-COMBINATION", "input": "(define-method-combination nil)", "output": "(defmacro DEFINE-METHOD-COMBINATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(sunless nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SUNLESS", "input": "(sunless nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(or nil)\n\nPattern to recognize: Macro call that should be transformed by OR", "input": "(or nil)", "output": "(defmacro OR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(cond->> nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by COND->>", "input": "(cond->> nil\n (progn))", "output": "(defmacro cond->> (init &body exps) (cond-arrow-macro init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fields nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by FIELDS", "input": "(fields nil :key nil)", "output": "(defmacro fields (&rest fields)\n `(make-clause :fields ,@(mapcar #'expand-op fields)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(with-unique-names nil\n nil)", "output": "(defmacro WITH-UNIQUE-NAMES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-unique-names 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-UNIQUE-NAMES", "input": "(with-unique-names 'lol-gen::some-name)", "output": "(defmacro with-unique-names (names &body forms)\n \"Alias for WITH-GENSYMS.\"\n `(with-gensyms ,names ,@forms))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(collecting\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECTING", "input": "(collecting\n nil)", "output": "(defmacro collecting (&body body)\n \"Like `with-collector', with the collector bound to the result of\ninterning `collect' in the current package.\"\n (with-current-package-symbols (collect)\n `(with-collector (,collect)\n ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(source-position nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SOURCE-POSITION", "input": "(source-position nil :key nil)", "output": "(defmacro SOURCE-POSITION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-simple-type-map nil nil)\n\nProblem: Macro call that should be transformed by DEFINE-SIMPLE-TYPE-MAP", "input": "(define-simple-type-map nil nil)", "output": "(defmacro define-simple-type-map (class type)\n `(defmethod type ((,class ,class))\n ',type))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(^fm-next-sib 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ^FM-NEXT-SIB", "input": "(^fm-next-sib 'lol-gen::some-name)", "output": "(defmacro ^fm-next-sib (&optional (self 'self))\n (let ((s (gensym)))\n `(let ((,s ,self))\n (car (cdr (member ,s (kids (fm-parent ,s))))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(match2+ common-lisp:nil\n (common-lisp:progn))\n\nWrite a macro that addresses: Macro call that should be transformed by MATCH2+", "input": "(match2+ common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro match2+ (what type &body clauses)\n \"Variant of match2 : can specify the inferred type of the argument\"\n `(match2*+ (,what) (,type)\n ,@(mapcar (lambda-ematch0\n ((list* pattern body)\n (list* (list pattern) body)))\n clauses)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(appendf nil nil)\n\nPattern to recognize: Macro call that should be transformed by APPENDF", "input": "(appendf nil nil)", "output": "(defmacro APPENDF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(one-value 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by ONE-VALUE", "input": "(one-value 'lol-gen::some-name)", "output": "(defmacro ONE-VALUE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(in-optimizer 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by IN-OPTIMIZER", "input": "(in-optimizer 'lol-gen::some-name)", "output": "(defmacro in-optimizer (name &optional verbose)\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n ,@(when verbose\n `((when ,verbose (format *trace-output* \"~&Switching to the ~A optimizer~%\" ',name))))\n (setf *optimizer* ',name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(eval-always\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n common-lisp:nil)", "output": "(defmacro EVAL-ALWAYS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(inner-join nil)\n\nProblem: Macro call that should be transformed by INNER-JOIN", "input": "(inner-join nil)", "output": "(defmacro inner-join (table &key on using)\n `(join ,table :kind :inner :on ,on :using ,using))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(some-> nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SOME->", "input": "(some-> nil nil)", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(and-it nil (progn))\n\nProblem: Macro call that should be transformed by AND-IT", "input": "(and-it nil (progn))", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defsynonym nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFSYNONYM", "input": "(defsynonym nil (progn))", "output": "(defmacro DEFSYNONYM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-port-value-slot nil (progn))\n\nProblem: Macro call that should be transformed by DEFINE-PORT-VALUE-SLOT", "input": "(define-port-value-slot nil (progn))", "output": "(defmacro DEFINE-PORT-VALUE-SLOT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(doiter nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DOITER", "input": "(doiter nil\n (progn))", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ccase nil)\n\nProblem: Macro call that should be transformed by CCASE", "input": "(ccase nil)", "output": "(defmacro CCASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(who-ps-html nil nil)\n\nPattern to recognize: Macro call that should be transformed by WHO-PS-HTML", "input": "(who-ps-html nil nil)", "output": "(defmacro WHO-PS-HTML ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(scase nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by SCASE", "input": "(scase nil\n nil)", "output": "(defmacro scase (keyform &body cases)\n \"Like CASE, except binds the keyform to IT (via SYMBOL-MACROLET) for the\nscope of the body. IT can be set with SETF.\"\n `(symbolic case ,keyform ,@cases))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(eval-when-compile\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by EVAL-WHEN-COMPILE", "input": "(eval-when-compile\n common-lisp:nil)", "output": "(defmacro EVAL-WHEN-COMPILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(execute nil :key nil)\n\nIssue: Macro call that should be transformed by EXECUTE", "input": "(execute nil :key nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(when 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WHEN", "input": "(when 'lol-gen::some-name)", "output": "(defmacro WHEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(untrace nil)\n\nWrite a macro that addresses: Macro call that should be transformed by UNTRACE", "input": "(untrace nil)", "output": "(defmacro UNTRACE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(check-declaration-env nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CHECK-DECLARATION-ENV", "input": "(check-declaration-env nil)", "output": "(defmacro CHECK-DECLARATION-ENV ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-language-macro nil)\n\nProblem: Macro call that should be transformed by DEFINE-LANGUAGE-MACRO", "input": "(define-language-macro nil)", "output": "(defmacro DEFINE-LANGUAGE-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-script-symbol-macro nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-SCRIPT-SYMBOL-MACRO", "input": "(define-script-symbol-macro nil)", "output": "(defmacro DEFINE-SCRIPT-SYMBOL-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(group-by nil)\n\nWrite a macro that addresses: Macro call that should be transformed by GROUP-BY", "input": "(group-by nil)", "output": "(defmacro GROUP-BY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defun* nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFUN*", "input": "(defun* nil\n (progn))", "output": "(defmacro DEFUN* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(eval-when-load\n common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by EVAL-WHEN-LOAD", "input": "(eval-when-load\n common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro EVAL-WHEN-LOAD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(gather-result 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by GATHER-RESULT", "input": "(gather-result 'lol-gen::some-name)", "output": "(defmacro GATHER-RESULT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(min-of nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MIN-OF", "input": "(min-of nil)", "output": "(defmacro MIN-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(select nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by SELECT", "input": "(select nil\n (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(producing nil (progn))\n\nProblem: Macro call that should be transformed by PRODUCING", "input": "(producing nil (progn))", "output": "(defmacro PRODUCING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-pp\n nil)\n\nIssue: Macro call that should be transformed by WITH-PP", "input": "(with-pp\n nil)", "output": "(defmacro with-pp (&body body)\n `(symbol-macrolet ((stream (get-stream-generic pp))\n\t\t (indent (get-indent-generic pp))\n\t\t (--indent (dec-indent-generic pp))\n\t\t (++indent (inc-indent-generic pp)))\n (macrolet ((push-sign (x) `(push-sign-generic pp ,x))\n\t\t(pop-sign () `(pop-sign-generic pp))\n\t\t(top-sign () `(top-sign-generic pp))\n\t\t(find-sign (x) `(find-sign-generic pp ,x))\n\t\t(push-info (x) `(push-info-generic pp ,x))\n\t\t(pop-info () `(pop-info-generic pp))\n\t\t(top-info () `(top-info-generic pp))\n\t\t(find-info (x) `(find-info-generic pp ,x))\n\t\t(info-size () `(info-size-generic pp))\n\t\t(node-slot (x) `(slot-value item ',x)))\n ,@body)))", "category": "anaphoric", "technique": "symbol-macrolet,macrolet,nested-backquote,anaphor", "complexity": "advanced", "quality_score": 0.9175} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ctypecase-of nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CTYPECASE-OF", "input": "(ctypecase-of nil\n :key\n nil)", "output": "(defmacro ctypecase-of (type keyplace &body body &environment env)\n \"Like `etypecase-of', but providing a `store-value' restart to correct KEYPLACE and try again.\"\n (check-exhaustiveness 'typecase type body env)\n `(ctypecase ,keyplace ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(without-symbol-access\n nil\n nil)\n\nIssue: Macro call that should be transformed by WITHOUT-SYMBOL-ACCESS", "input": "(without-symbol-access\n nil\n nil)", "output": "(defmacro WITHOUT-SYMBOL-ACCESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(class/std nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by CLASS/STD", "input": "(class/std nil\n nil)", "output": "(defmacro class/std (name &body defaulted-slots)\n \"The most concise shortcut macro to DEFCLASS.\n\n (class/std example slot1 slot2 slot3)\n\n expands to:\n\n (DEFCLASS/STD EXAMPLE ()\n ((SLOT1 SLOT2 SLOT3)))\n\n which expands to:\n\n (DEFCLASS EXAMPLE ()\n ((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL)\n (SLOT2 :ACCESSOR SLOT2 :INITARG :SLOT2 :INITFORM NIL)\n (SLOT3 :ACCESSOR SLOT3 :INITARG :SLOT3 :INITFORM NIL)))\n\"\n `(defclass/std ,name ()\n ((,@defaulted-slots))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(.< common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by .<", "input": "(.< common-lisp:nil)", "output": "(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))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(iter\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ITER", "input": "(iter\n 'lol-gen::some-name)", "output": "(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)))))))", "category": "anaphoric", "technique": "tagbody-go,gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda-ematch)\n\nIssue: Macro call that should be transformed by LAMBDA-EMATCH", "input": "(lambda-ematch)", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-hook-restart\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-HOOK-RESTART", "input": "(with-hook-restart\n nil\n (progn))", "output": "(defmacro with-hook-restart (&body body)\n `(with-simple-restart (continue \"Call next function in hook ~s\" *hook*)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(-<> nil)\n\nProblem: Macro call that should be transformed by -<>", "input": "(-<> nil)", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(def-suite* nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEF-SUITE*", "input": "(def-suite* nil (progn))", "output": "(defmacro def-suite* (name &rest def-suite-args)\n `(progn\n (def-suite ,name ,@def-suite-args)\n (in-suite ,name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(m nil)\n\nWrite a macro that addresses: Macro call that should be transformed by M", "input": "(m nil)", "output": "(defmacro M ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-fixture-restore nil\n nil)\n\nIssue: Macro call that should be transformed by DEFINE-FIXTURE-RESTORE", "input": "(define-fixture-restore nil\n nil)", "output": "(defmacro define-fixture-restore (name args &body body)\n `(progn (setf (gethash ',name *fixture-restores*)\n (lambda ,args ,@body))\n ',name))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c?n\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by C?N", "input": "(c?n\n nil\n :key\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-capped-stack nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-CAPPED-STACK", "input": "(with-capped-stack nil\n :key\n nil)", "output": "(defmacro with-capped-stack (() &body body)\n `(stack-capper (lambda () ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(block-compile nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by BLOCK-COMPILE", "input": "(block-compile nil\n :key\n nil)", "output": "(defmacro block-compile ((&key entry-points\n (block-compile t))\n &body body)\n \"Shorthand for block compilation with `local*'.\n\nOnly the functions in ENTRY-POINTS will have global definitions. All\nother functions in BODY will be compiled as purely local functions,\nand all of their calls to one another will be compiled as local calls.\nThis includes calls to the entry points, and even self-calls from\nwithin the entry points.\n\nNote that `declaim' forms occuring inside of BODY will be translated\ninto local `declare' forms.\n\nIf you pass `:block-compile nil', this macro is equivalent to progn.\nThis may be useful during development.\"\n (if (not block-compile) `(progn ,@body)\n `(local*\n ,@body\n (progn\n ,@(loop for entry-point in entry-points\n collect `(defalias ,entry-point #',entry-point))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(boolean-if nil nil)\n\nProblem: Macro call that should be transformed by BOOLEAN-IF", "input": "(boolean-if nil nil)", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-collectors nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-COLLECTORS", "input": "(with-collectors nil\n (progn))", "output": "(defmacro WITH-COLLECTORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(prependf nil :key nil)\n\nIssue: Macro call that should be transformed by PREPENDF", "input": "(prependf nil :key nil)", "output": "(defmacro PREPENDF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(*let 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by *LET", "input": "(*let 'lol-gen::some-name)", "output": "(defmacro *LET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH*", "input": "(with* nil\n (progn))", "output": "(defmacro WITH* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(comment)\n\nIssue: Macro call that should be transformed by COMMENT", "input": "(comment)", "output": "(defmacro comment (&body body)\n \"A macro that ignores its body and does nothing. Useful for\ncomments-by-example.\n\nAlso, as noted in EXTENSIONS.LISP of 1992, \\\"This may seem like a\nsilly macro, but used inside of other macros or code generation\nfacilities it is very useful - you can see comments in the (one-time)\nmacro expansion!\\\"\"\n (declare (ignore body)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.79} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(best-value nil nil)\n\nIssue: Macro call that should be transformed by BEST-VALUE", "input": "(best-value nil nil)", "output": "(defmacro BEST-VALUE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defalias nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFALIAS", "input": "(defalias nil\n nil)", "output": "(defmacro defalias (alias &body (def &optional docstring)\n &environment env)\n \"Define a value as a top-level function.\n\n (defalias string-gensym (compose #'gensym #'string))\n\nLike (setf (fdefinition ALIAS) DEF), but with a place to put\ndocumentation and some niceties to placate the compiler.\n\nNote that a function defined with `defalias' is declared `notinline'.\nThis is a matter of semantics: before we can assign to the function,\nwe must make it assignable (which is what `notinline' means).\n\nName from Emacs Lisp.\"\n `(progn\n (declaim (notinline ,alias))\n ,(multiple-value-bind (env decls lambda)\n (let-over-lambda def env)\n ;; If we can expand DEF into a lambda (possibly with some\n ;; variable bindings around it) then splice that lambda in\n ;; directly as the body of the function. (This is the same\n ;; function we use to resolve lambdas in `fbind'.)\n (if lambda\n (ematch lambda\n ((list* (and _ (eql 'lambda)) args body)\n `(let ,env\n (declare ,@decls)\n (defun ,alias ,args\n ,@(unsplice docstring)\n ,@body))))\n (with-unique-names (temp)\n `(let ((,temp (ensure-function ,def)))\n (declare (type function ,temp))\n ;; Give the function a temporary definition at\n ;; compile time so the compiler doesn't complain\n ;; about its being undefined.\n (defun ,alias (&rest args)\n (apply ,temp args))\n (setf (fdefinition ',alias) ,temp)\n ,@(unsplice\n (and docstring\n `(setf (documentation ',alias 'function) ,docstring)))))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(print-object/std nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PRINT-OBJECT/STD", "input": "(print-object/std nil)", "output": "(defmacro print-object/std (class)\n \"Old name for DEFINE-PRINT-OBJECT/STD.\"\n `(define-print-object/std ,class))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-shuffling\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WITH-SHUFFLING", "input": "(with-shuffling\n 'lol-gen::some-name)", "output": "(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))))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(or 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by OR", "input": "(or 'lol-gen::some-name)", "output": "(defmacro OR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(continue-whopper 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by CONTINUE-WHOPPER", "input": "(continue-whopper 'lol-gen::some-name)", "output": "(defmacro CONTINUE-WHOPPER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defvar* nil nil)\n\nProblem: Macro call that should be transformed by DEFVAR*", "input": "(defvar* nil nil)", "output": "(defmacro DEFVAR* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(psetq nil (progn))\n\nProblem: Macro call that should be transformed by PSETQ", "input": "(psetq nil (progn))", "output": "(defmacro PSETQ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(destructuring-bind () (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DESTRUCTURING-BIND", "input": "(destructuring-bind () (progn))", "output": "(defmacro DESTRUCTURING-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(awhen 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by AWHEN", "input": "(awhen 'lol-gen::some-name)", "output": "(defmacro AWHEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ftype 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by FTYPE", "input": "(ftype 'lol-gen::some-name)", "output": "(defmacro FTYPE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(without-c-dependency)\n\nProblem: Macro call that should be transformed by WITHOUT-C-DEPENDENCY", "input": "(without-c-dependency)", "output": "(defmacro without-c-dependency (&body body)\n ` (let (*depender*)\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-length nil)\n\nIssue: Macro call that should be transformed by COLLECT-LENGTH", "input": "(collect-length nil)", "output": "(defmacro COLLECT-LENGTH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(typecase nil)\n\nWhat needs to change: Macro call that should be transformed by TYPECASE", "input": "(typecase nil)", "output": "(defmacro TYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(local)\n\nWhat needs to change: Macro call that should be transformed by LOCAL", "input": "(local)", "output": "(defmacro LOCAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(def-fixture nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEF-FIXTURE", "input": "(def-fixture nil\n (progn))", "output": "(defmacro def-fixture (name (&rest args) &body body)\n \"Defines a fixture named NAME. A fixture is very much like a\nmacro but is used only for simple templating. A fixture created\nwith DEF-FIXTURE is a macro which can use the special macrolet\n&BODY to specify where the body should go.\n\nSee Also: WITH-FIXTURE\n\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (get-fixture ',name) (cons ',args ',body))\n ',name))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "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", "input": "(batch\n nil\n :key\n nil)", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defconstructor nil)\n\nWhat needs to change: Macro call that should be transformed by DEFCONSTRUCTOR", "input": "(defconstructor nil)", "output": "(defmacro defconstructor (type-name &body slots\n &environment env)\n \"A variant of `defstruct' for modeling immutable data.\n\nThe structure defined by `defconstructor' has only one constructor,\nwhich takes its arguments as required arguments (a BOA constructor).\nThus, `defconstructor' is only appropriate for data structures that\nrequire no initialization.\n\nThe printed representation of an instance resembles its constructor:\n\n (person \\\"Common Lisp\\\" 33)\n => (PERSON \\\"Common Lisp\\\" 33)\n\nWhile the constructor is BOA, the copier takes keyword arguments,\nallowing you to override the values of a selection of the slots of the\nstructure being copied, while retaining the values of the others.\n\n (defconstructor person\n (name string)\n (age (integer 0 1000)))\n\n (defun birthday (person)\n (copy-person person :age (1+ (person-age person))))\n\n (birthday (person \\\"Common Lisp\\\" 33))\n => (PERSON \\\"Common Lisp\\\" 34)\n\nObviously the copier becomes more useful the more slots the type has.\n\nWhen `*print-readably*' is true, the printed representation is\nreadable:\n\n (person \\\"Common Lisp\\\" 33)\n => #.(PERSON \\\"Common Lisp\\\" 33)\n\n\\(Why override how a structure is normally printed? Structure types\nare not necessarily readable unless they have a default \\(`make-X')\nconstructor. Since the type defined by `defconstructor' has only one\nconstructor, we have to take over to make sure it re-readable.)\n\nBesides being re-readable, the type is also externalizable, with a\nmethod for `make-load-form':\n\n (make-load-form (person \\\"Common Lisp\\\" 33))\n => (PERSON \\\"Common Lisp\\\" 33)\n\nUsers of Trivia get an extra benefit: defining a type with\n`defconstructor' also defines a symmetrical pattern for destructuring\nthat type.\n\n (trivia:match (person \\\"Common Lisp\\\" 33)\n ((person name age)\n (list name age)))\n => (\\\"Common Lisp\\\" 33)\n\nNote that the arguments to the pattern are optional:\n\n (trivia:match (person \\\"Common Lisp\\\" 33)\n ((person name) name))\n => \\\"Common Lisp\\\"\n\nIf you don't use Trivia, you can still do destructuring with\n`deconstruct', which returns the slots of a constructor as multiple\nvalues:\n\n (deconstruct (person \\\"Common Lisp\\\" 33))\n => \\\"Common Lisp\\\", 33\n\nNote also that no predicate is defined for the type, so to test for\nthe type you must either use `typep' or pattern matching as above.\n\nWhile it is possible to inherit from a type defined with\n`defconstructor' (this is Lisp, I can't stop you), it's a bad idea. In\nparticular, on Lisps which support it, a type defined with\n`defconstructor' is declared to be frozen (sealed), so your new\nsubtype may not be recognized in type tests that have already been\ncompiled.\n\nBecause `defconstructor' is implemented on top of\n`defstruct-read-only', it shares the limitations of\n`defstruct-read-only'. In particular it cannot use inheritance.\n\nThe design of `defconstructor' is mostly inspired by Scala's [case\nclasses](https://docs.scala-lang.org/tour/case-classes.html), with\nsome implementation tricks from `cl-algebraic-data-type'.\"\n (let* ((super (env-super env))\n (docstring\n (and (stringp (first slots))\n (pop slots)))\n (slots\n (loop for slot in slots\n collect (match slot\n ((list (and slot-name (type symbol))\n type)\n (list slot-name type))\n (otherwise\n (error \"Constructor slots must have both ~\n a name and a type.~%Constructor: ~a\"\n type-name)))))\n (constructor type-name)\n (slot-names (mapcar #'first slots))\n (readers\n (mapcar (curry #'symbolicate type-name '-)\n slot-names))\n (copier-name (symbolicate 'copy- type-name)))\n `(progn\n ;; Make sure the constructor is inlined. This is necessary on\n ;; SBCL to allow instances to be stack-allocated.\n (declaim (inline ,constructor))\n\n ;; Actually define the type.\n (defstruct-read-only\n (,type-name\n ,@(unsplice (and super `(:include ,super)))\n (:constructor ,constructor ,slot-names)\n (:predicate nil)\n (:print-function\n (lambda (object stream depth)\n (declare (ignore depth))\n ,(if (null readers)\n `(print-constructor object stream nil)\n (with-unique-names (fields)\n `(let ((,fields\n (list\n ,@(loop for reader in readers\n collect `(,reader object)))))\n (declare (dynamic-extent ,fields))\n (print-constructor object stream ,fields)))))))\n ,@(unsplice docstring)\n ,@(loop for (slot-name slot-type) in slots\n collect `(,slot-name :type ,slot-type)))\n\n ;; Freeze the type when possible.\n (declaim-freeze-type ,type-name)\n\n ;; Define the copier.\n (declaim (inline ,copier-name))\n ;; The gensym is needed in case one of the slots has the same\n ;; name as the type itself.\n ,(let ((orig (gensym (string type-name))))\n `(defun ,copier-name\n (,orig &key\n ,@(loop for (slot-name nil) in slots\n for reader in readers\n collect `(,slot-name (,reader ,orig))))\n ,(format nil \"Copy an instance of ~:@(~a~), optionally ~\noverriding some or all of its slots.\" type-name)\n (declare (ignorable ,orig))\n ;; A copier without slots should be identity.\n ,(if (null readers)\n orig\n `(,type-name ,@slot-names))))\n\n ;; Define a load form.\n (defmethod make-load-form ((self ,type-name) &optional env)\n (declare (ignorable self env))\n (list ',type-name\n ,@(loop for reader in readers\n collect `(quote-unless-constant (,reader self)\n env))))\n\n ;; Define a comparison method.\n (defmethod %constructor= ((o1 ,type-name) (o2 ,type-name))\n ,(if readers\n `(and ,@(loop for reader in readers\n collect `(constructor= (,reader o1)\n (,reader o2))))\n t))\n\n ;; Define a destructor.\n (defmethod constructor-values/generic ((x ,type-name))\n (values ,@(loop for reader in readers\n collect `(,reader x))))\n\n ;; Define a pattern to match.\n (defpattern ,type-name\n ,(if slot-names\n `(&optional ,@slot-names)\n ())\n (list\n 'and\n (list 'type ',type-name)\n ,@(loop for reader in readers\n for name in slot-names\n collect `(list 'trivia:access '',reader ,name))))\n ',type-name)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(aand nil nil)\n\nProblem: Macro call that should be transformed by AAND", "input": "(aand nil nil)", "output": "(defmacro aand (first &rest rest)\n \"Like AND, except binds the first argument to IT (via LET) for the\nscope of the rest of the arguments.\"\n `(anaphoric and ,first ,@rest))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(c?dbg\n nil)\n\nIssue: Macro call that should be transformed by C?DBG", "input": "(c?dbg\n nil)", "output": "(defmacro c?dbg (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :debug t\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(next-in nil)\n\nWhat needs to change: Macro call that should be transformed by NEXT-IN", "input": "(next-in nil)", "output": "(defmacro NEXT-IN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fbind* nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by FBIND*", "input": "(fbind* nil\n :key\n nil)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defgeneric nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DEFGENERIC", "input": "(defgeneric nil :key nil)", "output": "(defmacro DEFGENERIC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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 @", "input": "(@ nil nil)", "output": "(defmacro @ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c-input nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by C-INPUT", "input": "(c-input nil nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(possibly?\n nil)\n\nProblem: Macro call that should be transformed by POSSIBLY?", "input": "(possibly?\n nil)", "output": "(defmacro POSSIBLY? ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lret nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LRET", "input": "(lret nil\n :key\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-and 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by COLLECT-AND", "input": "(collect-and 'lol-gen::some-name)", "output": "(defmacro COLLECT-AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-ps-symbol-macro nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-PS-SYMBOL-MACRO", "input": "(define-ps-symbol-macro nil (progn))", "output": "(defmacro DEFINE-PS-SYMBOL-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(maybe-once-only nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by MAYBE-ONCE-ONLY", "input": "(maybe-once-only nil\n :key\n nil)", "output": "(defmacro MAYBE-ONCE-ONLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ignore-errors nil nil)\n\nIssue: Macro call that should be transformed by IGNORE-ERRORS", "input": "(ignore-errors nil nil)", "output": "(defmacro IGNORE-ERRORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(js-inline nil)\n\nProblem: Macro call that should be transformed by JS-INLINE", "input": "(js-inline nil)", "output": "(defmacro JS-INLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(def-suite* nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DEF-SUITE*", "input": "(def-suite* nil :key nil)", "output": "(defmacro def-suite* (name &rest def-suite-args)\n `(progn\n (def-suite ,name ,@def-suite-args)\n (in-suite ,name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defclause-sequence nil nil)\n\nProblem: Macro call that should be transformed by DEFCLAUSE-SEQUENCE", "input": "(defclause-sequence nil nil)", "output": "(defmacro DEFCLAUSE-SEQUENCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(without-symbol-access\n nil)\n\nIssue: Macro call that should be transformed by WITHOUT-SYMBOL-ACCESS", "input": "(without-symbol-access\n nil)", "output": "(defmacro WITHOUT-SYMBOL-ACCESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(char-ecase nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CHAR-ECASE", "input": "(char-ecase nil\n nil)", "output": "(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)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(sccase nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by SCCASE", "input": "(sccase nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(as->* nil)\n\nPattern to recognize: Macro call that should be transformed by AS->*", "input": "(as->* nil)", "output": "(defmacro AS->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-savepoint nil)\n\nProblem: Macro call that should be transformed by WITH-SAVEPOINT", "input": "(with-savepoint nil)", "output": "(defmacro with-savepoint (name &body body)\n \"Can only be used within a transaction. Establishes a savepoint with the given\nname at the start of body, and binds the same name to a handle for that savepoint.\nThe body is executed and, at the end of body, the savepoint is released, unless a\ncondition is thrown, in which case it is rolled back. Execute the body within a\nsavepoint, releasing savepoint when the body exits normally, and rolling back\notherwise. NAME is both the variable that can be used to release or rolled back\nbefore the body unwinds, and the SQL name of the savepoint.\n\nAn example might look like this:\n\n(defun test12 (x &optional (y nil))\n (with-logical-transaction (lt1 :read-committed-rw)\n (execute (:insert-into 'test-data :set 'value 0))\n (with-savepoint sp1\n (execute (:insert-into 'test-data :set 'value 1))\n (if (< x 0)\n (rollback-savepoint sp1)\n (release-savepoint sp1)))\n (with-savepoint sp2\n (execute (:insert-into 'test-data :set 'value 2))\n (with-savepoint sp3\n (execute (:insert-into 'test-data :set 'value 3))\n (if (> x 0)\n (rollback-savepoint sp3)\n (release-savepoint sp3))\n (when y (rollback-savepoint sp2)))\n (if (= x 0)\n (rollback-savepoint sp2)\n (release-savepoint sp2)))\n (when (string= y \\\"abrt\\\")\n (abort-transaction lt1))))\"\n\n `(call-with-savepoint ',name (lambda (,name)\n (declare (ignorable ,name)) ,@body)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda-bind 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by LAMBDA-BIND", "input": "(lambda-bind 'lol-gen::some-name)", "output": "(defmacro lambda-bind ((&rest instrs) &body body)\n \"Use `bind' to allow restructuring of argument to lambda expressions.\n\nThis lets you funcall and destructure simultaneously. For example\n\n (let ((fn (lambda-bind ((a b) c) (cons a c))))\n (funcall fn '(1 2) 3))\n ;; => (1 . 3)\n\nVia eschulte (see git://gist.github.com/902174.git).\n\"\n #+(or)\n (declare (indent 1))\n (let* ((evald-instrs instrs)\n (syms (mapcar (lambda (_)\n\t\t\t (declare (ignore _))\n\t\t\t (gensym))\n\t\t evald-instrs)))\n `(lambda ,syms (bind ,(mapcar #'list evald-instrs syms) ,@body))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(->>\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by ->>", "input": "(->>\n nil\n :key\n nil)", "output": "(defmacro ->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(letrec nil)\n\nPattern to recognize: Macro call that should be transformed by LETREC", "input": "(letrec nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(some-<>> nil)\n\nPattern to recognize: Macro call that should be transformed by SOME-<>>", "input": "(some-<>> nil)", "output": "(defmacro some-<>> (init &body exps) (diamond-wand init exps t t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-hook-type nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-HOOK-TYPE", "input": "(define-hook-type nil :key nil)", "output": "(defmacro define-hook-type (name type &optional documentation)\n \"Define hook class.\nType must be something like:\n\n (function (string) (values integer t))\n\nThe `handler-type' of the defined hook class has `:class' allocation\ntype, so that all hooks of such class have the same `handler-type'.\"\n (let* ((name (string name))\n (hook-class-name (intern (serapeum:concat \"HOOK-\" name))))\n `(defclass ,hook-class-name (hook)\n ((handler-type :initform ',type :allocation :class))\n (:metaclass closer-mop:funcallable-standard-class)\n ,@(when documentation\n `((:documentation ,documentation))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-active-layers nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-ACTIVE-LAYERS", "input": "(with-active-layers nil)", "output": "(defmacro WITH-ACTIVE-LAYERS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(<* nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by <*", "input": "(<* nil :key nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(is-values 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by IS-VALUES", "input": "(is-values 'lol-gen::some-name)", "output": "(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)))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(best-value nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by BEST-VALUE", "input": "(best-value nil :key nil)", "output": "(defmacro BEST-VALUE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(enable-interpol-syntax nil)\n\nIssue: Macro call that should be transformed by ENABLE-INTERPOL-SYNTAX", "input": "(enable-interpol-syntax nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda-cmatch1 common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-CMATCH1", "input": "(lambda-cmatch1 common-lisp:nil)", "output": "(defmacro lambda-cmatch1 (pattern &body body)\n \"Equivalent to (lambda (arg) (cmatch arg (PATTERN BODY...))).\"\n `(lambda-cmatch (,pattern ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-stemcell-infer-hook nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-STEMCELL-INFER-HOOK", "input": "(with-stemcell-infer-hook nil\n (progn))", "output": "(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)))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do-instance-combinations 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DO-INSTANCE-COMBINATIONS", "input": "(do-instance-combinations 'lol-gen::some-name)", "output": "(defmacro DO-INSTANCE-COMBINATIONS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(returning nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by RETURNING", "input": "(returning nil (progn))", "output": "(defmacro returning (&rest expressions)\n `(apply #'make-clause :returning\n (list ,@(mapcar (lambda (expr)\n (if (and (listp expr)\n (keywordp (car expr)))\n (expand-op expr)\n `,expr))\n expressions))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(destructuring-case-of nil\n nil)\n\nProblem: Macro call that should be transformed by DESTRUCTURING-CASE-OF", "input": "(destructuring-case-of nil\n nil)", "output": "(defmacro destructuring-case-of (type expr &body body)\n \"Like `destructuring-ecase-of', but an `otherwise' clause must also be supplied.\n\nNote that the otherwise clauses must also be a list:\n\n ((otherwise &rest args) ...)\"\n (expand-destructuring-case-of type expr body 'case-of))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fluid-bind nil)\n\nProblem: Macro call that should be transformed by FLUID-BIND", "input": "(fluid-bind nil)", "output": "(defmacro fluid-bind ((&rest bindings) &body body)\n \"Fluid-bind is an extension of bind that handles setting and resetting places. For example, suppose that an object of class foo has a slot named bar whose value is currently 3. The following code would evaluate the inner body with bar bound to 17 and restore it when the inner body is exited. \n\n\\(fluid-bind \\(\\(\\(bar foo\\) 17\\)\\)\n \\(print \\(bar foo\\)\\)\\)\n\\(print \\(bar foo\\)\\)\n==> \\(prints 17, then 3\\)\n\nThis is similar to dynamic-binding but _much_ less robust.\"\n ;; does not handle declarations correctly\n (let ((setup-forms nil)\n (cleanup-forms nil)\n (gensyms nil))\n (loop for binding in bindings collect\n (destructuring-bind \n\t\t(setup-form cleanup-form)\n\t (cond ((consp binding)\n\t\t (destructuring-bind (var value) binding\n\t\t (let ((g (gensym)))\n\t\t\t (push g gensyms)\n\t\t\t (cond ((atom var)\n\t\t\t\t`((:bind (,var ,value)) nil)\n\t\t\t\t#+(or)\n\t\t\t\t;; lexical or special?\n\t\t\t\t(if (boundp var)\n\t\t\t\t `((:bind (,var ,value)) nil)\n\t\t\t\t `((:setf (setf ,g ,var ,var ,value))\n\t\t\t\t (setf ,var ,g))))\n\t\t\t ((and (fboundp (first var))\n\t\t\t\t (not (eq (first var) 'values)))\n\t\t\t\t;; putative place\n\t\t\t\t`((:setf (setf ,g ,var ,var ,value))\n\t\t\t\t (setf ,var ,g)))\n\t\t\t (t\n\t\t\t\t`((:bind (,var ,value)) nil))))))\n\t\t (t\n\t\t `((:bind (,binding nil)) nil)))\n (push setup-form setup-forms)\n (push cleanup-form cleanup-forms)))\n (let ((result body))\n (mapc (lambda (setup cleanup)\n (setf result\n (ecase (first setup)\n (:setf `((unwind-protect\n (progn\n ,(second setup)\n ,@result)\n ,cleanup)))\n (:bind `((bind (,(second setup))\n ,@result)))))\n result)\n setup-forms cleanup-forms)\n `(let ,gensyms\n (declare (ignorable ,@gensyms))\n ,@result))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-walker-handler-lexical-environment\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT", "input": "(with-walker-handler-lexical-environment\n nil\n nil)", "output": "(defmacro WITH-WALKER-HANDLER-LEXICAL-ENVIRONMENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cmatch* common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by CMATCH*", "input": "(cmatch* common-lisp:nil\n (common-lisp:progn))", "output": "(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))))))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(destructuring-case-of nil\n (progn))\n\nProblem: Macro call that should be transformed by DESTRUCTURING-CASE-OF", "input": "(destructuring-case-of nil\n (progn))", "output": "(defmacro destructuring-case-of (type expr &body body)\n \"Like `destructuring-ecase-of', but an `otherwise' clause must also be supplied.\n\nNote that the otherwise clauses must also be a list:\n\n ((otherwise &rest args) ...)\"\n (expand-destructuring-case-of type expr body 'case-of))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-integrity nil (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-INTEGRITY", "input": "(with-integrity nil (progn))", "output": "(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)))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(local-output)\n\nIssue: Macro call that should be transformed by LOCAL-OUTPUT", "input": "(local-output)", "output": "(defmacro LOCAL-OUTPUT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(delete-from nil\n (progn))\n\nProblem: Macro call that should be transformed by DELETE-FROM", "input": "(delete-from nil\n (progn))", "output": "(defmacro delete-from (table &body clauses)\n `(make-statement :delete-from\n ,(expand-expression table) ,@clauses))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-special-initargs 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-SPECIAL-INITARGS", "input": "(with-special-initargs 'lol-gen::some-name)", "output": "(defmacro WITH-SPECIAL-INITARGS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-compilation-unit nil nil)\n\nIssue: Macro call that should be transformed by WITH-COMPILATION-UNIT", "input": "(with-compilation-unit nil nil)", "output": "(defmacro WITH-COMPILATION-UNIT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(where nil)\n\nProblem: Macro call that should be transformed by WHERE", "input": "(where nil)", "output": "(defmacro where (expression)\n `(make-clause :where\n ,(if (and (listp expression)\n (keywordp (car expression)))\n (expand-op expression)\n `,expression)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(and-bind nil)\n\nWhat needs to change: Macro call that should be transformed by AND-BIND", "input": "(and-bind nil)", "output": "(defmacro AND-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond-> 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by COND->", "input": "(cond-> 'lol-gen::some-name)", "output": "(defmacro COND-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(some->>\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SOME->>", "input": "(some->>\n nil\n (progn))", "output": "(defmacro SOME->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(drop-view 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DROP-VIEW", "input": "(drop-view 'lol-gen::some-name)", "output": "(defmacro drop-view (view-name)\n `(make-statement :drop-view ,view-name))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(coercef nil nil)\n\nProblem: Macro call that should be transformed by COERCEF", "input": "(coercef nil nil)", "output": "(defmacro COERCEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(tree-ecase nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by TREE-ECASE", "input": "(tree-ecase nil\n nil)", "output": "(defmacro TREE-ECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(char-case nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by CHAR-CASE", "input": "(char-case nil\n (progn))", "output": "(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)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c-abs nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by C-ABS", "input": "(c-abs nil\n :key\n nil)", "output": "(defmacro c-abs (value &body body)\n `(make-c-drifter-absolute\n :code ',body\n :value-state :valid\n :value ,value\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nlet nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by NLET", "input": "(nlet nil\n (progn))", "output": "(defmacro NLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(some->>)\n\nProblem: Macro call that should be transformed by SOME->>", "input": "(some->>)", "output": "(defmacro SOME->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-declaration nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-DECLARATION", "input": "(define-declaration nil\n :key\n nil)", "output": "(defmacro DEFINE-DECLARATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(op\n nil)\n\nIssue: Macro call that should be transformed by OP", "input": "(op\n nil)", "output": "(defmacro op (&body body &environment env)\n \"GOO's simple macro for positional lambdas.\n\nAn OP is like a lambda without an argument list. Within the body of the OP\nform, an underscore introduces a new argument.\n\n (reduce (op (set-intersection _ _ :test #'equal))\n sets)\n\nYou can refer back to each argument by number, starting with _1.\n\n (funcall (op (+ _ _1)) 2) => 4\n\nYou can also use positional arguments directly:\n\n (reduce (op (funcall _2 _1)) ...)\n\nArgument lists can be sparse:\n\n (apply (op (+ _1 _3 _5)) '(1 2 3 4 5)) => 9\n\nNote that OP with a single argument is equivalent to CONSTANTLY:\n\n (funcall (op 1)) => 1\n\nand that OP with a single placeholder is equivalent to IDENTITY:\n\n (funcall (op _) 1) => 1\n\nOP can also be used to define variadic functions by using _* as the\nplaceholder. It is not necessary to use APPLY.\n\n (apply (op (+ _*)) '(1 2 3 4)) => 10\n\nOP is intended for simple functions -- one-liners. Parameters are\nextracted according to a depth-first walk of BODY. Macro expansion\nmay, or may not, be done depending on the implementation; it should\nnot be relied on. Lexical bindings may, or may not, shadow\nplaceholders -- again, it depends on the implementation. (This means,\namong other things, that nested use of `op' is not a good idea.)\nBecause of the impossibility of a truly portable code walker, `op'\nwill never be a true replacement for `lambda'. But even if it were\npossible to do better, `op' would still only be suited for one-liners.\nIf you need more than a one-liner, then you should be giving your\nparameters names.\n\n\\(One thing you *can* count on is the ability to use `op' with\nquasiquotes. If using placeholders inside quasiquotes does not work on\nyour Lisp implementation, that's a bug, not a limitation.)\"\n (let ((env (extract-op-env body env)))\n (op-env-lambda env)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(unless nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by UNLESS", "input": "(unless nil :key nil)", "output": "(defmacro UNLESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(builder nil (progn))\n\nWhat needs to change: Macro call that should be transformed by BUILDER", "input": "(builder nil (progn))", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(check-type nil :key nil)\n\nIssue: Macro call that should be transformed by CHECK-TYPE", "input": "(check-type nil :key nil)", "output": "(defmacro CHECK-TYPE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dletf nil\n (progn))\n\nIssue: Macro call that should be transformed by DLETF", "input": "(dletf nil\n (progn))", "output": "(defmacro DLETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(assuref nil nil)\n\nIssue: Macro call that should be transformed by ASSUREF", "input": "(assuref nil nil)", "output": "(defmacro assuref (place type-spec)\n \"Like `(progn (check-type PLACE TYPE-SPEC) PLACE)`, but evaluates\nPLACE only once.\"\n (with-gensyms (temp)\n (let ((ts type-spec))\n `(the ,ts\n (values\n (let ((,temp ,place))\n (if (typep ,temp ',ts)\n ,temp\n (setf ,place (require-type-for ,temp ',ts ',place)))))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(enable-quasi-quoted-string-to-string-emitting-form-syntax nil)\n\nPattern to recognize: Macro call that should be transformed by ENABLE-QUASI-QUOTED-STRING-TO-STRING-EMITTING-FORM-SYNTAX", "input": "(enable-quasi-quoted-string-to-string-emitting-form-syntax nil)", "output": "(defmacro ENABLE-QUASI-QUOTED-STRING-TO-STRING-EMITTING-FORM-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-access-values nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-ACCESS-VALUES", "input": "(with-access-values nil\n :key\n nil)", "output": "(defmacro with-access-values ((&rest bindings) obj &body body)\n \"A macro which binds local variables from accessed values on object\n according to bindings\n\n bindings: (local-symbol-and-access-key\n or (local-symbol access-key)\n ...)\n obj: the thing we are accessing data from\n \"\n (flet ((key-for (it)\n (etypecase it\n (symbol `(quote ,it))\n ((or string keyword list) it))))\n (let* ((o (gensym \"OBJ\"))\n (expanded-bindings\n (iter (for b in (ensure-list bindings))\n (when (first-iteration-p)\n (collect `(,o ,obj)))\n (typecase b\n (null)\n (list (collect `(,(first b) (access ,o ,(key-for (second b))))))\n (symbol (collect `(,b (access ,o ,(key-for b)))))))))\n `(let* ,expanded-bindings\n ,@body))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-unique-js-names nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-UNIQUE-JS-NAMES", "input": "(with-unique-js-names nil)", "output": "(defmacro WITH-UNIQUE-JS-NAMES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n;; Threading a value through multiple dependent checks\n(let ((user (find-user id)))\n (if user\n (let ((orders (get-orders user)))\n (if orders\n (let ((latest (first orders)))\n (if latest\n (process latest)\n :no-orders))\n :no-orders))\n :no-user))\n;; Deeply nested ifs obscure the linear flow\n\nIssue: Threading a value through dependent operations creates deep if-nesting \u2014 want linear, pipeline-like syntax", "input": ";; Threading a value through multiple dependent checks\n(let ((user (find-user id)))\n (if user\n (let ((orders (get-orders user)))\n (if orders\n (let ((latest (first orders)))\n (if latest\n (process latest)\n :no-orders))\n :no-orders))\n :no-user))\n;; Deeply nested ifs obscure the linear flow", "output": "(defmacro aand (&rest args)\n (cond ((null args) t)\n ((null (cdr args)) (car args))\n (t `(aif ,(car args) (aand ,@(cdr args))))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-keys nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-KEYS", "input": "(with-keys nil\n (progn))", "output": "(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)))", "category": "dsl", "technique": "once-only,nested-backquote", "complexity": "intermediate", "quality_score": 0.8725} {"instruction": "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", "input": "(with-string-dispatch nil\n (progn))", "output": "(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))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(maybe-once-only 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by MAYBE-ONCE-ONLY", "input": "(maybe-once-only 'lol-gen::some-name)", "output": "(defmacro MAYBE-ONCE-ONLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(n^ 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by N^", "input": "(n^ 'lol-gen::some-name)", "output": "(defmacro n^ (type)\n `(nearest self ,type))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defgenerator nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFGENERATOR", "input": "(defgenerator nil\n (progn))", "output": "(defmacro defgenerator (name arguments &body body)\n (multiple-value-bind (remaining-forms declarations doc-string)\n (alexandria:parse-body body :documentation t)\n `(defun ,name ,arguments\n ,doc-string\n ,@declarations\n (with-yield\n\t ,@remaining-forms))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(econd)\n\nWhat needs to change: Macro call that should be transformed by ECOND", "input": "(econd)", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(aif nil nil)\n\nIssue: Macro call that should be transformed by AIF", "input": "(aif nil nil)", "output": "(defmacro AIF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-collectors nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-COLLECTORS", "input": "(with-collectors nil\n nil)", "output": "(defmacro WITH-COLLECTORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(bcond\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by BCOND", "input": "(bcond\n 'lol-gen::some-name)", "output": "(defmacro bcond (&body clauses)\n \"Scheme's extended COND.\n\nThis is exactly like COND, except for clauses having the form\n\n (test :=> recipient)\n\nIn that case, if TEST evaluates to a non-nil result, then RECIPIENT, a\nfunction, is called with that result, and the result of RECIPIENT is\nreturn as the value of the `cond`.\n\nAs an extension, a clause like this:\n\n (test :=> var ...)\n\nCan be used as a shorthand for\n\n (test :=> (lambda (var) ...))\n\nThe name `bcond' for a \u201cbinding cond\u201d goes back at least to the days\nof the Lisp Machines. I do not know who was first to use it, but the\noldest examples I have found are by Michael Parker and Scott L.\nBurson.\"\n (flet ((send-clause? (clause)\n (let ((second (second clause)))\n (and (symbolp second)\n (string= second :=>))))\n (parse-send-clause (clause)\n (destructuring-bind (test => . body) clause\n (declare (ignore =>))\n (cond ((null body) (error \"Missing clause\"))\n ((null (rest body))\n (values test (car body)))\n (t (destructuring-bind (var . body) body\n (let ((fn `(lambda (,var) ,@body)))\n (values test fn))))))))\n ;; Note that we expand into `cond' rather than `if' so we don't\n ;; have to handle tests without bodies.\n (cond ((null clauses) nil)\n ((member-if #'send-clause? clauses)\n (let* ((tail (member-if #'send-clause? clauses))\n (preceding (ldiff clauses tail))\n (clause (car tail))\n (clauses (cdr tail)))\n (multiple-value-bind (test fn)\n (parse-send-clause clause)\n (with-gensyms (tmp)\n `(cond ,@preceding\n (t (if-let1 ,tmp ,test\n (funcall ,fn ,tmp)\n (bcond ,@clauses))))))))\n (t `(cond ,@clauses)))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(brkx 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by BRKX", "input": "(brkx 'lol-gen::some-name)", "output": "(defmacro brkx (msg)\n `(break \"At ~a: OK?\" ',msg))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(when-failing nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WHEN-FAILING", "input": "(when-failing nil\n :key\n nil)", "output": "(defmacro WHEN-FAILING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defpattern-inline common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by DEFPATTERN-INLINE", "input": "(defpattern-inline common-lisp:nil\n (common-lisp:progn))", "output": "(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))))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(once-only nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by ONCE-ONLY", "input": "(once-only nil\n (progn))", "output": "(defmacro once-only (specs &body forms)\n \"Evaluate FORMS with names rebound to temporary variables, ensuring\n that each is evaluated only once.\n\n Each SPEC must be either a NAME, or a (NAME INITFORM), with plain\n NAME using the named variable as initform.\n\n Example:\n\n CL-USER> (defmacro cons1 (x)\n (once-only (x)\n `(cons ,x ,x)))\n CL-USER> (let ((y 0))\n (cons1 (incf y)))\n (1 . 1)\n\"\n (let ((gensyms (make-gensym-list (length specs) \"OO\"))\n (names-and-forms (mapcar (lambda (spec)\n (etypecase spec\n (list\n (destructuring-bind (name form) spec\n (cons name form)))\n (symbol\n (cons spec spec))))\n (remove-if-not #`(or (symbolp %) (listp %))\n specs))))\n ;; bind in user-macro\n `(let ,(mapcar #`(list % `(gensym ,(string (car %%))))\n gensyms names-and-forms)\n ;; bind in final expansion\n `(let (,,@(mapcar (lambda (g n) ``(,,g ,,(cdr n)))\n gensyms names-and-forms))\n ;; bind in user-macro\n ,(let ,(mapcar #`(list (car %) %%)\n names-and-forms gensyms)\n ,@forms)))))", "category": "control-flow", "technique": "once-only,gensym,nested-backquote,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(dlet* nil\n (progn))\n\nProblem: Macro call that should be transformed by DLET*", "input": "(dlet* nil\n (progn))", "output": "(defmacro DLET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-unbuilder 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-UNBUILDER", "input": "(with-unbuilder 'lol-gen::some-name)", "output": "(defmacro WITH-UNBUILDER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(fbind* 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by FBIND*", "input": "(fbind* 'lol-gen::some-name)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(do () (progn))\n\nProblem: Macro call that should be transformed by DO", "input": "(do () (progn))", "output": "(defmacro DO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(multiple-value-list nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MULTIPLE-VALUE-LIST", "input": "(multiple-value-list nil)", "output": "(defmacro MULTIPLE-VALUE-LIST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(export-accessors)\n\nPattern to recognize: Macro call that should be transformed by EXPORT-ACCESSORS", "input": "(export-accessors)", "output": "(defmacro EXPORT-ACCESSORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-parse-method nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-PARSE-METHOD", "input": "(define-parse-method nil\n nil)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make-name-transformer 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by MAKE-NAME-TRANSFORMER", "input": "(make-name-transformer 'lol-gen::some-name)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(setf nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SETF", "input": "(setf nil (progn))", "output": "(defmacro SETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(loop)\n\nIssue: Macro call that should be transformed by LOOP", "input": "(loop)", "output": "(defmacro LOOP ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(match 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by MATCH", "input": "(match 'lol-gen::some-name)", "output": "(defmacro MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda-match*\n common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by LAMBDA-MATCH*", "input": "(lambda-match*\n common-lisp:nil\n common-lisp:nil)", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Generate a defmacro form that transforms code like this:\n(custom-decoder 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by CUSTOM-DECODER", "input": "(custom-decoder 'lol-gen::some-name)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(case nil)\n\nPattern to recognize: Macro call that should be transformed by CASE", "input": "(case nil)", "output": "(defmacro CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(aand nil :key nil)\n\nProblem: Macro call that should be transformed by AAND", "input": "(aand nil :key nil)", "output": "(defmacro AAND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fm-other? nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by FM-OTHER?", "input": "(fm-other? nil :key nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(case nil)\n\nPattern to recognize: Macro call that should be transformed by CASE", "input": "(case nil)", "output": "(defmacro CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(decf 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DECF", "input": "(decf 'lol-gen::some-name)", "output": "(defmacro DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(alter-table nil\n nil)\n\nIssue: Macro call that should be transformed by ALTER-TABLE", "input": "(alter-table nil\n nil)", "output": "(defmacro alter-table (table &body clauses)\n `(make-statement :alter-table\n ,(expand-expression table) ,@clauses))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-active-layers* nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-ACTIVE-LAYERS*", "input": "(with-active-layers* nil\n :key\n nil)", "output": "(defmacro WITH-ACTIVE-LAYERS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(c?? nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by C??", "input": "(c?? nil\n :key\n nil)", "output": "(defmacro c?? ((&key (tagp nil) (in nil) (out t))&body body)\n (let ((result (copy-symbol 'result))\n (thetag (gensym)))\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :rule (c-lambda\n (let ((,thetag (gensym \"tag\"))\n (*trcdepth* (1+ *trcdepth*))\n )\n (declare (ignorable self ,thetag))\n ,(when in\n `(trc \"c??> entry\" (c-slot-name c) (c-model c) (when ,tagp ,thetag)))\n (count-it :c?? (c-slot-name c) (md-name (c-model c)))\n (let ((,result (progn ,@body)))\n ,(when out `(trc \"c?? result:\" ,result (c-slot-name c) (when ,tagp ,thetag)))\n ,result))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-accessors nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-ACCESSORS", "input": "(with-accessors nil\n :key\n nil)", "output": "(defmacro WITH-ACCESSORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH", "input": "(with nil\n (progn))", "output": "(defmacro WITH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(special common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SPECIAL", "input": "(special common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro SPECIAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(optional common-lisp:nil (common-lisp:progn))\n\nIssue: Macro call that should be transformed by OPTIONAL", "input": "(optional common-lisp:nil (common-lisp:progn))", "output": "(defmacro OPTIONAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(html)\n\nWhat needs to change: Macro call that should be transformed by HTML", "input": "(html)", "output": "(defmacro html (&rest tags)\n `(with-doctype :html\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fdec nil (progn))\n\nIssue: Macro call that should be transformed by FDEC", "input": "(fdec nil (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(and-it nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AND-IT", "input": "(and-it nil :key nil)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(iterate 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ITERATE", "input": "(iterate 'lol-gen::some-name)", "output": "(defmacro ITERATE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(callf nil (progn))\n\nIssue: Macro call that should be transformed by CALLF", "input": "(callf nil (progn))", "output": "(defmacro callf (function place &rest args &environment env)\n \"Set PLACE to the value of calling FUNCTION on PLACE, with ARGS.\"\n (multiple-value-bind (vars vals stores setter getter)\n (get-setf-expansion place env)\n `(let* ,(mapcar #'list vars vals)\n (multiple-value-bind ,stores\n (funcall ,function ,getter ,@args)\n ,setter))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda-match*\n common-lisp:nil\n (common-lisp:progn))\n\nProblem: Macro call that should be transformed by LAMBDA-MATCH*", "input": "(lambda-match*\n common-lisp:nil\n (common-lisp:progn))", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-symbol-access\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-SYMBOL-ACCESS", "input": "(with-symbol-access\n nil\n nil)", "output": "(defmacro WITH-SYMBOL-ACCESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(*> nil)\n\nWhat needs to change: Macro call that should be transformed by *>", "input": "(*> nil)", "output": "(defmacro *> (parser &rest parsers)\n \"Combination of parsers yielding the result of the rightmost one.\"\n (let ((offset (gensym \"*>-OFFSET\")))\n `(lambda (,offset)\n ,(reduce (lambda (i p)\n (let ((res (gensym \"*>-RES\"))\n (next (gensym \"*>-NEXT\")))\n `(multiple-value-bind (,res ,next) ,i\n (if (ok? ,res)\n (funcall ,p ,next)\n (fail ,next)))))\n parsers\n :initial-value `(funcall ,parser ,offset)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fail nil (progn))\n\nWhat needs to change: Macro call that should be transformed by FAIL", "input": "(fail nil (progn))", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(is-true nil)\n\nWhat needs to change: Macro call that should be transformed by IS-TRUE", "input": "(is-true nil)", "output": "(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)))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(auto-permute-typecase nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by AUTO-PERMUTE-TYPECASE", "input": "(auto-permute-typecase nil\n (progn))", "output": "(defmacro AUTO-PERMUTE-TYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-generator 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-GENERATOR", "input": "(with-generator 'lol-gen::some-name)", "output": "(defmacro WITH-GENERATOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(subtest 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by SUBTEST", "input": "(subtest 'lol-gen::some-name)", "output": "(defmacro subtest (desc &body body)\n `(%subtest ,desc (lambda () ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(enable-static-dispatch)\n\nWrite a macro that addresses: Macro call that should be transformed by ENABLE-STATIC-DISPATCH", "input": "(enable-static-dispatch)", "output": "(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))))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.79} {"instruction": "Generate a defmacro form that transforms code like this:\n(static-load-time-value nil)\n\nPattern to recognize: Macro call that should be transformed by STATIC-LOAD-TIME-VALUE", "input": "(static-load-time-value nil)", "output": "(defmacro static-load-time-value\n (form &optional (read-only-p nil read-only-p-supplied?))\n \"Like `load-time-value', but signals an error if it cannot preserve identity.\n\nOn close reading of the standard, in a function that is evaluated but\nnot compiled, it is permissible for implementations to repeatedly\nexecute a `load-time-value' form, and in fact some implementations do\nthis \\(including, at the time of writing, ABCL, CLISP, Allegro and\nLispWorks).\n\nWhen `static-load-time-value' is compiled, it behaves exactly like\n`load-time-value'. Otherwise it conducts a run-time check to ensure\nthat `load-time-value' preserves identity.\"\n ;; Thanks to Jean-Philippe Paradis and Micha\u0142 Herda for helping to\n ;; diagnose and treat the problem here.\n (if *compile-file-truename*\n `(load-time-value ,form\n ,@(and read-only-p-supplied? (list read-only-p)))\n `(progn\n (flet ((fn () (load-time-value (random most-positive-fixnum))))\n (declare (dynamic-extent #'fn) (ignorable #'fn)\n #+LispWorks (notinline fn))\n ;; Do the actual test out of line.\n (test-load-time-value #'fn ',form ',read-only-p))\n (load-time-value ,form\n ,@(and read-only-p-supplied? (list read-only-p))))))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8724999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(aand nil (progn))\n\nIssue: Macro call that should be transformed by AAND", "input": "(aand nil (progn))", "output": "(defmacro AAND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defiter nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFITER", "input": "(defiter nil\n nil)", "output": "(defmacro DEFITER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(do+\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DO+", "input": "(do+\n nil\n :key\n nil)", "output": "(defmacro do+ (&body body)\n \"High-level, extensible iteration construct. Refer to the manual for syntax and semantics.\"\n `(do+/internal nil ,@body))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(incf nil nil)\n\nWhat needs to change: Macro call that should be transformed by INCF", "input": "(incf nil nil)", "output": "(defmacro INCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(letrec nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by LETREC", "input": "(letrec nil\n (progn))", "output": "(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))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c-envalue\n nil)\n\nProblem: Macro call that should be transformed by C-ENVALUE", "input": "(c-envalue\n nil)", "output": "(defmacro c-envalue (&body body)\n `(make-c-envaluer\n :envalue-rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-transaction nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-TRANSACTION", "input": "(with-transaction nil\n (progn))", "output": "(defmacro with-transaction ((&optional name isolation-level) &body body)\n \"Execute the given body within a database transaction, committing it when the\nbody exits normally, and aborting otherwise. An optional name and/or\nisolation-level can be given to the transaction. The name can be used to force\na commit or abort before the body unwinds. The isolation-level will set the\nisolation-level used by the 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 quoted\nor a string) and ... simply indicates other statements would be expected here:\n\n (with-transaction ()\n (execute (:insert-into 'test-data :set 'value 77))\n ...)\n\n (with-transaction (george)\n (execute (:insert-into 'test-data :set 'value 22))\n ...)\n\n (with-transaction (george :read-committed-rw)\n (execute (:insert-into 'test-data :set 'value 33))\n (query (:select '* :from 'test-data))\n ...)\n\n (with-transaction (:serializable)\n (execute (:insert-into 'test-data :set 'value 44))\n ...)\n\nFurther discussion of transactions and isolation levels can found in the\nisolation notes file in the doc folder.\"\n (let ((transaction-name (or (when (not (isolation-level-p name))\n name)\n (gensym \"anonymous-transaction\"))))\n (when (and name (isolation-level-p name))\n (setf isolation-level name))\n `(call-with-transaction (lambda (,transaction-name)\n (declare (ignorable ,transaction-name)) ,@body)\n ,isolation-level)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-vari-compiler-macro nil\n nil)\n\nProblem: Macro call that should be transformed by DEFINE-VARI-COMPILER-MACRO", "input": "(define-vari-compiler-macro nil\n nil)", "output": "(defmacro define-vari-compiler-macro (name lambda-list &body body)\n (check-args-for-constant-names :compiler-macro name lambda-list)\n (labels ((namedp (name x)\n (when (symbolp x)\n (string= name x)))\n (maybe-nth (n x)\n (if (listp x) (nth n x) x)))\n (when (find-if \u03bb(namedp :&uniforms _) lambda-list)\n (error 'uniform-in-cmacro :name name))\n (when (find-if \u03bb(namedp :&shared _) lambda-list)\n (error 'shared-in-cmacro :name name))\n (when (find-if \u03bb(namedp :&optional _) lambda-list)\n (error 'optional-in-cmacro :name name))\n (when (find-if \u03bb(namedp :&key _) lambda-list)\n (error 'key-in-cmacro :func-name name))\n ;;\n (let ((llist (mapcar \u03bb(if (listp _) (first _) _) lambda-list)))\n (vbind (func-code context) (gen-macro-function-code name llist body)\n (let* ((args (nth-value 1 (extract-arg-pair lambda-list :&whole)))\n (args (nth-value 1 (extract-arg-pair args :&environment)))\n (arg-names (mapcar \u03bb(maybe-nth 0 _) args))\n (arg-types (mapcar \u03bb(arg-form->type (maybe-nth 1 _)) args)))\n `(progn\n (add-global-compiler-macro\n (make-compiler-macro ',name ,func-code ',arg-names ',arg-types\n ',context))\n ',name))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(static-let* nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by STATIC-LET*", "input": "(static-let* nil\n nil)", "output": "(defmacro static-let* ((&rest bindings) &body body &environment env)\n \"Like `let*', except the variables are only initialized once and\nretain their values between different invocations of `body'.\n\nEvery static binding is similar to a `let' binding, except it can have\nadditional keyword arguments:\n\n- `type' Denotes the type of the variable.\n- `once' If true, then binding initialization and mutation will be\n thread-safe.\n- `flush' If true, this binding will be flushable. Defaults to true.\n- `in' Denotes the static binding group in which the binding will be\n placed for flushing. Defaults to the value of `*package'.\n- `read-only' If true, then the binding cannot be mutated with `setf'.\n\nStatic bindings can be flushed via `flush-static-binding-group' and\n`flush-all-static-binding-groups'; the latter is automatically pushed\ninto `uiop:*dump-image-hooks*' by Serapeum.\n\nAn unflushable static binding will carry its value over into dumped\nLisp binaries.\"\n (parse-static-let* bindings body env))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8724999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ensure-functionf nil nil)\n\nIssue: Macro call that should be transformed by ENSURE-FUNCTIONF", "input": "(ensure-functionf nil nil)", "output": "(defmacro ensure-functionf (&rest places)\n \"Multiple-place modify macro for ENSURE-FUNCTION: ensures that each of\nPLACES contains a function.\"\n `(progn ,@(mapcar (lambda (x) `(ensure-functionf/1 ,x)) places)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defoptimizer common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by DEFOPTIMIZER", "input": "(defoptimizer common-lisp:nil\n (common-lisp:progn))", "output": "(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))))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(shift-decf nil (progn))\n\nProblem: Macro call that should be transformed by SHIFT-DECF", "input": "(shift-decf nil (progn))", "output": "(defmacro SHIFT-DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(pass)\n\nPattern to recognize: Macro call that should be transformed by PASS", "input": "(pass)", "output": "(defmacro pass (&rest message-args)\n \"Simply generate a PASS.\"\n `(add-result 'test-passed\n :test-expr ',message-args\n ,@(when message-args\n `(:reason (format nil ,@message-args)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(psetf nil (progn))\n\nIssue: Macro call that should be transformed by PSETF", "input": "(psetf nil (progn))", "output": "(defmacro PSETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(flet* nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by FLET*", "input": "(flet* nil\n nil)", "output": "(defmacro FLET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(multiple-value-prog2 nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by MULTIPLE-VALUE-PROG2", "input": "(multiple-value-prog2 nil\n (progn))", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(raw nil nil)\n\nWhat needs to change: Macro call that should be transformed by RAW", "input": "(raw nil nil)", "output": "(defmacro raw (&rest forms)\n `(list ,@forms))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n;; eval loses lexical environment - can't access surrounding bindings\n(let ((x 1))\n (eval '(+ 1 x))) ;; Error: X is unbound!\n\n;; Need: way to tunnel lexical variables into eval\n\nWhat needs to change: eval cannot access lexical environment \u2014 want a 'tunnel' that bridges lexical scope into eval's dynamic world", "input": ";; eval loses lexical environment - can't access surrounding bindings\n(let ((x 1))\n (eval '(+ 1 x))) ;; Error: X is unbound!\n\n;; Need: way to tunnel lexical variables into eval", "output": "(defvar pandoric-eval-tunnel)\n\n(defmacro pandoric-eval (vars expr)\n `(let ((pandoric-eval-tunnel\n (plambda () ,vars t)))\n (eval `(with-pandoric\n ,',vars pandoric-eval-tunnel\n ,,expr))))", "category": "scope", "technique": "dlambda,symbol-macrolet", "complexity": "advanced", "quality_score": 0.9824999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(if-not nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IF-NOT", "input": "(if-not nil nil)", "output": "(defmacro if-not (test then &optional else)\n \"If TEST evaluates to NIL, evaluate THEN and return its values,\notherwise evaluate ELSE and return its values. ELSE defaults to NIL.\"\n `(if (not ,test)\n ,then\n ,else))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(wtrc nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WTRC", "input": "(wtrc nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(xml nil)\n\nProblem: Macro call that should be transformed by XML", "input": "(xml nil)", "output": "(defmacro xml (&rest tags)\n `(with-doctype :xml\n (loop for tag in ',tags\n append (tag->string tag))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-global-parameter nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-GLOBAL-PARAMETER", "input": "(define-global-parameter nil (progn))", "output": "(defmacro DEFINE-GLOBAL-PARAMETER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cond->> 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COND->>", "input": "(cond->> 'lol-gen::some-name)", "output": "(defmacro cond->> (init &body exps) (cond-arrow-macro init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(sccase nil\n nil)\n\nIssue: Macro call that should be transformed by SCCASE", "input": "(sccase nil\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(dletf* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DLETF*", "input": "(dletf* nil\n (progn))", "output": "(defmacro DLETF* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-active-layers nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITH-ACTIVE-LAYERS", "input": "(with-active-layers nil\n :key\n nil)", "output": "(defmacro WITH-ACTIVE-LAYERS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make nil (progn))\n\nWhat needs to change: Macro call that should be transformed by MAKE", "input": "(make nil (progn))", "output": "(defmacro MAKE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ok nil nil)\n\nIssue: Macro call that should be transformed by OK", "input": "(ok nil nil)", "output": "(defmacro ok (offset value)\n \"Parsing was successful.\"\n `(values ,value ,offset))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(eval-and-compile\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by EVAL-AND-COMPILE", "input": "(eval-and-compile\n 'lol-gen::some-name)", "output": "(defmacro eval-and-compile (&body body)\n \"Emacs's `eval-and-compile'.\nAlias for `eval-always'.\"\n `(eval-always\n ,@body))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(jor nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by JOR", "input": "(jor nil (progn))", "output": "(defmacro jor (&rest args)\n \"JSON-aware version of `cl:or'.\"\n `(or ,@(loop for arg in args\n collecting `(jwhen ,arg ,arg))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(nth-value-or nil\n nil)\n\nProblem: Macro call that should be transformed by NTH-VALUE-OR", "input": "(nth-value-or nil\n nil)", "output": "(defmacro nth-value-or (nth-value &body forms)\n \"Evaluates FORM arguments one at a time, until the NTH-VALUE returned by one\nof the forms is true. It then returns all the values returned by evaluating\nthat form. If none of the forms return a true nth value, this form returns\nNIL.\"\n (once-only (nth-value)\n (with-gensyms (values)\n `(let ((,values (multiple-value-list ,(first forms))))\n (if (nth ,nth-value ,values)\n (values-list ,values)\n ,(if (rest forms)\n `(nth-value-or ,nth-value ,@(rest forms))\n nil))))))", "category": "anaphoric", "technique": "once-only,gensym,anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(summing-to-and-returning nil)\n\nWhat needs to change: Macro call that should be transformed by SUMMING-TO-AND-RETURNING", "input": "(summing-to-and-returning nil)", "output": "(defmacro SUMMING-TO-AND-RETURNING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-hash-table-iterator 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-HASH-TABLE-ITERATOR", "input": "(with-hash-table-iterator 'lol-gen::some-name)", "output": "(defmacro WITH-HASH-TABLE-ITERATOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-transaction 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-TRANSACTION", "input": "(with-transaction 'lol-gen::some-name)", "output": "(defmacro with-transaction (conn &body body)\n \"Start a transaction and commit at the end of this block. If the evaluation `body` is interrupted, the transaction is rolled back automatically.\"\n (let ((conn-var (gensym \"CONN-VAR\")))\n `(let ((,conn-var ,conn))\n (if (in-transaction ,conn-var)\n (with-savepoint ,conn-var ,@body)\n (%with-transaction ,conn-var ,@body)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "Generate a defmacro form that transforms code like this:\n(fbind nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by FBIND", "input": "(fbind nil\n :key\n nil)", "output": "(defmacro fbind (bindings &body body &environment *lexenv*)\n \"Binds values in the function namespace.\n\nThat is,\n (fbind ((fn (lambda () ...))))\n \u2261 (flet ((fn () ...))),\n\nexcept that a bare symbol in BINDINGS is rewritten as (symbol\nsymbol).\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbind `(locally ,@body)))\n ;; When possible (if the binding expands to a simple\n ;; let-over-lambda), we hoist the bindings to the top and bind\n ;; the lambda directly with flet.\n\n ;; Failing that, if we know that the function is never directly\n ;; dereferenced with sharp-quote, we can bind with `macrolet'\n ;; instead of `flet', leaving no runtime overhead vs. `funcall'.\n (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))\n (macro-vars\n (merely-syntactic-functions (mapcar #'first bindings)\n body\n *lexenv*))\n (vars (mapcar #'first bindings))\n (exprs (mapcar #'second bindings))\n (temps (mapcar #'string-gensym vars))\n (body decls (parse-body body)))\n `(let ,env\n ,@(unsplice (and env-decls `(declare ,@env-decls)))\n (comment \"fbind: Hidden variable bindings to close over.\")\n (let ,(loop for temp in temps\n for expr in exprs\n collect `(,temp (ensure-function ,expr)))\n ,@(when temps\n (unsplice\n `(declare (function ,@temps))))\n (comment \"fbind: Hidden variable bindings for function values.\")\n (flet (,@(loop for (name lambda) in lambdas\n collect `(,name ,@(cdr lambda)))\n ,@(loop for var in vars\n for temp in temps\n unless (member var macro-vars)\n collect (build-bind/ftype var temp decls env)))\n #-sbcl (declare (inline ,@(set-difference vars macro-vars)))\n ,@decls\n (comment \"fbind: Functions that might be sharp-quoted.\")\n (macrolet (,@(loop for var in vars\n for temp in temps\n when (member var macro-vars)\n collect `(,var\n (&rest args)\n (list* 'funcall ',temp args))))\n (comment \"fbind: Macros for functions provably never sharp-quoted.\")\n ,@body))))))", "category": "control-flow", "technique": "macrolet,gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make-kid 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-KID", "input": "(make-kid 'lol-gen::some-name)", "output": "(defmacro make-kid (class &rest ia)\n (with-gensyms (c)\n `(let ((,c ,class))\n (make-instance ,c\n ,@ia\n :fm-parent (progn (assert self () \"make-kid: self nil making ~a\" ,c)\n self)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(some-> nil (progn))\n\nIssue: Macro call that should be transformed by SOME->", "input": "(some-> nil (progn))", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-proxynodes nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-PROXYNODES", "input": "(with-proxynodes nil\n (progn))", "output": "(defmacro with-proxynodes (proxy-nodes &body body)\n \"define proxy nodes for local usage\"\n (if (not (listp proxy-nodes))\n (setf proxy-nodes (list proxy-nodes)))\n (if proxy-nodes\n (let ((tmp (gensym (format nil \"~:@(proxy-~a-~)\" (first proxy-nodes)))))\n\t;(format t \"Symbol:: ~s\" tmp)\n\t(setf (gethash (first proxy-nodes) *proxy-node*) tmp)\n\t;;for debug/swank, else comment out\n\t;;(eval `(defnode ,tmp (proxy) ()))\n\t;;\n\t`(let ((,(first proxy-nodes) ',tmp))\n\n\t ;(defnode ,tmp (proxy) ())\n\t (defproxy ,tmp)\n\t \n\t (with-proxynodes ,(rest proxy-nodes) ,@body)))\n `(progn ,@body)))", "category": "dsl", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(any-of nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by ANY-OF", "input": "(any-of nil\n (progn))", "output": "(defmacro ANY-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(advisable-lambda nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by ADVISABLE-LAMBDA", "input": "(advisable-lambda nil\n :key\n nil)", "output": "(defmacro ADVISABLE-LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(unless nil)\n\nProblem: Macro call that should be transformed by UNLESS", "input": "(unless nil)", "output": "(defmacro UNLESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(acase 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by ACASE", "input": "(acase 'lol-gen::some-name)", "output": "(defmacro acase (keyform &body cases)\n \"Like CASE, except binds the result of the keyform to IT (via LET) for the\nscope of the cases.\"\n `(anaphoric case ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(special common-lisp:nil\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SPECIAL", "input": "(special common-lisp:nil\n common-lisp:nil)", "output": "(defmacro SPECIAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(resolve\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by RESOLVE", "input": "(resolve\n nil\n nil)", "output": "(defmacro RESOLVE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(do-generator-value-list 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DO-GENERATOR-VALUE-LIST", "input": "(do-generator-value-list 'lol-gen::some-name)", "output": "(defmacro do-generator-value-list ((var generator) &body body)\n \"Like do-generator, except all values emitted by the generator are placed in a list under the user defined variable.\"\n (let ((g (gensym)))\n `(let ((,g ,generator))\n (loop \n\t do (if-generator (,var ,g)\n\t\t\t (progn ,@body)\n\t\t\t (return))))))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fnn nil (progn))\n\nProblem: Macro call that should be transformed by FNN", "input": "(fnn nil (progn))", "output": "(defmacro FNN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(c_1\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by C_1", "input": "(c_1\n nil\n :key\n nil)", "output": "(defmacro c_1 (&body body)\n `(make-c-dependent\n :code '(without-c-dependency ,@body)\n :inputp nil\n :lazy t\n :value-state :unevaluated\n :rule (c-lambda (without-c-dependency ,@body))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(trcx 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by TRCX", "input": "(trcx 'lol-gen::some-name)", "output": "(defmacro trcx (tgt-form &rest os)\n (if (eql tgt-form 'nil)\n '(progn)\n `(without-c-dependency\n (call-trc t ,(format nil \"TX> ~(~s~)\" tgt-form)\n ,@(loop for obj in (or os (list tgt-form))\n nconcing (list (intern (format nil \"~a\" obj) :keyword) obj))))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(dynamic-wind\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by DYNAMIC-WIND", "input": "(dynamic-wind\n nil\n :key\n nil)", "output": "(defmacro DYNAMIC-WIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(select 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by SELECT", "input": "(select 'lol-gen::some-name)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(re-setf nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by RE-SETF", "input": "(re-setf nil (progn))", "output": "(defmacro re-setf (var &rest clauses)\n \"SETFs VAR to the value of each clause subsequently.\n Re-uses the new value of VAR in subsequent clauses.\n Expects VAR to be a valid place for SETF.\"\n `(progn ,@(mapcar (lambda (clause)\n `(setf ,var ,clause))\n clauses)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fgathering nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by FGATHERING", "input": "(fgathering nil\n :key\n nil)", "output": "(defmacro FGATHERING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-connection nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-CONNECTION", "input": "(with-connection nil\n :key\n nil)", "output": "(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*))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(->\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by ->", "input": "(->\n nil\n nil)", "output": "(defmacro -> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(count-failures\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by COUNT-FAILURES", "input": "(count-failures\n nil\n nil)", "output": "(defmacro COUNT-FAILURES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c?\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by C?", "input": "(c?\n nil\n (progn))", "output": "(defmacro c? (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fail)\n\nIssue: Macro call that should be transformed by FAIL", "input": "(fail)", "output": "(defmacro fail ()\n \"Causes the latest pattern matching to fail. After this failure,\nmatching continues at the next pattern.\"\n ;; FIXME: Don't raise an error but expand to %FAIL for the hack\n ;; above.\n ;(error \"Not pattern matching.\")\n '%fail)", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda-ematch\n common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-EMATCH", "input": "(lambda-ematch\n common-lisp:nil\n (common-lisp:progn))", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defaction nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFACTION", "input": "(defaction nil\n :key\n nil)", "output": "(defmacro DEFACTION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c?n\n nil)\n\nWhat needs to change: Macro call that should be transformed by C?N", "input": "(c?n\n nil)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(print-values\n nil)\n\nProblem: Macro call that should be transformed by PRINT-VALUES", "input": "(print-values\n nil)", "output": "(defmacro PRINT-VALUES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(eval-when-load\n common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by EVAL-WHEN-LOAD", "input": "(eval-when-load\n common-lisp:nil\n common-lisp:nil)", "output": "(defmacro EVAL-WHEN-LOAD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(insert-into 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by INSERT-INTO", "input": "(insert-into 'lol-gen::some-name)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(any-of nil)\n\nIssue: Macro call that should be transformed by ANY-OF", "input": "(any-of nil)", "output": "(defmacro ANY-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(unionf nil :key nil)\n\nIssue: Macro call that should be transformed by UNIONF", "input": "(unionf nil :key nil)", "output": "(defmacro UNIONF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(-<> 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by -<>", "input": "(-<> 'lol-gen::some-name)", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(c?n-dbg\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by C?N-DBG", "input": "(c?n-dbg\n 'lol-gen::some-name)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(aand 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by AAND", "input": "(aand 'lol-gen::some-name)", "output": "(defmacro aand (first &rest rest)\n \"Like AND, except binds the first argument to IT (via LET) for the\nscope of the rest of the arguments.\"\n `(anaphoric and ,first ,@rest))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(possibly?\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by POSSIBLY?", "input": "(possibly?\n 'lol-gen::some-name)", "output": "(defmacro POSSIBLY? ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c?once\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by C?ONCE", "input": "(c?once\n nil\n (progn))", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(unionf nil nil)\n\nWhat needs to change: Macro call that should be transformed by UNIONF", "input": "(unionf nil nil)", "output": "(defmacro UNIONF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defmethod nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFMETHOD", "input": "(defmethod nil (progn))", "output": "(defmacro DEFMETHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(gen-lambda nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by GEN-LAMBDA", "input": "(gen-lambda nil\n :key\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(prog2 nil (progn))\n\nPattern to recognize: Macro call that should be transformed by PROG2", "input": "(prog2 nil (progn))", "output": "(defmacro PROG2 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(multiple-value-cmatch nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MULTIPLE-VALUE-CMATCH", "input": "(multiple-value-cmatch nil)", "output": "(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))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(rem-arg-list-key-value! nil (progn))\n\nWhat needs to change: Macro call that should be transformed by REM-ARG-LIST-KEY-VALUE!", "input": "(rem-arg-list-key-value! nil (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fbindrec nil\n nil)\n\nProblem: Macro call that should be transformed by FBINDREC", "input": "(fbindrec nil\n nil)", "output": "(defmacro fbindrec (bindings &body body &environment *lexenv*)\n \"Like `fbind', but creates recursive bindings.\n\nThe consequences of referring to one binding in the expression that\ngenerates another are undefined.\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbindrec `(locally ,@body)))\n (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))\n (body decls (parse-body body))\n (simple complex lambda unref\n (partition-fbinds (append bindings lambdas)\n body))\n (temps (mapcar (op (gensym (string (first _)))) complex))\n (simple-decls complex-decls lambda-decls others\n (partition-declarations-by-kind simple complex lambda decls)))\n `(let ,env\n ,@(unsplice (and env-decls `(declare ,@env-decls)))\n ;; Simple expressions reference functions already defined\n ;; outside of the letrec, so we can handle them with fbind.\n (comment \"fbind: Simple\")\n (fbind ,simple\n ,@simple-decls\n (comment \"fbind: Temps for complex bindings\")\n (let ,(loop for temp in temps collect `(,temp #'invalid))\n (declare ,@(loop for temp in temps collect `(function ,temp)))\n (flet ,(loop for (name nil) in complex\n for temp in temps\n collect (build-bind/ftype name temp complex-decls env))\n ,@complex-decls\n (comment \"fbind: Lambdas\")\n (labels (,@(loop for (name lambda) in lambda\n collect `(,name ,@(cdr lambda))))\n ,@lambda-decls\n (comment \"fbind: Unreferenced\")\n (progn ,@(mapcar #'second unref))\n (comment \"fbind: Complex\")\n (psetf ,@(loop for temp in temps\n for (nil expr) in complex\n append `(,temp (ensure-function ,expr))))\n (locally ,@others\n ,@body))))))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(in-suite 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by IN-SUITE", "input": "(in-suite 'lol-gen::some-name)", "output": "(defmacro in-suite (suite-name)\n \"Set the *suite* special variable so that all tests defined\nafter the execution of this form are, unless specified otherwise,\nin the test-suite named SUITE-NAME.\n\nSee also: DEF-SUITE *SUITE*\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (%in-suite ,suite-name)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(isnt-values nil)\n\nWhat needs to change: Macro call that should be transformed by ISNT-VALUES", "input": "(isnt-values nil)", "output": "(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)))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(collect-sum 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECT-SUM", "input": "(collect-sum 'lol-gen::some-name)", "output": "(defmacro COLLECT-SUM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(cond->> 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by COND->>", "input": "(cond->> 'lol-gen::some-name)", "output": "(defmacro COND->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-slots nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-SLOTS", "input": "(with-slots nil\n nil)", "output": "(defmacro WITH-SLOTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-cc nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-CC", "input": "(with-cc nil\n (progn))", "output": "(defmacro with-cc (id &body body)\n `(with-integrity (:change ,id)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(some->> nil nil)\n\nIssue: Macro call that should be transformed by SOME->>", "input": "(some->> nil nil)", "output": "(defmacro SOME->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(setf)\n\nWrite a macro that addresses: Macro call that should be transformed by SETF", "input": "(setf)", "output": "(defmacro SETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-shadowed-custom-vars\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-SHADOWED-CUSTOM-VARS", "input": "(with-shadowed-custom-vars\n 'lol-gen::some-name)", "output": "(defmacro with-shadowed-custom-vars (&body body)\n `(let ,(loop for (var) in *custom-vars*\n collect `(,var (if (boundp ',var) ,var)))\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(set-dynamic nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SET-DYNAMIC", "input": "(set-dynamic nil nil)", "output": "(defmacro SET-DYNAMIC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(update nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by UPDATE", "input": "(update nil\n (progn))", "output": "(defmacro update (table &body clauses)\n `(make-statement :update\n ,(expand-expression table) ,@clauses))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-savepoint 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WITH-SAVEPOINT", "input": "(with-savepoint 'lol-gen::some-name)", "output": "(defmacro with-savepoint (name &body body)\n \"Can only be used within a transaction. Establishes a savepoint with the given\nname at the start of body, and binds the same name to a handle for that savepoint.\nThe body is executed and, at the end of body, the savepoint is released, unless a\ncondition is thrown, in which case it is rolled back. Execute the body within a\nsavepoint, releasing savepoint when the body exits normally, and rolling back\notherwise. NAME is both the variable that can be used to release or rolled back\nbefore the body unwinds, and the SQL name of the savepoint.\n\nAn example might look like this:\n\n(defun test12 (x &optional (y nil))\n (with-logical-transaction (lt1 :read-committed-rw)\n (execute (:insert-into 'test-data :set 'value 0))\n (with-savepoint sp1\n (execute (:insert-into 'test-data :set 'value 1))\n (if (< x 0)\n (rollback-savepoint sp1)\n (release-savepoint sp1)))\n (with-savepoint sp2\n (execute (:insert-into 'test-data :set 'value 2))\n (with-savepoint sp3\n (execute (:insert-into 'test-data :set 'value 3))\n (if (> x 0)\n (rollback-savepoint sp3)\n (release-savepoint sp3))\n (when y (rollback-savepoint sp2)))\n (if (= x 0)\n (rollback-savepoint sp2)\n (release-savepoint sp2)))\n (when (string= y \\\"abrt\\\")\n (abort-transaction lt1))))\"\n\n `(call-with-savepoint ',name (lambda (,name)\n (declare (ignorable ,name)) ,@body)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(eval-always\n nil)\n\nIssue: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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", "input": "(c?n-dbg\n nil\n (progn))", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-contracts-disabled nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-CONTRACTS-DISABLED", "input": "(with-contracts-disabled nil\n :key\n nil)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7999999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(c?n-until nil)\n\nIssue: Macro call that should be transformed by C?N-UNTIL", "input": "(c?n-until nil)", "output": "(defmacro c?n-until (args &body body)\n `(make-c-dependent\n :optimize :when-value-t\n :code ',body\n :inputp t\n :value-state :unevaluated\n :rule (c-lambda ,@body)\n ,@args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(unless nil :key nil)\n\nIssue: Macro call that should be transformed by UNLESS", "input": "(unless nil :key nil)", "output": "(defmacro UNLESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-symbol-access\n nil)\n\nIssue: Macro call that should be transformed by WITH-SYMBOL-ACCESS", "input": "(with-symbol-access\n nil)", "output": "(defmacro WITH-SYMBOL-ACCESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(whichever 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WHICHEVER", "input": "(whichever 'lol-gen::some-name)", "output": "(defmacro whichever (&rest possibilities &environment env)\n \"Evaluates exactly one of POSSIBILITIES, chosen at random.\"\n (setf possibilities (mapcar (lambda (p) (macroexpand p env)) possibilities))\n (let ((length (length possibilities)))\n (cond\n ((= 1 length)\n (first possibilities))\n ((every #'constantp possibilities)\n `(svref (load-time-value (vector ,@possibilities)) \n (random ,length)))\n (T\n (labels ((expand (possibilities position random-number)\n (if (null (cdr possibilities))\n (car possibilities)\n (let* ((length (length possibilities))\n (half (truncate length 2))\n (second-half (nthcdr half possibilities))\n (first-half (butlast possibilities (- length half))))\n `(if (< ,random-number ,(+ position half))\n ,(expand first-half position random-number)\n ,(expand second-half (+ position half) random-number))))))\n (with-gensyms (random-number)\n `(let ((,random-number (random ,length)))\n ,(expand possibilities 0 random-number))))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ignore-some-conditions nil)\n\nIssue: Macro call that should be transformed by IGNORE-SOME-CONDITIONS", "input": "(ignore-some-conditions nil)", "output": "(defmacro ignore-some-conditions ((&rest conditions) &body body)\n \"Similar to CL:IGNORE-ERRORS but the (unevaluated) CONDITIONS\nlist determines which specific conditions are to be ignored.\"\n `(handler-case\n (progn ,@body)\n ,@(loop for condition in conditions collect\n `(,condition (c) (values nil c)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(send nil nil)\n\nIssue: Macro call that should be transformed by SEND", "input": "(send nil nil)", "output": "(defmacro SEND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fm-other 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by FM-OTHER", "input": "(fm-other 'lol-gen::some-name)", "output": "(defmacro fm-other (md-name &key (starting 'self) skip-tree (test '#'true-that))\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 :skip-tree ,skip-tree\n :global-search t\n :test ,test))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(markup nil)\n\nProblem: Macro call that should be transformed by MARKUP", "input": "(markup nil)", "output": "(defmacro markup (&rest tags)\n `(%write-strings\n ,@(loop for tag in tags\n append (tag->string tag))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(psetq nil nil)\n\nWhat needs to change: Macro call that should be transformed by PSETQ", "input": "(psetq nil nil)", "output": "(defmacro PSETQ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fluid-bind nil\n nil)\n\nIssue: Macro call that should be transformed by FLUID-BIND", "input": "(fluid-bind nil\n nil)", "output": "(defmacro fluid-bind ((&rest bindings) &body body)\n \"Fluid-bind is an extension of bind that handles setting and resetting places. For example, suppose that an object of class foo has a slot named bar whose value is currently 3. The following code would evaluate the inner body with bar bound to 17 and restore it when the inner body is exited. \n\n\\(fluid-bind \\(\\(\\(bar foo\\) 17\\)\\)\n \\(print \\(bar foo\\)\\)\\)\n\\(print \\(bar foo\\)\\)\n==> \\(prints 17, then 3\\)\n\nThis is similar to dynamic-binding but _much_ less robust.\"\n ;; does not handle declarations correctly\n (let ((setup-forms nil)\n (cleanup-forms nil)\n (gensyms nil))\n (loop for binding in bindings collect\n (destructuring-bind \n\t\t(setup-form cleanup-form)\n\t (cond ((consp binding)\n\t\t (destructuring-bind (var value) binding\n\t\t (let ((g (gensym)))\n\t\t\t (push g gensyms)\n\t\t\t (cond ((atom var)\n\t\t\t\t`((:bind (,var ,value)) nil)\n\t\t\t\t#+(or)\n\t\t\t\t;; lexical or special?\n\t\t\t\t(if (boundp var)\n\t\t\t\t `((:bind (,var ,value)) nil)\n\t\t\t\t `((:setf (setf ,g ,var ,var ,value))\n\t\t\t\t (setf ,var ,g))))\n\t\t\t ((and (fboundp (first var))\n\t\t\t\t (not (eq (first var) 'values)))\n\t\t\t\t;; putative place\n\t\t\t\t`((:setf (setf ,g ,var ,var ,value))\n\t\t\t\t (setf ,var ,g)))\n\t\t\t (t\n\t\t\t\t`((:bind (,var ,value)) nil))))))\n\t\t (t\n\t\t `((:bind (,binding nil)) nil)))\n (push setup-form setup-forms)\n (push cleanup-form cleanup-forms)))\n (let ((result body))\n (mapc (lambda (setup cleanup)\n (setf result\n (ecase (first setup)\n (:setf `((unwind-protect\n (progn\n ,(second setup)\n ,@result)\n ,cleanup)))\n (:bind `((bind (,(second setup))\n ,@result)))))\n result)\n setup-forms cleanup-forms)\n `(let ,gensyms\n (declare (ignorable ,@gensyms))\n ,@result))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-method-combination nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-METHOD-COMBINATION", "input": "(define-method-combination nil :key nil)", "output": "(defmacro define-method-combination (name &rest args)\n `(progn\n (define-method-combination% ,name ,@args)\n (c2mop:define-method-combination ,name ,@args)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-standard-io-syntax nil (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-STANDARD-IO-SYNTAX", "input": "(with-standard-io-syntax nil (progn))", "output": "(defmacro WITH-STANDARD-IO-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(named-lambda nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by NAMED-LAMBDA", "input": "(named-lambda nil\n :key\n nil)", "output": "(defmacro named-lambda (name lambda-list &body body)\n \"Expands into a lambda-expression within whose BODY NAME denotes the\ncorresponding function.\"\n `(labels ((,name ,lambda-list ,@body))\n #',name))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dreletf* nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DRELETF*", "input": "(dreletf* nil\n :key\n nil)", "output": "(defmacro DRELETF* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defunion nil\n (progn))\n\nProblem: Macro call that should be transformed by DEFUNION", "input": "(defunion nil\n (progn))", "output": "(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)))))", "category": "anaphoric", "technique": "symbol-macrolet,anaphor", "complexity": "advanced", "quality_score": 0.8925} {"instruction": "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", "input": "(letmatch nil\n nil)", "output": "(defmacro LETMATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(delete-from-plistf nil nil)\n\nProblem: Macro call that should be transformed by DELETE-FROM-PLISTF", "input": "(delete-from-plistf nil nil)", "output": "(defmacro DELETE-FROM-PLISTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ignore-errors 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by IGNORE-ERRORS", "input": "(ignore-errors 'lol-gen::some-name)", "output": "(defmacro IGNORE-ERRORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "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 -<>>", "input": "(-<>> nil\n (progn))", "output": "(defmacro -<>> (init &body exps) (diamond-wand init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(alet 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ALET", "input": "(alet 'lol-gen::some-name)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ok? nil)\n\nIssue: Macro call that should be transformed by OK?", "input": "(ok? nil)", "output": "(defmacro ok? (x)\n \"Did parsing succeed?\"\n `(cl:not (failure? ,x)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(or nil)\n\nPattern to recognize: Macro call that should be transformed by OR", "input": "(or nil)", "output": "(defmacro OR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(walk-environment\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WALK-ENVIRONMENT", "input": "(walk-environment\n nil\n nil)", "output": "(defmacro WALK-ENVIRONMENT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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 <-", "input": "(<- nil nil)", "output": "(defmacro <- (place fn)\n \"Apply FN in-place to PLACE.\"\n `(setf ,place (call ,fn ,place)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(static-let nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by STATIC-LET", "input": "(static-let nil\n nil)", "output": "(defmacro static-let ((&rest bindings) &body body)\n \"Like `let', except the variables are only initialized once and\nretain their values between different invocations of `body'.\n\nEvery static binding is similar to a `let' binding, except it can have\nadditional keyword arguments:\n\n- `type' Denotes the type of the variable.\n- `once' If true, then binding initialization and mutation will be\n thread-safe.\n- `flush' If true, this binding will be flushable. Defaults to true.\n- `in' Denotes the static binding group in which the binding will be\n placed for flushing. Defaults to the value of `*package'.\n- `read-only' If true, then the binding cannot be mutated with `setf'.\n\nStatic bindings can be flushed via `flush-static-binding-group' and\n`flush-all-static-binding-groups'; the latter is automatically pushed\ninto `uiop:*dump-image-hooks*' by Serapeum.\n\nAn unflushable static binding will carry its value over into dumped\nLisp binaries.\"\n (parse-static-let bindings body))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8724999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(pprint-coalton-codegen-ast\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-AST", "input": "(pprint-coalton-codegen-ast\n 'lol-gen::some-name)", "output": "(defmacro PPRINT-COALTON-CODEGEN-AST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(appendf nil)\n\nPattern to recognize: Macro call that should be transformed by APPENDF", "input": "(appendf nil)", "output": "(defmacro APPENDF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(decf 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DECF", "input": "(decf 'lol-gen::some-name)", "output": "(defmacro DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-setf-expander nil ())\n\nPattern to recognize: Macro call that should be transformed by DEFINE-SETF-EXPANDER", "input": "(define-setf-expander nil ())", "output": "(defmacro DEFINE-SETF-EXPANDER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(eval-always\n common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n common-lisp:nil\n common-lisp:nil)", "output": "(defmacro EVAL-ALWAYS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(fbindrec 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by FBINDREC", "input": "(fbindrec 'lol-gen::some-name)", "output": "(defmacro fbindrec (bindings &body body &environment *lexenv*)\n \"Like `fbind', but creates recursive bindings.\n\nThe consequences of referring to one binding in the expression that\ngenerates another are undefined.\"\n (setf bindings (expand-fbindings bindings))\n (unless bindings\n (return-from fbindrec `(locally ,@body)))\n (mvlet* ((env env-decls bindings lambdas (analyze-fbinds bindings *lexenv*))\n (body decls (parse-body body))\n (simple complex lambda unref\n (partition-fbinds (append bindings lambdas)\n body))\n (temps (mapcar (op (gensym (string (first _)))) complex))\n (simple-decls complex-decls lambda-decls others\n (partition-declarations-by-kind simple complex lambda decls)))\n `(let ,env\n ,@(unsplice (and env-decls `(declare ,@env-decls)))\n ;; Simple expressions reference functions already defined\n ;; outside of the letrec, so we can handle them with fbind.\n (comment \"fbind: Simple\")\n (fbind ,simple\n ,@simple-decls\n (comment \"fbind: Temps for complex bindings\")\n (let ,(loop for temp in temps collect `(,temp #'invalid))\n (declare ,@(loop for temp in temps collect `(function ,temp)))\n (flet ,(loop for (name nil) in complex\n for temp in temps\n collect (build-bind/ftype name temp complex-decls env))\n ,@complex-decls\n (comment \"fbind: Lambdas\")\n (labels (,@(loop for (name lambda) in lambda\n collect `(,name ,@(cdr lambda))))\n ,@lambda-decls\n (comment \"fbind: Unreferenced\")\n (progn ,@(mapcar #'second unref))\n (comment \"fbind: Complex\")\n (psetf ,@(loop for temp in temps\n for (nil expr) in complex\n append `(,temp (ensure-function ,expr))))\n (locally ,@others\n ,@body))))))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defplace nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFPLACE", "input": "(defplace nil\n :key\n nil)", "output": "(defmacro defplace (name args &body body)\n \"Define NAME and (SETF NAME) in one go.\n\nBODY is a list of forms, starting with an optional docstring. The last\nform in BODY, however, must be a single, setf-able expression.\"\n (match body\n ((list (type string))\n (error \"No form for ~s: ~a\" 'defplace body))\n ((last (cons (type string) nil) 1)\n `(defplace ,name ,args ,@(reverse body)))\n (otherwise\n (with-gensyms (value)\n `(progn\n (defun ,name ,args\n ,@body)\n (defun (setf ,name) (,value ,@args)\n ,@(butlast body)\n (setf ,(lastcar body) ,value)))))))", "category": "capture-management", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defsynonym nil (progn))\n\nProblem: Macro call that should be transformed by DEFSYNONYM", "input": "(defsynonym nil (progn))", "output": "(defmacro defsynonym (syn word)\n \"Makes SYN a synonym for the existing iterate keyword WORD.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (setf (get ',syn 'synonym) ',word)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(when nil (progn))\n\nProblem: Macro call that should be transformed by WHEN", "input": "(when nil (progn))", "output": "(defmacro WHEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fgather-next nil (progn))\n\nPattern to recognize: Macro call that should be transformed by FGATHER-NEXT", "input": "(fgather-next nil (progn))", "output": "(defmacro FGATHER-NEXT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dletf* nil\n nil)\n\nIssue: Macro call that should be transformed by DLETF*", "input": "(dletf* nil\n nil)", "output": "(defmacro DLETF* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-language nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-LANGUAGE", "input": "(define-language nil (progn))", "output": "(defmacro DEFINE-LANGUAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(match nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by MATCH", "input": "(match nil (progn))", "output": "(defmacro MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(c_?dbg\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by C_?DBG", "input": "(c_?dbg\n 'lol-gen::some-name)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-string-dispatch nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITH-STRING-DISPATCH", "input": "(with-string-dispatch nil\n :key\n nil)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(case-using nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CASE-USING", "input": "(case-using nil\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(some->> nil)\n\nPattern to recognize: Macro call that should be transformed by SOME->>", "input": "(some->> nil)", "output": "(defmacro some->> (init &body exps) (arrow-macro init exps t t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(and-let* nil)\n\nPattern to recognize: Macro call that should be transformed by AND-LET*", "input": "(and-let* nil)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7275} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(true nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by TRUE", "input": "(true nil :key nil)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(return 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by RETURN", "input": "(return 'lol-gen::some-name)", "output": "(defmacro RETURN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(match 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by MATCH", "input": "(match 'lol-gen::some-name)", "output": "(defmacro match (what &body clauses)\n #.+match-doc+\n `(match2 ,what\n ,@clauses\n (_ nil)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(-<>> nil (progn))\n\nIssue: Macro call that should be transformed by -<>>", "input": "(-<>> nil (progn))", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(and nil (progn))\n\nWhat needs to change: Macro call that should be transformed by AND", "input": "(and nil (progn))", "output": "(defmacro AND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(mapping nil (progn))\n\nPattern to recognize: Macro call that should be transformed by MAPPING", "input": "(mapping nil (progn))", "output": "(defmacro MAPPING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(prependf nil nil)\n\nPattern to recognize: Macro call that should be transformed by PREPENDF", "input": "(prependf nil nil)", "output": "(defmacro PREPENDF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(implies nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IMPLIES", "input": "(implies nil nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(pprint-coalton-codegen-types)\n\nProblem: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-TYPES", "input": "(pprint-coalton-codegen-types)", "output": "(defmacro PPRINT-COALTON-CODEGEN-TYPES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-keys nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-KEYS", "input": "(with-keys nil\n nil)", "output": "(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)))", "category": "dsl", "technique": "once-only,nested-backquote", "complexity": "intermediate", "quality_score": 0.8725} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-contracts-disabled nil)\n\nProblem: Macro call that should be transformed by WITH-CONTRACTS-DISABLED", "input": "(with-contracts-disabled nil)", "output": "(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)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(eval-when-compile\n common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EVAL-WHEN-COMPILE", "input": "(eval-when-compile\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro EVAL-WHEN-COMPILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(unwind-protect-case nil\n nil)\n\nIssue: Macro call that should be transformed by UNWIND-PROTECT-CASE", "input": "(unwind-protect-case nil\n nil)", "output": "(defmacro unwind-protect-case ((&optional abort-flag) protected-form &body clauses)\n \"Like CL:UNWIND-PROTECT, but you can specify the circumstances that\nthe cleanup CLAUSES are run.\n\n clauses ::= (:NORMAL form*)* | (:ABORT form*)* | (:ALWAYS form*)*\n\nClauses can be given in any order, and more than one clause can be\ngiven for each circumstance. The clauses whose denoted circumstance\noccured, are executed in the order the clauses appear.\n\nABORT-FLAG is the name of a variable that will be bound to T in\nCLAUSES if the PROTECTED-FORM aborted preemptively, and to NIL\notherwise.\n\nExamples:\n\n (unwind-protect-case ()\n (protected-form)\n (:normal (format t \\\"This is only evaluated if PROTECTED-FORM executed normally.~%\\\"))\n (:abort (format t \\\"This is only evaluated if PROTECTED-FORM aborted preemptively.~%\\\"))\n (:always (format t \\\"This is evaluated in either case.~%\\\")))\n\n (unwind-protect-case (aborted-p)\n (protected-form)\n (:always (perform-cleanup-if aborted-p)))\n\"\n (check-type abort-flag (or null symbol))\n (let ((gflag (gensym \"FLAG+\")))\n `(let ((,gflag t))\n (unwind-protect (multiple-value-prog1 ,protected-form (setf ,gflag nil))\n\t (let ,(and abort-flag `((,abort-flag ,gflag)))\n\t ,@(loop for (cleanup-kind . forms) in clauses\n\t\t collect (ecase cleanup-kind\n\t\t\t (:normal `(when (not ,gflag) ,@forms))\n\t\t\t (:abort `(when ,gflag ,@forms))\n\t\t\t (:always `(progn ,@forms)))))))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defannotation nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFANNOTATION", "input": "(defannotation nil\n :key\n nil)", "output": "(defmacro defannotation (name lambda-list options &body body)\n `(progn\n (set-annotation-options ',name ',options)\n (defmacro ,name ,lambda-list ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ps\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by PS", "input": "(ps\n 'lol-gen::some-name)", "output": "(defmacro PS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(on-duplicate-key-update nil nil)\n\nProblem: Macro call that should be transformed by ON-DUPLICATE-KEY-UPDATE", "input": "(on-duplicate-key-update nil nil)", "output": "(defmacro on-duplicate-key-update (&rest args)\n `(make-clause :on-duplicate-key-update ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defunit nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFUNIT", "input": "(defunit nil (progn))", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(markup)\n\nWhat needs to change: Macro call that should be transformed by MARKUP", "input": "(markup)", "output": "(defmacro markup (&rest tags)\n `(%write-strings\n ,@(loop for tag in tags\n append (tag->string tag))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(xor 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by XOR", "input": "(xor 'lol-gen::some-name)", "output": "(defmacro xor (&rest datums)\n \"Evaluates its arguments one at a time, from left to right. If more than one\nargument evaluates to a true value no further DATUMS are evaluated, and NIL is\nreturned as both primary and secondary value. If exactly one argument\nevaluates to true, its value is returned as the primary value after all the\narguments have been evaluated, and T is returned as the secondary value. If no\narguments evaluate to true NIL is returned as primary, and T as secondary\nvalue.\"\n (with-gensyms (xor tmp true)\n `(let (,tmp ,true)\n (declare (ignorable ,tmp))\n (block ,xor\n ,@(mapcar (lambda (datum)\n `(if (setf ,tmp ,datum)\n (if ,true\n (return-from ,xor (values nil nil))\n (setf ,true ,tmp))))\n datums)\n (return-from ,xor (values ,true t))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(enable-annot-syntax)\n\nProblem: Macro call that should be transformed by ENABLE-ANNOT-SYNTAX", "input": "(enable-annot-syntax)", "output": "(defmacro enable-annot-syntax ()\n '(eval-when (:compile-toplevel :load-toplevel :execute)\n (%enable-annot-syntax)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-max 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COLLECT-MAX", "input": "(collect-max 'lol-gen::some-name)", "output": "(defmacro COLLECT-MAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(drelet nil\n (progn))\n\nIssue: Macro call that should be transformed by DRELET", "input": "(drelet nil\n (progn))", "output": "(defmacro DRELET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-logical-transaction nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-LOGICAL-TRANSACTION", "input": "(with-logical-transaction nil\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(is-error nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IS-ERROR", "input": "(is-error nil nil)", "output": "(defmacro IS-ERROR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(as-array-member nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AS-ARRAY-MEMBER", "input": "(as-array-member nil\n nil)", "output": "(defmacro as-array-member ((&optional (stream '*json-output*))\n &body body)\n \"BODY should be a program which encodes exactly one JSON datum to\nSTREAM. AS-ARRAY-MEMBER ensures that the datum is properly formatted\nas a Member of an Array, i. e. separated by comma from any preceding\nor following Member.\"\n `(progn\n (next-aggregate-member 'array ,stream)\n ,@body))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(either\n nil)\n\nProblem: Macro call that should be transformed by EITHER", "input": "(either\n nil)", "output": "(defmacro EITHER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(terminate)\n\nWhat needs to change: Macro call that should be transformed by TERMINATE", "input": "(terminate)", "output": "(defmacro TERMINATE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ltbdd-with-new-hash 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by LTBDD-WITH-NEW-HASH", "input": "(ltbdd-with-new-hash 'lol-gen::some-name)", "output": "(defmacro LTBDD-WITH-NEW-HASH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-current-source-form 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WITH-CURRENT-SOURCE-FORM", "input": "(with-current-source-form 'lol-gen::some-name)", "output": "(defmacro WITH-CURRENT-SOURCE-FORM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make-simple-collector-to-place nil)\n\nWhat needs to change: Macro call that should be transformed by MAKE-SIMPLE-COLLECTOR-TO-PLACE", "input": "(make-simple-collector-to-place nil)", "output": "(defmacro MAKE-SIMPLE-COLLECTOR-TO-PLACE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(let-match1 common-lisp:nil\n (common-lisp:progn))\n\nWrite a macro that addresses: Macro call that should be transformed by LET-MATCH1", "input": "(let-match1 common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro let-match1 (pattern arg &body body)\n \"Equivalent to (let-match ((PATTERN ARG)) BODY...).\"\n `(let-match ((,pattern ,arg)) ,.body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fmv 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by FMV", "input": "(fmv 'lol-gen::some-name)", "output": "(defmacro fmv (name)\n `(value (fm-other ,name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(tree-case 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by TREE-CASE", "input": "(tree-case 'lol-gen::some-name)", "output": "(defmacro TREE-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(push-end nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by PUSH-END", "input": "(push-end nil (progn))", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ignore common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by IGNORE", "input": "(ignore common-lisp:nil\n common-lisp:nil)", "output": "(defmacro IGNORE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(export-accessors\n common-lisp:nil\n :key\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by EXPORT-ACCESSORS", "input": "(export-accessors\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro EXPORT-ACCESSORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(defparameter-unbound nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFPARAMETER-UNBOUND", "input": "(defparameter-unbound nil\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(esc)\n\nWhat needs to change: Macro call that should be transformed by ESC", "input": "(esc)", "output": "(defmacro esc (&rest forms)\n `(list\n ,@(loop for form in forms\n collect (%escape-string-form form))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7775} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ensure-list 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ENSURE-LIST", "input": "(ensure-list 'lol-gen::some-name)", "output": "(defmacro ensure-list (item &body body)\n `(let ((,item (if (listp ,item) ,item '(,item))))\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is-print nil :key nil)\n\nProblem: Macro call that should be transformed by IS-PRINT", "input": "(is-print nil :key nil)", "output": "(defmacro is-print (got expected &optional desc)\n (with-gensyms (output duration duration-inner)\n (once-only (expected desc)\n `(with-catching-errors (:description ,desc :expected ,expected)\n (let* (,duration\n (,output (with-output-to-string (*standard-output*)\n (with-duration ((,duration-inner ,output) ,got)\n (declare (ignore ,output))\n (setq ,duration ,duration-inner)))))\n (test ,output ,expected ,desc\n :duration ,duration\n :got-form ',got\n :test-fn #'string=\n :report-expected-label \"output\"))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-standard-io-syntax nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-STANDARD-IO-SYNTAX", "input": "(with-standard-io-syntax nil :key nil)", "output": "(defmacro WITH-STANDARD-IO-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(html 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by HTML", "input": "(html 'lol-gen::some-name)", "output": "(defmacro html (&rest tags)\n `(with-doctype :html\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(-> 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ->", "input": "(-> 'lol-gen::some-name)", "output": "(defmacro -> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fail nil)\n\nWhat needs to change: Macro call that should be transformed by FAIL", "input": "(fail nil)", "output": "(defmacro fail (offset)\n \"Fail a parse while recording while recording how far it got.\"\n `(values :fail ,offset))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(make-list common-lisp:nil :key common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by MAKE-LIST", "input": "(make-list common-lisp:nil :key common-lisp:nil)", "output": "(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)))", "category": "control-flow", "technique": "nested-backquote", "complexity": "advanced", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(matrix-ecase 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by MATRIX-ECASE", "input": "(matrix-ecase 'lol-gen::some-name)", "output": "(defmacro MATRIX-ECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-explicit-encoder\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-EXPLICIT-ENCODER", "input": "(with-explicit-encoder\n 'lol-gen::some-name)", "output": "(defmacro with-explicit-encoder (&body body)\n `(with-local-encoder (use-explicit-encoder)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(-<>)\n\nPattern to recognize: Macro call that should be transformed by -<>", "input": "(-<>)", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(local-output\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by LOCAL-OUTPUT", "input": "(local-output\n 'lol-gen::some-name)", "output": "(defmacro LOCAL-OUTPUT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(multiple-value-list 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by MULTIPLE-VALUE-LIST", "input": "(multiple-value-list 'lol-gen::some-name)", "output": "(defmacro MULTIPLE-VALUE-LIST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dig 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DIG", "input": "(dig 'lol-gen::some-name)", "output": "(defmacro DIG ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(synchronized nil\n (progn))\n\nProblem: Macro call that should be transformed by SYNCHRONIZED", "input": "(synchronized nil\n (progn))", "output": "(defmacro synchronized ((&optional (object nil objectp)) &body body &environment env)\n \"Run BODY holding a unique lock associated with OBJECT.\nIf no OBJECT is provided, run BODY as an anonymous critical section.\n\nIf BODY begins with a literal string, attach the string to the lock\nobject created (as the argument to `bt:make-recursive-lock').\"\n (multiple-value-bind (string? body)\n (if (stringp (first body))\n (values (first body) (rest body))\n (values nil body))\n (let* ((form (lock-form object objectp env string?)))\n (with-gensyms (lock)\n `(let ((,lock ,form))\n (bt:with-recursive-lock-held (,lock)\n ;; On some Lisps this would return T if empty.\n ,@(or body '(nil))))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(select 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by SELECT", "input": "(select 'lol-gen::some-name)", "output": "(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))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defun* nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFUN*", "input": "(defun* nil\n (progn))", "output": "(defmacro DEFUN* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(cmatch* common-lisp:nil\n :key\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by CMATCH*", "input": "(cmatch* common-lisp:nil\n :key\n common-lisp:nil)", "output": "(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))))))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(terminate)\n\nWhat needs to change: Macro call that should be transformed by TERMINATE", "input": "(terminate)", "output": "(defmacro terminate () ; recommended for use with FOR ... NEXT\n \"Use within FOR ... DO-/NEXT clause to end the iteration\"\n '(finish))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(producing nil)\n\nWhat needs to change: Macro call that should be transformed by PRODUCING", "input": "(producing nil)", "output": "(defmacro PRODUCING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(eval-always\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "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 ->>", "input": "(->> nil)", "output": "(defmacro ->> (x &rest forms)\n \"Threads the expr through FORMS. Inserts X as the\n last item in the first form, or in place of % if it is present in the form,\n making a list of it if it is not a list already.\n If there are more forms, inserts the first form\n as the last item in second form, etc.\"\n (if (first forms)\n (let* ((form (first forms))\n (threaded (if (listp form)\n (if (member '% form)\n `(funcall (lambda (%) ,form) ,x)\n `(,(first form) ,@(rest form) ,x))\n `(,form ,x))))\n `(->> ,threaded ,@(rest forms)))\n x))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.815} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defmacro common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by DEFMACRO", "input": "(defmacro common-lisp:nil\n common-lisp:nil)", "output": "(defmacro DEFMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(-> 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by ->", "input": "(-> 'lol-gen::some-name)", "output": "(defmacro -> (init &body exps) (arrow-macro init exps))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(skip nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by SKIP", "input": "(skip nil :key nil)", "output": "(defmacro skip (&rest reason)\n \"Generates a TEST-SKIPPED result.\"\n `(add-result 'test-skipped :reason (format nil ,@reason)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-module nil\n nil)\n\nIssue: Macro call that should be transformed by DEFINE-MODULE", "input": "(define-module nil\n nil)", "output": "(defmacro define-module (name &body options)\n (let ((name (string name))\n (package (gensym \"PACKAGE\")))\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (let ((,package (or (find-package ,name)\n (make-package ,name :use ()))))\n (modularize :package ,package :name ,name)\n (expand-module ,name ',options)\n ,package))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(do-iter-values nil)\n\nWhat needs to change: Macro call that should be transformed by DO-ITER-VALUES", "input": "(do-iter-values nil)", "output": "(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))))", "category": "anaphoric", "technique": "tagbody-go,gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defparameter-unbound nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFPARAMETER-UNBOUND", "input": "(defparameter-unbound nil\n (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda-match1 common-lisp:nil\n :key\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by LAMBDA-MATCH1", "input": "(lambda-match1 common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro lambda-match1 (pattern &body body)\n \"Equivalent to (lambda (arg) (match arg (PATTERN BODY...))).\"\n `(lambda-match (,pattern ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-option-expander nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-OPTION-EXPANDER", "input": "(define-option-expander nil\n (progn))", "output": "(defmacro define-option-expander (name (package &rest arguments) &body body)\n (let ((args (gensym \"ARGS\")))\n `(defmethod expand-option ((,(gensym \"TYPE\") (eql ,(intern (string name) \"KEYWORD\"))) ,package ,args)\n (destructuring-bind ,arguments ,args\n ,@body))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "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", "input": "(lambda-match\n common-lisp:nil\n common-lisp:nil)", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defprotocol nil)\n\nIssue: Macro call that should be transformed by DEFPROTOCOL", "input": "(defprotocol nil)", "output": "(defmacro DEFPROTOCOL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(push-end-new nil nil)\n\nWhat needs to change: Macro call that should be transformed by PUSH-END-NEW", "input": "(push-end-new nil nil)", "output": "(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)))))", "category": "anaphoric", "technique": "once-only,anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(lambda-cmatch1 common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by LAMBDA-CMATCH1", "input": "(lambda-cmatch1 common-lisp:nil\n common-lisp:nil)", "output": "(defmacro lambda-cmatch1 (pattern &body body)\n \"Equivalent to (lambda (arg) (cmatch arg (PATTERN BODY...))).\"\n `(lambda-cmatch (,pattern ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(->\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by ->", "input": "(->\n nil\n :key\n nil)", "output": "(defmacro -> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(the nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by THE", "input": "(the nil :key nil)", "output": "(defmacro THE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(appendf nil :key nil)\n\nIssue: Macro call that should be transformed by APPENDF", "input": "(appendf nil :key nil)", "output": "(defmacro APPENDF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(try-as 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by TRY-AS", "input": "(try-as 'lol-gen::some-name)", "output": "(defmacro try-as (type cl:&optional (expr cl:nil expr-supplied-p))\n \"A syntactic convenience for type casting.\n\n (try-as )\n\nis equivalent to\n\n (the (Optional ) (tryInto ))\n\nand\n\n (try-as )\n\nis equivalent to\n\n (fn (expr) (the (Optional ) (tryInto expr))).\n\nNote that this may copy the object or allocate memory.\"\n\n (cl:let ((try-into (cl:ignore-errors (cl:find-symbol \"TRYINTO\" \"COALTON/CLASSES\")))\n (Optional (cl:ignore-errors (cl:find-symbol \"OPTIONAL\" \"COALTON/CLASSES\"))))\n (cl:assert try-into () \"`try-as` macro does not have access to `try-into` yet.\")\n (cl:assert Optional () \"`try-as` macro does not have access to `Optional` yet.\")\n (cl:if expr-supplied-p\n `(the (,Optional ,type) (,try-into ,expr))\n (alexandria:with-gensyms (lexpr)\n `(fn (,lexpr)\n (the (,Optional ,type) (,try-into ,lexpr)))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dletf* 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DLETF*", "input": "(dletf* 'lol-gen::some-name)", "output": "(defmacro DLETF* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dynamic-let nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DYNAMIC-LET", "input": "(dynamic-let nil\n :key\n nil)", "output": "(defmacro DYNAMIC-LET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defpackage nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by DEFPACKAGE", "input": "(defpackage nil :key nil)", "output": "(defmacro DEFPACKAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(prog* () (progn))\n\nIssue: Macro call that should be transformed by PROG*", "input": "(prog* () (progn))", "output": "(defmacro PROG* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(local\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by LOCAL", "input": "(local\n 'lol-gen::some-name)", "output": "(defmacro LOCAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make-instance* nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-INSTANCE*", "input": "(make-instance* nil)", "output": "(defmacro make-instance* (class &rest arguments)\n \"Convenience macro on top of `make-instance'.\n\nConveniences:\n\n- First argument can be a (possibly empty) list of shortcut symbols,\n which is automatically converted into a KEYWORD+SYMBOL pairs where\n - KEYWORD is the same as shortcut name, but interned as keyword.\n - And SYMBOL is the same as shortcut.\n\n- The last argument can be an apply argument---arbitrary\n list-producing form, which will be used as the last argument\n to (apply #'make-instance ...) idiom.\n\nNote that using a singular shortcut list of apply argument is an\nambiguous case that will be interpreted in favor of apply argument. To\nforce either of interpretations, provide shortcuts and apply arguments\nexplicitly:\n(make-instance* 'class (a b c)) ;; BAD\n(make-instance* 'class (a b c) nil) ;; GOOD\n(make-instance* 'class (when t nil)) ;; BAD\n(make-instance* 'class () (when t nil)) ;; GOOD\n\nOtherwise, the behavior is equivalent to `make-instance'.\n\nExamples:\n\nShortcut args:\n\\(make-instance* 'class (a b c))\n=>\n\\(make-instance 'class :a a :b b :c c)\n\nLast form converted into `apply' argument:\n\\(make-instance* 'class :c c :b b (when something (list :a a)))\n=>\n\\(apply #'make-instance 'class :c c :b b (when something (list :a a)))\n\nShortcut arguments, regular arguments, and form for `apply':\n\\(make-instance* 'class (b c) :x x (when something (list :a a)))\n=>\n\\(apply #'make-instance 'class :b b :c c :x x (when something (list :a a)))\n\nForm for `apply' (notice the empty shortcuts---these are required for\nunambiguous parsing):\n\\(make-instance* 'class () (when something (list :a a)))\n=>\n\\(apply #'make-instance 'class (when something (list :a a)))\n\nRegular `make-instance'-like use:\n\\(make-instance* 'class :a a-value :b b-value)\n=>\n\\(make-instance 'class :a a-value :b b-value)\"\n (when (and (= 1 (length arguments))\n (listp (first arguments)))\n (style-warn \"Body of MAKE-INSTANCE* contains a single list-like form ~a.\n\nIf you meant APPLY args, add empty shortcuts list:\n(make-instance* 'class () (apply-form))\n\nIf you meant shortcut list, add empty APPLY args:\n(make-instance* 'class (shortcuts) nil)\n\nInterpreting as APPLY args for now, but this behavior may change in\nthe future.\" arguments))\n (let* ((shortcuts-p (and (listp (first arguments))\n (> (length arguments) 1)))\n (shortcuts (when shortcuts-p\n (first arguments)))\n (arguments (if shortcuts-p\n (rest arguments)\n arguments))\n (last-appendable-form-p (oddp (length arguments)))\n (last-appendable-form (when last-appendable-form-p\n (first (last arguments))))\n (arguments (if last-appendable-form-p\n (butlast arguments)\n arguments)))\n `(,@(if last-appendable-form-p\n `(apply #'make-instance)\n `(make-instance))\n ,class\n ,@(loop for shortcut in shortcuts\n append (list (intern (symbol-name shortcut) :keyword)\n shortcut))\n ,@arguments\n ,@(when last-appendable-form-p\n (list last-appendable-form)))))", "category": "anaphoric", "technique": "nested-backquote,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(inline common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by INLINE", "input": "(inline common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro INLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(when-it nil)\n\nWhat needs to change: Macro call that should be transformed by WHEN-IT", "input": "(when-it nil)", "output": "(defmacro when-it (test &body body)\n \"Like WHEN. IT is bound to TEST.\"\n `(let ((it ,test))\n (when it\n ,@body)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(step 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by STEP", "input": "(step 'lol-gen::some-name)", "output": "(defmacro STEP ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(def-kid-slots nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEF-KID-SLOTS", "input": "(def-kid-slots nil (progn))", "output": "(defmacro def-kid-slots (&rest slot-defs)\n `(lambda (self)\n (declare (ignorable self))\n (list ,@slot-defs)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda-cmatch)\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-CMATCH", "input": "(lambda-cmatch)", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-standard-input-syntax\n nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-STANDARD-INPUT-SYNTAX", "input": "(with-standard-input-syntax\n nil\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(across 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ACROSS", "input": "(across 'lol-gen::some-name)", "output": "(defmacro ACROSS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(static-let nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by STATIC-LET", "input": "(static-let nil\n (progn))", "output": "(defmacro static-let ((&rest bindings) &body body)\n \"Like `let', except the variables are only initialized once and\nretain their values between different invocations of `body'.\n\nEvery static binding is similar to a `let' binding, except it can have\nadditional keyword arguments:\n\n- `type' Denotes the type of the variable.\n- `once' If true, then binding initialization and mutation will be\n thread-safe.\n- `flush' If true, this binding will be flushable. Defaults to true.\n- `in' Denotes the static binding group in which the binding will be\n placed for flushing. Defaults to the value of `*package'.\n- `read-only' If true, then the binding cannot be mutated with `setf'.\n\nStatic bindings can be flushed via `flush-static-binding-group' and\n`flush-all-static-binding-groups'; the latter is automatically pushed\ninto `uiop:*dump-image-hooks*' by Serapeum.\n\nAn unflushable static binding will carry its value over into dumped\nLisp binaries.\"\n (parse-static-let bindings body))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8724999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(skip nil nil)\n\nWhat needs to change: Macro call that should be transformed by SKIP", "input": "(skip nil nil)", "output": "(defmacro skip (&rest reason)\n \"Generates a TEST-SKIPPED result.\"\n `(add-result 'test-skipped :reason (format nil ,@reason)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(local*)\n\nPattern to recognize: Macro call that should be transformed by LOCAL*", "input": "(local*)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-fixtures nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-FIXTURES", "input": "(with-fixtures nil\n nil)", "output": "(defmacro with-fixtures (fixtures &body body)\n `(call-with-fixtures (lambda () ,@body) ,fixtures))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-html\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-HTML", "input": "(with-html\n nil\n (progn))", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-simple-type-map nil (progn))\n\nIssue: Macro call that should be transformed by DEFINE-SIMPLE-TYPE-MAP", "input": "(define-simple-type-map nil (progn))", "output": "(defmacro define-simple-type-map (class type)\n `(defmethod type ((,class ,class))\n ',type))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(some->>\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by SOME->>", "input": "(some->>\n nil\n nil)", "output": "(defmacro SOME->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(typecase nil (progn))\n\nPattern to recognize: Macro call that should be transformed by TYPECASE", "input": "(typecase nil (progn))", "output": "(defmacro TYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(v-defmacro nil\n nil)\n\nIssue: Macro call that should be transformed by V-DEFMACRO", "input": "(v-defmacro nil\n nil)", "output": "(defmacro v-defmacro (name lambda-list &body body)\n `(define-vari-macro ,name ,lambda-list ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fn common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by FN", "input": "(fn common-lisp:nil\n common-lisp:nil)", "output": "(defmacro FN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dcase 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DCASE", "input": "(dcase 'lol-gen::some-name)", "output": "(defmacro dcase (keyform &body clauses)\n \"DCASE is a combination of CASE 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 CASE,\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 'case))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fn nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by FN", "input": "(fn nil\n :key\n nil)", "output": "(defmacro FN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nand nil (progn))\n\nIssue: Macro call that should be transformed by NAND", "input": "(nand nil (progn))", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ccase nil :key ())\n\nIssue: Macro call that should be transformed by CCASE", "input": "(ccase nil :key ())", "output": "(defmacro CCASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dowhile-it nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DOWHILE-IT", "input": "(dowhile-it nil\n nil)", "output": "(defmacro dowhile-it (test &body body)\n \"Like DOWHILE. IT is bound to TEST.\"\n `(do ((it ,test ,test))\n ((not it))\n ,@body))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(group-by nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by GROUP-BY", "input": "(group-by nil (progn))", "output": "(defmacro GROUP-BY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defmethod* nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFMETHOD*", "input": "(defmethod* nil\n (progn))", "output": "(defmacro DEFMETHOD* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fail-compile nil (progn))\n\nPattern to recognize: Macro call that should be transformed by FAIL-COMPILE", "input": "(fail-compile nil (progn))", "output": "(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))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(alambda nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by ALAMBDA", "input": "(alambda nil\n (progn))", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(etypecase-of nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by ETYPECASE-OF", "input": "(etypecase-of nil\n :key\n nil)", "output": "(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)))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fgatherlet nil\n nil)\n\nIssue: Macro call that should be transformed by FGATHERLET", "input": "(fgatherlet nil\n nil)", "output": "(defmacro FGATHERLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(on-duplicate-key-update 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ON-DUPLICATE-KEY-UPDATE", "input": "(on-duplicate-key-update 'lol-gen::some-name)", "output": "(defmacro on-duplicate-key-update (&rest args)\n `(make-clause :on-duplicate-key-update ,@(mapcar #'expand-op args)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(prog* () nil)\n\nWhat needs to change: Macro call that should be transformed by PROG*", "input": "(prog* () nil)", "output": "(defmacro PROG* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(group-by nil (progn))\n\nIssue: Macro call that should be transformed by GROUP-BY", "input": "(group-by nil (progn))", "output": "(defmacro group-by (&rest expressions)\n `(apply #'make-clause :group-by ',expressions))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(insert-into nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by INSERT-INTO", "input": "(insert-into nil\n :key\n nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-screamer-package 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-SCREAMER-PACKAGE", "input": "(define-screamer-package 'lol-gen::some-name)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(eval-when-load\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EVAL-WHEN-LOAD", "input": "(eval-when-load\n common-lisp:nil)", "output": "(defmacro EVAL-WHEN-LOAD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(match nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by MATCH", "input": "(match nil\n nil)", "output": "(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)))))))))", "category": "dsl", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(modf-eval nil (progn))\n\nIssue: Macro call that should be transformed by MODF-EVAL", "input": "(modf-eval nil (progn))", "output": "(defmacro modf-eval (&rest args)\n `(progn ,@args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda-ematch1 common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LAMBDA-EMATCH1", "input": "(lambda-ematch1 common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro lambda-ematch1 (pattern &body body)\n \"Equivalent to (lambda (arg) (ematch arg (PATTERN BODY...))).\"\n `(lambda-ematch (,pattern ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.875} {"instruction": "Generate a defmacro form that transforms code like this:\n(string-literal nil)\n\nPattern to recognize: Macro call that should be transformed by STRING-LITERAL", "input": "(string-literal nil)", "output": "(defmacro STRING-LITERAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(in-package nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IN-PACKAGE", "input": "(in-package nil)", "output": "(defmacro IN-PACKAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dynamic-wind\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DYNAMIC-WIND", "input": "(dynamic-wind\n nil\n nil)", "output": "(defmacro DYNAMIC-WIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(char-ecase nil\n (progn))\n\nProblem: Macro call that should be transformed by CHAR-ECASE", "input": "(char-ecase nil\n (progn))", "output": "(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)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is nil nil)\n\nProblem: Macro call that should be transformed by IS", "input": "(is nil nil)", "output": "(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)))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(callf nil nil)\n\nWhat needs to change: Macro call that should be transformed by CALLF", "input": "(callf nil nil)", "output": "(defmacro callf (function place &rest args &environment env)\n \"Set PLACE to the value of calling FUNCTION on PLACE, with ARGS.\"\n (multiple-value-bind (vars vals stores setter getter)\n (get-setf-expansion place env)\n `(let* ,(mapcar #'list vars vals)\n (multiple-value-bind ,stores\n (funcall ,function ,getter ,@args)\n ,setter))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(aecase nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by AECASE", "input": "(aecase nil\n :key\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(-<>> nil)\n\nWhat needs to change: Macro call that should be transformed by -<>>", "input": "(-<>> nil)", "output": "(defmacro -<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(make-simple-appender-to-place 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by MAKE-SIMPLE-APPENDER-TO-PLACE", "input": "(make-simple-appender-to-place 'lol-gen::some-name)", "output": "(defmacro MAKE-SIMPLE-APPENDER-TO-PLACE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(f-zerop nil nil)\n\nPattern to recognize: Macro call that should be transformed by F-ZEROP", "input": "(f-zerop nil nil)", "output": "(defmacro f-zerop (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 (zerop new-basis))\n (progn\n (setf prior-fire-value (zerop new-basis))\n :propagate)\n :no-propagate)))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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", "input": "(enable-interpol-syntax)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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->", "input": "(some-> nil)", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(-> nil (progn))\n\nIssue: Macro call that should be transformed by ->", "input": "(-> nil (progn))", "output": "(defmacro -> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(and-it 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by AND-IT", "input": "(and-it 'lol-gen::some-name)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Generate a defmacro form that transforms code like this:\n(c?n)\n\nPattern to recognize: Macro call that should be transformed by C?N", "input": "(c?n)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(returning)\n\nWhat needs to change: Macro call that should be transformed by RETURNING", "input": "(returning)", "output": "(defmacro RETURNING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(selector nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SELECTOR", "input": "(selector nil\n nil)", "output": "(defmacro SELECTOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(trc nil)\n\nWrite a macro that addresses: Macro call that should be transformed by TRC", "input": "(trc nil)", "output": "(defmacro trc (tgt-form &rest os)\n (if (eql tgt-form 'nil)\n '(progn)\n (if (stringp tgt-form)\n `(without-c-dependency\n (call-trc t ,tgt-form ,@os))\n (let ((tgt (gensym)))\n ;(break \"slowww? ~a\" tgt-form)\n `(without-c-dependency\n (bif (,tgt ,tgt-form)\n (if (trcp ,tgt)\n (progn\n (assert (stringp ,(car os)) () \"trc with test expected string second, got ~a\" ,(car os))\n (call-trc t ,@os)) ;;,(car os) ,tgt ,@(cdr os)))\n (progn\n ;(trc \"trcfailed\")\n (count-it :trcfailed)))\n (count-it :tgtnileval)))))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8274999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(-<>> 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by -<>>", "input": "(-<>> 'lol-gen::some-name)", "output": "(defmacro -<>> (init &body exps) (diamond-wand init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(character-literal nil)\n\nProblem: Macro call that should be transformed by CHARACTER-LITERAL", "input": "(character-literal nil)", "output": "(defmacro CHARACTER-LITERAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(c_in\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by C_IN", "input": "(c_in\n 'lol-gen::some-name)", "output": "(defmacro c_in (&body body)\n `(c-input (:lazy :once-asked) (progn ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(jmatch nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by JMATCH", "input": "(jmatch nil\n nil)", "output": "(defmacro jmatch (form &body clauses)\n \"Similar to Trivia match macro, match the FORM (JSON value) against CLAUSES.\nCLAUSES are (PATTERN . BODY) forms, where\n- PATTERN is a `jbind' destructuring pattern.\n- And BODY is an implicit progn.\n\nIf PATTERN matches successfully in `jbind', then BODY is executed with\nthe variables from the PATTERN bound to the respective values, as per\n`jbind'.\n\nThe last clause could start with T, OTHERWISE, ELSE, or _, and it will\nbe invoked if other patterns don't match. If there's no such clause,\n`jmatch' will simply return NIL on no matching patterns.\"\n (let ((form-sym (gensym \"MATCH-FORM\")))\n `(let ((,form-sym ,form))\n (cond\n ,@(loop for (pattern . body) in clauses\n when (and (symbolp pattern)\n (member (symbol-name pattern) '(\"T\" \"_\" \"OTHERWISE\" \"ELSE\")\n :test #'string=))\n collect `(t ,@body)\n else\n collect `((ignore-errors (jbind ,pattern ,form-sym t))\n (jbind ,pattern ,form-sym ,@body)))))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Generate a defmacro form that transforms code like this:\n(matrix-typecase nil)\n\nPattern to recognize: Macro call that should be transformed by MATRIX-TYPECASE", "input": "(matrix-typecase nil)", "output": "(defmacro MATRIX-TYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(distinct-on nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DISTINCT-ON", "input": "(distinct-on nil :key nil)", "output": "(defmacro distinct-on (columns &rest fields)\n `(make-clause :distinct-on (list ,@columns) ,@(mapcar #'expand-op fields)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(actypecase 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by ACTYPECASE", "input": "(actypecase 'lol-gen::some-name)", "output": "(defmacro actypecase (keyform &body cases)\n \"Like CTYPECASE, except binds the result of the keyform to IT (via LET) for\nthe scope of the cases. Unlike CTYPECASE, new values possible stored by the\nSTORE-VALUE restart are not received by the keyform/place, but by IT.\"\n `(anaphoric ctypecase ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(modf-fn nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MODF-FN", "input": "(modf-fn nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(let-match* common-lisp:nil\n :key\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by LET-MATCH*", "input": "(let-match* common-lisp:nil\n :key\n common-lisp:nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(jand 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by JAND", "input": "(jand 'lol-gen::some-name)", "output": "(defmacro jand (&rest args)\n \"JSON-aware version of `cl:and'.\"\n `(and ,@(loop for arg in args\n collecting `(jwhen ,arg ,arg))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-active-layers* 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-ACTIVE-LAYERS*", "input": "(with-active-layers* 'lol-gen::some-name)", "output": "(defmacro WITH-ACTIVE-LAYERS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defclause-sequence nil nil)\n\nProblem: Macro call that should be transformed by DEFCLAUSE-SEQUENCE", "input": "(defclause-sequence nil nil)", "output": "(defmacro defclause-sequence (element-name index-name\n &key access-fn size-fn\n element-type sequence-type\n element-doc-string index-doc-string)\n \"A simple way to define a FOR-like &sequence clause.\"\n\n;Package subtlety: FOR should be in the same package as the\n;element-name or index-name.\"\n (let* ((seq-for (when element-name\n (intern (symbol-name 'for) (symbol-package element-name))))\n (seq-def (when element-name\n `(defclause-driver\n (,seq-for var ,element-name seq &sequence)\n ,element-doc-string\n (return-sequence-code :element-var var\n :sequence seq\n :access-fn ,access-fn\n :size-fn ,size-fn\n :element-type ,element-type\n :sequence-type ,sequence-type))))\n #+nil\n (inx-for (when index-name\n (intern (symbol-name 'for) (symbol-package index-name))))\n (inx-def (when index-name\n `(defclause-driver (:for var ,index-name seq &sequence)\n ,index-doc-string\n (if with-index\n (clause-error \"WITH-INDEX keyword should not ~\nbe specified for this clause\")\n (progn\n (setq with-index var)\n (return-sequence-code\n :sequence seq\n :size-fn ,size-fn\n :sequence-type ,sequence-type)))))))\n `(progn ,seq-def ,inx-def)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defwalker-handler nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFWALKER-HANDLER", "input": "(defwalker-handler nil\n (progn))", "output": "(defmacro DEFWALKER-HANDLER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(without-dependency-capture\n nil)\n\nIssue: Macro call that should be transformed by WITHOUT-DEPENDENCY-CAPTURE", "input": "(without-dependency-capture\n nil)", "output": "(defmacro WITHOUT-DEPENDENCY-CAPTURE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(select nil\n (progn))\n\nIssue: Macro call that should be transformed by SELECT", "input": "(select nil\n (progn))", "output": "(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))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-layered-class 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DEFINE-LAYERED-CLASS", "input": "(define-layered-class 'lol-gen::some-name)", "output": "(defmacro DEFINE-LAYERED-CLASS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(if-let nil\n (progn))\n\nProblem: Macro call that should be transformed by IF-LET", "input": "(if-let nil\n (progn))", "output": "(defmacro if-let (bindings &body (then-form &optional else-form))\n \"Creates new variable bindings, and conditionally executes either\nTHEN-FORM or ELSE-FORM. ELSE-FORM defaults to NIL.\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, the THEN-FORM is executed with the\nbindings in effect, otherwise the ELSE-FORM is executed with the bindings in\neffect.\"\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 (if (and ,@variables)\n ,then-form\n ,else-form))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c-abs nil\n (progn))\n\nProblem: Macro call that should be transformed by C-ABS", "input": "(c-abs nil\n (progn))", "output": "(defmacro c-abs (value &body body)\n `(make-c-drifter-absolute\n :code ',body\n :value-state :valid\n :value ,value\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lexpr-$send nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by LEXPR-$SEND", "input": "(lexpr-$send nil (progn))", "output": "(defmacro LEXPR-$SEND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-yield\n nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITH-YIELD", "input": "(with-yield\n nil\n :key\n nil)", "output": "(defmacro WITH-YIELD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-at-end nil :key nil)\n\nIssue: Macro call that should be transformed by COLLECT-AT-END", "input": "(collect-at-end nil :key nil)", "output": "(defmacro COLLECT-AT-END ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fm!v 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by FM!V", "input": "(fm!v 'lol-gen::some-name)", "output": "(defmacro fm!v (id)\n `(value (fm! ,id)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(->* 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by ->*", "input": "(->* 'lol-gen::some-name)", "output": "(defmacro ->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(print-object/std 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by PRINT-OBJECT/STD", "input": "(print-object/std 'lol-gen::some-name)", "output": "(defmacro print-object/std (class)\n \"Old name for DEFINE-PRINT-OBJECT/STD.\"\n `(define-print-object/std ,class))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-stealth-mixin nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by DEFINE-STEALTH-MIXIN", "input": "(define-stealth-mixin nil :key nil)", "output": "(defmacro DEFINE-STEALTH-MIXIN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(aprog1 nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by APROG1", "input": "(aprog1 nil\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-open-files 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-OPEN-FILES", "input": "(with-open-files 'lol-gen::some-name)", "output": "(defmacro with-open-files ((&rest args) &body body)\n \"A simple macro to open one or more files providing the streams for the BODY. The ARGS is a list of `(stream filespec options*)` as supplied to WITH-OPEN-FILE.\"\n (case (length args)\n ((0)\n `(progn ,@body))\n ((1)\n `(with-open-file ,(first args) ,@body))\n (t `(with-open-file ,(first args)\n (with-open-files\n ,(rest args) ,@body)))))", "category": "dsl", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(order-by nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ORDER-BY", "input": "(order-by nil :key nil)", "output": "(defmacro order-by (&rest expressions)\n `(make-clause :order-by ,@(expand-expression expressions)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-pp\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-PP", "input": "(with-pp\n nil\n nil)", "output": "(defmacro with-pp (&body body)\n `(symbol-macrolet ((stream (get-stream-generic pp))\n\t\t (indent (get-indent-generic pp))\n\t\t (--indent (dec-indent-generic pp))\n\t\t (++indent (inc-indent-generic pp)))\n (macrolet ((push-sign (x) `(push-sign-generic pp ,x))\n\t\t(pop-sign () `(pop-sign-generic pp))\n\t\t(top-sign () `(top-sign-generic pp))\n\t\t(find-sign (x) `(find-sign-generic pp ,x))\n\t\t(push-info (x) `(push-info-generic pp ,x))\n\t\t(pop-info () `(pop-info-generic pp))\n\t\t(top-info () `(top-info-generic pp))\n\t\t(find-info (x) `(find-info-generic pp ,x))\n\t\t(info-size () `(info-size-generic pp))\n\t\t(node-slot (x) `(slot-value item ',x)))\n ,@body)))", "category": "anaphoric", "technique": "symbol-macrolet,macrolet,nested-backquote,anaphor", "complexity": "advanced", "quality_score": 0.9175} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-fixture-capture nil\n nil)\n\nProblem: Macro call that should be transformed by DEFINE-FIXTURE-CAPTURE", "input": "(define-fixture-capture nil\n nil)", "output": "(defmacro define-fixture-capture (name args &body body)\n `(progn (setf (gethash ',name *fixture-captures*)\n (lambda ,args ,@body))\n ',name))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(def-kid-slots nil)\n\nIssue: Macro call that should be transformed by DEF-KID-SLOTS", "input": "(def-kid-slots nil)", "output": "(defmacro def-kid-slots (&rest slot-defs)\n `(lambda (self)\n (declare (ignorable self))\n (list ,@slot-defs)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n($slot 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by $SLOT", "input": "($slot 'lol-gen::some-name)", "output": "(defmacro $SLOT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(listcase 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by LISTCASE", "input": "(listcase 'lol-gen::some-name)", "output": "(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)))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "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", "input": "(jbind nil\n :key\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "advanced", "quality_score": 0.8099999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(odig 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by ODIG", "input": "(odig 'lol-gen::some-name)", "output": "(defmacro ODIG ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(ensure2 nil)\n\nPattern to recognize: Macro call that should be transformed by ENSURE2", "input": "(ensure2 nil)", "output": "(defmacro ensure2 (place &body newval &environment env)\n \"Like `ensure', but specifically for accessors that return a second\nvalue like `gethash'.\"\n (multiple-value-bind (vars vals stores setter getter)\n (get-setf-expansion place env)\n (with-gensyms (old presentp)\n `(let* ,(mapcar #'list vars vals)\n (multiple-value-bind (,old ,presentp)\n ,getter\n (if ,presentp\n ,old\n (multiple-value-bind ,stores\n (progn ,@newval)\n ,setter)))))))", "category": "capture-management", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-decoder-simple-list-semantics\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-DECODER-SIMPLE-LIST-SEMANTICS", "input": "(with-decoder-simple-list-semantics\n nil\n :key\n nil)", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(2nd nil)\n\nPattern to recognize: Macro call that should be transformed by 2ND", "input": "(2nd nil)", "output": "(defmacro 2nd (form)\n \"(NTH-VALUE 1 FORM)\"\n `(nth-value 1 ,form))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(-> nil\n (progn))\n\nIssue: Macro call that should be transformed by ->", "input": "(-> nil\n (progn))", "output": "(defmacro -> (init &body exps) (arrow-macro init exps))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defmacro-driver 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DEFMACRO-DRIVER", "input": "(defmacro-driver 'lol-gen::some-name)", "output": "(defmacro defmacro-driver (clause-template &body body)\n \"Macro for for defining iterators (with DEFMACRO), which may also be used\nas generators.\"\n (define-clause 'defmacro clause-template body t))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ensure-list nil)\n\nProblem: Macro call that should be transformed by ENSURE-LIST", "input": "(ensure-list nil)", "output": "(defmacro ensure-list (item &body body)\n `(let ((,item (if (listp ,item) ,item '(,item))))\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(do* () (progn))\n\nPattern to recognize: Macro call that should be transformed by DO*", "input": "(do* () (progn))", "output": "(defmacro DO* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(html5 nil)\n\nPattern to recognize: Macro call that should be transformed by HTML5", "input": "(html5 nil)", "output": "(defmacro html5 (&rest tags)\n `(with-doctype :html5\n (tag->string (cons :html ',tags))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(collect-nth nil (progn))\n\nPattern to recognize: Macro call that should be transformed by COLLECT-NTH", "input": "(collect-nth nil (progn))", "output": "(defmacro COLLECT-NTH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-ignore 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COLLECT-IGNORE", "input": "(collect-ignore 'lol-gen::some-name)", "output": "(defmacro COLLECT-IGNORE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-read-only-vars nil)\n\nIssue: Macro call that should be transformed by WITH-READ-ONLY-VARS", "input": "(with-read-only-vars nil)", "output": "(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))))", "category": "anaphoric", "technique": "symbol-macrolet,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8175} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ignoring 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by IGNORING", "input": "(ignoring 'lol-gen::some-name)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(cond-<>\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by COND-<>", "input": "(cond-<>\n nil\n (progn))", "output": "(defmacro COND-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(while nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WHILE", "input": "(while nil\n :key\n nil)", "output": "(defmacro WHILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defunwalker-handler nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFUNWALKER-HANDLER", "input": "(defunwalker-handler nil\n (progn))", "output": "(defmacro DEFUNWALKER-HANDLER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(subtest nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by SUBTEST", "input": "(subtest nil\n :key\n nil)", "output": "(defmacro subtest (desc &body body)\n `(%subtest ,desc (lambda () ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(def-metadata-infer nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEF-METADATA-INFER", "input": "(def-metadata-infer nil\n :key\n nil)", "output": "(defmacro def-metadata-infer (varjo-type-spec metadata-kind env-var &body body)\n (warn 'v-deprecated\n :old 'def-metadata-infer\n :new 'define-metadata-infer)\n `(define-metadata-infer ,varjo-type-spec ,metadata-kind ,env-var ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(multiple-value-prog2 nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by MULTIPLE-VALUE-PROG2", "input": "(multiple-value-prog2 nil\n :key\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(resolving\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by RESOLVING", "input": "(resolving\n nil\n nil)", "output": "(defmacro RESOLVING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dreletf* nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DRELETF*", "input": "(dreletf* nil)", "output": "(defmacro DRELETF* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ematch common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by EMATCH", "input": "(ematch common-lisp:nil\n common-lisp:nil)", "output": "(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))))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(sccase nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SCCASE", "input": "(sccase nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defprettymethod nil\n nil)\n\nProblem: Macro call that should be transformed by DEFPRETTYMETHOD", "input": "(defprettymethod nil\n nil)", "output": "(defmacro defprettymethod (qualifier node &body body)\n (if (eql :self qualifier)\n `(progn (setf (gethash (find-class ',node) *ignore-node*) t)\n\t (defmethod traverser\n\t\t ((pp pretty-printer) \n\t\t (item ,node) level)\n\t\t(declare (ignorable level))\n\t\t(with-slots (values subnodes) item .,body)\n\t\t(call-next-method)))\n `(defmethod traverser ,qualifier \n\t ((pp pretty-printer) \n\t (item ,node) level)\n\t (declare (ignorable level))\n\t (with-slots (values subnodes) item .,body))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(cmatch* common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CMATCH*", "input": "(cmatch* common-lisp:nil)", "output": "(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))))))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(ltbdd-with-new-hash nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by LTBDD-WITH-NEW-HASH", "input": "(ltbdd-with-new-hash nil\n nil)", "output": "(defmacro LTBDD-WITH-NEW-HASH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(jand nil :key nil)\n\nProblem: Macro call that should be transformed by JAND", "input": "(jand nil :key nil)", "output": "(defmacro jand (&rest args)\n \"JSON-aware version of `cl:and'.\"\n `(and ,@(loop for arg in args\n collecting `(jwhen ,arg ,arg))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(deletef nil nil)\n\nIssue: Macro call that should be transformed by DELETEF", "input": "(deletef nil nil)", "output": "(defmacro DELETEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(and-it)\n\nIssue: Macro call that should be transformed by AND-IT", "input": "(and-it)", "output": "(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))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.815} {"instruction": "Generate a defmacro form that transforms code like this:\n(v-defmacro nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by V-DEFMACRO", "input": "(v-defmacro nil\n :key\n nil)", "output": "(defmacro v-defmacro (name lambda-list &body body)\n `(define-vari-macro ,name ,lambda-list ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(skip nil)\n\nIssue: Macro call that should be transformed by SKIP", "input": "(skip nil)", "output": "(defmacro skip (desc &body tests)\n `(with-forced-status (:skipped ,@(if (listp desc) desc (list desc)))\n ,@tests))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defun nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFUN", "input": "(defun nil :key nil)", "output": "(defmacro DEFUN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(match 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by MATCH", "input": "(match 'lol-gen::some-name)", "output": "(defmacro MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(live)\n\nIssue: Macro call that should be transformed by LIVE", "input": "(live)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defconst nil (progn))\n\nProblem: Macro call that should be transformed by DEFCONST", "input": "(defconst nil (progn))", "output": "(defmacro defconst (symbol init &optional docstring)\n \"Define a constant, lexically.\n\n`defconst' defines a constant using a strategy similar to `def', so\nyou don\u2019t have to +cage+ your constants.\n\nThe constant is only redefined on re-evaluation if INIT has a\ndifferent literal representation than the old value.\n\nA constant defined with `defconst' is guaranteed to be available as\nsoon as it has been defined (for example, for use with reader macros\nlater in the same file). This is not guaranteed to be portably true\nfor `defconstant'.\n\nThe name is from Emacs Lisp.\"\n (let ((backing-var (symbolicate '#:+storage-for-deflex-var- symbol '+)))\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (define-constant ,backing-var ,init\n :test 'same-literal-p\n :documentation ,docstring)\n (define-symbol-macro ,symbol ,backing-var))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dletf nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by DLETF", "input": "(dletf nil\n :key\n nil)", "output": "(defmacro DLETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(xml nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by XML", "input": "(xml nil (progn))", "output": "(defmacro xml (&rest tags)\n `(with-doctype :xml\n (loop for tag in ',tags\n append (tag->string tag))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(bind nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by BIND", "input": "(bind nil\n :key\n nil)", "output": "(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)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.815} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(cell-let nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CELL-LET", "input": "(cell-let nil\n nil)", "output": "(defmacro cell-let ((&rest bindings) &body body &environment env)\n \"Define cells that are visible only to the forms in BODY.\n\nBINDINGS is a list of cell bindings to establish, similar to\nLET*. Each item in BINDINGS is a list of the form\n\n.. code-block::\n\n (NAME VALUE-FORM)\n\nwhere NAME is the symbol identifying the cell and VALUE-FORM is the\nvalue form of the cell. The cell can then be referenced within the\nforms in BODY by the symbol NAME.\n\nThe cells defined in BINDINGS lexcially shadow those in the\nenvironment defined with DEFCELL or by an enclosing CELL-LET\nform. Like LET* and unlike LET, each cell definition may reference the\ncells defined earlier in the same CELL-LET.\n\nThe forms in BODY are evaluated in an implicit PROGN. The value\nreturned by the last form is returned by the CELL-LET form.\"\n\n (flet ((make-cell-binding (binding form)\n (destructuring-bind (name &optional initform)\n (ensure-list binding)\n\n (if (constantp initform env)\n `(mutable-cell-let% (,name ,initform) ,form)\n `(computed-cell-let% (,name ,initform) ,form)))))\n\n (->> `(progn ,@body)\n (reduce #'make-cell-binding bindings :from-end t :initial-value))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(js)\n\nPattern to recognize: Macro call that should be transformed by JS", "input": "(js)", "output": "(defmacro JS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(enable-interpol-syntax 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ENABLE-INTERPOL-SYNTAX", "input": "(enable-interpol-syntax 'lol-gen::some-name)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-decoder-simple-list-semantics\n nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-DECODER-SIMPLE-LIST-SEMANTICS", "input": "(with-decoder-simple-list-semantics\n nil\n (progn))", "output": "(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))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c?dbg\n nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by C?DBG", "input": "(c?dbg\n nil\n nil)", "output": "(defmacro c?dbg (&body body)\n `(make-c-dependent\n :code ',body\n :value-state :unevaluated\n :debug t\n :rule (c-lambda ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(let-match* common-lisp:nil)\n\nProblem: Macro call that should be transformed by LET-MATCH*", "input": "(let-match* common-lisp:nil)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ps-html nil)\n\nWhat needs to change: Macro call that should be transformed by PS-HTML", "input": "(ps-html nil)", "output": "(defmacro PS-HTML ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(appendf nil)\n\nWrite a macro that addresses: Macro call that should be transformed by APPENDF", "input": "(appendf nil)", "output": "(defmacro APPENDF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(left-join nil)\n\nIssue: Macro call that should be transformed by LEFT-JOIN", "input": "(left-join nil)", "output": "(defmacro left-join (table &key on using)\n `(join ,table :kind :left :on ,on :using ,using))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-html-output-to-string 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-HTML-OUTPUT-TO-STRING", "input": "(with-html-output-to-string 'lol-gen::some-name)", "output": "(defmacro with-html-output-to-string ((var &optional string-form\n &key\n (element-type #-:lispworks ''character\n #+:lispworks ''lw:simple-char)\n prologue\n indent)\n &body body)\n \"Transform the enclosed BODY consisting of HTML as s-expressions\ninto Lisp code which creates the corresponding HTML as a string.\"\n (multiple-value-bind (declarations forms) (extract-declarations body)\n `(with-output-to-string (,var ,string-form :element-type ,element-type)\n ,@declarations\n (with-html-output (,var nil :prologue ,prologue :indent ,indent)\n ,@forms))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(export-only-always nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EXPORT-ONLY-ALWAYS", "input": "(export-only-always nil)", "output": "(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)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-transaction nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-TRANSACTION", "input": "(with-transaction nil)", "output": "(defmacro with-transaction ((&optional name isolation-level) &body body)\n \"Execute the given body within a database transaction, committing it when the\nbody exits normally, and aborting otherwise. An optional name and/or\nisolation-level can be given to the transaction. The name can be used to force\na commit or abort before the body unwinds. The isolation-level will set the\nisolation-level used by the 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 quoted\nor a string) and ... simply indicates other statements would be expected here:\n\n (with-transaction ()\n (execute (:insert-into 'test-data :set 'value 77))\n ...)\n\n (with-transaction (george)\n (execute (:insert-into 'test-data :set 'value 22))\n ...)\n\n (with-transaction (george :read-committed-rw)\n (execute (:insert-into 'test-data :set 'value 33))\n (query (:select '* :from 'test-data))\n ...)\n\n (with-transaction (:serializable)\n (execute (:insert-into 'test-data :set 'value 44))\n ...)\n\nFurther discussion of transactions and isolation levels can found in the\nisolation notes file in the doc folder.\"\n (let ((transaction-name (or (when (not (isolation-level-p name))\n name)\n (gensym \"anonymous-transaction\"))))\n (when (and name (isolation-level-p name))\n (setf isolation-level name))\n `(call-with-transaction (lambda (,transaction-name)\n (declare (ignorable ,transaction-name)) ,@body)\n ,isolation-level)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dowhile-bind 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DOWHILE-BIND", "input": "(dowhile-bind 'lol-gen::some-name)", "output": "(defmacro DOWHILE-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(finding nil (progn))\n\nIssue: Macro call that should be transformed by FINDING", "input": "(finding nil (progn))", "output": "(defmacro FINDING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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 -<>", "input": "(-<> nil nil)", "output": "(defmacro -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda () :key nil)\n\nIssue: Macro call that should be transformed by LAMBDA", "input": "(lambda () :key nil)", "output": "(defmacro LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(keep-bops nil (progn))\n\nWhat needs to change: Macro call that should be transformed by KEEP-BOPS", "input": "(keep-bops nil (progn))", "output": "(defmacro KEEP-BOPS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-contracts-enabled nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-CONTRACTS-ENABLED", "input": "(with-contracts-enabled nil\n :key\n nil)", "output": "(defmacro with-contracts-enabled\n ((&rest args &key invariants preconditions postconditions) &body body)\n \"Enables/disables contracts for the extent of this form, restoring them to\n their prior values upon exit.\"\n (declare (ignore invariants preconditions postconditions))\n (let ((enabled-contracts (gensym \"ENABLED-CONTRACTS-\")))\n `(let ((,enabled-contracts (enabled-contracts)))\n (unwind-protect\n (progn (enable-contracts ,@args)\n ,@body)\n (apply #'enable-contracts ,enabled-contracts)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.8125} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fail nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by FAIL", "input": "(fail nil :key nil)", "output": "(defmacro fail (&rest message-args)\n \"Simply generate a FAIL.\"\n `(process-failure ',message-args\n ,@message-args))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(when-match common-lisp:nil\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by WHEN-MATCH", "input": "(when-match common-lisp:nil\n common-lisp:nil)", "output": "(defmacro when-match (pattern arg &body body)\n \"Equivalent to (match ARG (PATTERN BODY...)).\"\n `(match ,arg (,pattern ,.body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(cell-let nil)\n\nPattern to recognize: Macro call that should be transformed by CELL-LET", "input": "(cell-let nil)", "output": "(defmacro cell-let ((&rest bindings) &body body &environment env)\n \"Define cells that are visible only to the forms in BODY.\n\nBINDINGS is a list of cell bindings to establish, similar to\nLET*. Each item in BINDINGS is a list of the form\n\n.. code-block::\n\n (NAME VALUE-FORM)\n\nwhere NAME is the symbol identifying the cell and VALUE-FORM is the\nvalue form of the cell. The cell can then be referenced within the\nforms in BODY by the symbol NAME.\n\nThe cells defined in BINDINGS lexcially shadow those in the\nenvironment defined with DEFCELL or by an enclosing CELL-LET\nform. Like LET* and unlike LET, each cell definition may reference the\ncells defined earlier in the same CELL-LET.\n\nThe forms in BODY are evaluated in an implicit PROGN. The value\nreturned by the last form is returned by the CELL-LET form.\"\n\n (flet ((make-cell-binding (binding form)\n (destructuring-bind (name &optional initform)\n (ensure-list binding)\n\n (if (constantp initform env)\n `(mutable-cell-let% (,name ,initform) ,form)\n `(computed-cell-let% (,name ,initform) ,form)))))\n\n (->> `(progn ,@body)\n (reduce #'make-cell-binding bindings :from-end t :initial-value))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.79} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(declaim nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DECLAIM", "input": "(declaim nil\n nil)", "output": "(defmacro DECLAIM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(nand 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by NAND", "input": "(nand 'lol-gen::some-name)", "output": "(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))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(eval-when-load)\n\nIssue: Macro call that should be transformed by EVAL-WHEN-LOAD", "input": "(eval-when-load)", "output": "(defmacro EVAL-WHEN-LOAD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(count-failures\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COUNT-FAILURES", "input": "(count-failures\n 'lol-gen::some-name)", "output": "(defmacro COUNT-FAILURES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-live-scope)\n\nWhat needs to change: Macro call that should be transformed by WITH-LIVE-SCOPE", "input": "(with-live-scope)", "output": "(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))))))", "category": "anaphoric", "technique": "macrolet,gensym,anaphor", "complexity": "intermediate", "quality_score": 0.81} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defjsmacro)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFJSMACRO", "input": "(defjsmacro)", "output": "(defmacro DEFJSMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defsyntax nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFSYNTAX", "input": "(defsyntax nil\n :key\n nil)", "output": "(defmacro defsyntax (tags packages lambda-list &body body)\n \"Define syntax for tags from specific packages\"\n (let ((tags (if (listp tags) tags (list tags))))\n `(progn\n ,@(loop for i in tags append\n\t (loop for k in packages collect\n\t `(let ((tag ',i))\n\t\t(declare (ignorable tag))\n\t\t(defmacro ,(intern (format nil \"~:@(~a~)\" i) k) ,lambda-list\n\t\t ,@body)\n\t\t(export ',(intern (format nil \"~:@(~a~)\" i) k) ,k)))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.8049999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(slet nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by SLET", "input": "(slet nil\n (progn))", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-print-object/std 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-PRINT-OBJECT/STD", "input": "(define-print-object/std 'lol-gen::some-name)", "output": "(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)))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(destructuring-case 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DESTRUCTURING-CASE", "input": "(destructuring-case 'lol-gen::some-name)", "output": "(defmacro DESTRUCTURING-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda-ematch1 common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-EMATCH1", "input": "(lambda-ematch1 common-lisp:nil\n common-lisp:nil)", "output": "(defmacro lambda-ematch1 (pattern &body body)\n \"Equivalent to (lambda (arg) (ematch arg (PATTERN BODY...))).\"\n `(lambda-ematch (,pattern ,@body)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-constant-inject-hook nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-CONSTANT-INJECT-HOOK", "input": "(with-constant-inject-hook nil\n nil)", "output": "(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)))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(.> common-lisp:nil :key common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by .>", "input": "(.> common-lisp:nil :key common-lisp:nil)", "output": "(defmacro .> (cl:&rest items)\n \"Left associative compose operator. Creates a new functions that will run the\nfunctions left to right when applied. This is the same as the `pipe` macro without supplying\nthe value. The composition is thus the reverse order of `compose`.\n\n`(.> f g h)` creates the function `(fn (x) (h (g (f x))))`.\"\n (alexandria:with-gensyms (x)\n `(fn (,x)\n (pipe ,x ,@items))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defgeneric* nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFGENERIC*", "input": "(defgeneric* nil\n (progn))", "output": "(defmacro DEFGENERIC* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(nsplice-seqf nil)\n\nPattern to recognize: Macro call that should be transformed by NSPLICE-SEQF", "input": "(nsplice-seqf nil)", "output": "(defmacro NSPLICE-SEQF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(atypecase nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by ATYPECASE", "input": "(atypecase nil\n :key\n nil)", "output": "(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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(cond->\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by COND->", "input": "(cond->\n nil\n :key\n nil)", "output": "(defmacro COND-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(call-method nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by CALL-METHOD", "input": "(call-method nil (progn))", "output": "(defmacro call-method (method &optional methods)\n `(cl:call-method ,method ,methods))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(deletef nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DELETEF", "input": "(deletef nil :key nil)", "output": "(defmacro DELETEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(loop 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by LOOP", "input": "(loop 'lol-gen::some-name)", "output": "(defmacro LOOP ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(dletf* nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DLETF*", "input": "(dletf* nil\n :key\n nil)", "output": "(defmacro DLETF* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-constant-inject-hook 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-CONSTANT-INJECT-HOOK", "input": "(with-constant-inject-hook 'lol-gen::some-name)", "output": "(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)))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(auto-permute-typecase nil\n nil)\n\nIssue: Macro call that should be transformed by AUTO-PERMUTE-TYPECASE", "input": "(auto-permute-typecase nil\n nil)", "output": "(defmacro AUTO-PERMUTE-TYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-gensyms nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WITH-GENSYMS", "input": "(with-gensyms nil\n (progn))", "output": "(defmacro with-gensyms (names &body forms)\n \"Binds a set of variables to gensyms and evaluates the implicit progn FORMS.\n\nEach element within NAMES is either a symbol SYMBOL or a pair (SYMBOL\nSTRING-DESIGNATOR). Bare symbols are equivalent to the pair (SYMBOL SYMBOL).\n\nEach pair (SYMBOL STRING-DESIGNATOR) specifies that the variable named by SYMBOL\nshould be bound to a symbol constructed using GENSYM with the string designated\nby STRING-DESIGNATOR being its first argument.\"\n `(let ,(mapcar (lambda (name)\n (multiple-value-bind (symbol string)\n (etypecase name\n (symbol\n (values name (symbol-name name)))\n ((cons symbol (cons string-designator null))\n (values (first name) (string (second name)))))\n `(,symbol (gensym ,string))))\n names)\n ,@forms))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} {"instruction": "Generate a defmacro form that transforms code like this:\n(w/uniqs nil)\n\nPattern to recognize: Macro call that should be transformed by W/UNIQS", "input": "(w/uniqs nil)", "output": "(defmacro W/UNIQS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ematch* common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by EMATCH*", "input": "(ematch* common-lisp:nil\n common-lisp:nil)", "output": "(defmacro ematch* (whats &body clauses)\n #.+match*-doc+\n (let ((temps (make-gensyms whats \"OTHERWISE\")))\n `(match2* ,whats\n ,@clauses\n (,temps\n (error 'match-error :pattern ',clauses :values (list ,@temps))))))", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(dlet nil)\n\nPattern to recognize: Macro call that should be transformed by DLET", "input": "(dlet nil)", "output": "(defmacro DLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(defhook nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by DEFHOOK", "input": "(defhook nil :key nil)", "output": "(defmacro defhook (generic-function hook-name &rest args)\n \"define a hook to be to be called by the effective method.\n\nThis macro has roughly the same signature as defmethod `(DEFHOOK GENERIC-FUNCTION HOOK-NAME {QUALIFIER} SPECIALIZED-LAMBDA-LIST &BODY BODY)`\ncreates a function `hook-name` with the `body` then creates a method to dispatch all hooks matching\nthe type-list for the given generic-function.\n\nSee define-hook-generic\nSee finalize-dispatch-method\"\n (%destructure-defhook-args args\n (destructure-specialized-lambda-list descriptive-lambda-list vanilla-lambda-list type-list specialized-lambda-list\n (with-effective-qualifier generic-function qualifier\n (intern-hook generic-function hook-name type-list qualifier)\n `(progn\n (%defhook-fun ,hook-name ,vanilla-lambda-list\n ,@body)\n (%define-method-dispatch ,generic-function ,qualifier ,specialized-lambda-list))))))", "category": "dsl", "technique": "", "complexity": "advanced", "quality_score": 0.8724999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-ps-gensyms nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-PS-GENSYMS", "input": "(with-ps-gensyms nil\n nil)", "output": "(defmacro WITH-PS-GENSYMS ...)", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dynamic-wind\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DYNAMIC-WIND", "input": "(dynamic-wind\n 'lol-gen::some-name)", "output": "(defmacro DYNAMIC-WIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(handler-bind nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by HANDLER-BIND", "input": "(handler-bind nil\n (progn))", "output": "(defmacro HANDLER-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(drelet nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DRELET", "input": "(drelet nil\n :key\n nil)", "output": "(defmacro DRELET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(assert! 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ASSERT!", "input": "(assert! 'lol-gen::some-name)", "output": "(defmacro ASSERT! ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(->> nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ->>", "input": "(->> nil\n :key\n nil)", "output": "(defmacro ->> (init &body exps) (arrow-macro init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(the-kids 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by THE-KIDS", "input": "(the-kids 'lol-gen::some-name)", "output": "(defmacro the-kids (&rest kids)\n `(let ((*parent* self))\n (packed-flat! ,@kids)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(eval-always\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n 'lol-gen::some-name)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do-generators nil\n (progn))\n\nIssue: Macro call that should be transformed by DO-GENERATORS", "input": "(do-generators nil\n (progn))", "output": "(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)))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Generate a defmacro form that transforms code like this:\n(mapping nil)\n\nPattern to recognize: Macro call that should be transformed by MAPPING", "input": "(mapping nil)", "output": "(defmacro MAPPING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(static-let* nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by STATIC-LET*", "input": "(static-let* nil\n :key\n nil)", "output": "(defmacro static-let* ((&rest bindings) &body body &environment env)\n \"Like `let*', except the variables are only initialized once and\nretain their values between different invocations of `body'.\n\nEvery static binding is similar to a `let' binding, except it can have\nadditional keyword arguments:\n\n- `type' Denotes the type of the variable.\n- `once' If true, then binding initialization and mutation will be\n thread-safe.\n- `flush' If true, this binding will be flushable. Defaults to true.\n- `in' Denotes the static binding group in which the binding will be\n placed for flushing. Defaults to the value of `*package'.\n- `read-only' If true, then the binding cannot be mutated with `setf'.\n\nStatic bindings can be flushed via `flush-static-binding-group' and\n`flush-all-static-binding-groups'; the latter is automatically pushed\ninto `uiop:*dump-image-hooks*' by Serapeum.\n\nAn unflushable static binding will carry its value over into dumped\nLisp binaries.\"\n (parse-static-let* bindings body env))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8724999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(step nil)\n\nPattern to recognize: Macro call that should be transformed by STEP", "input": "(step nil)", "output": "(defmacro STEP ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(ignore-some-conditions nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by IGNORE-SOME-CONDITIONS", "input": "(ignore-some-conditions nil\n :key\n nil)", "output": "(defmacro ignore-some-conditions ((&rest conditions) &body body)\n \"Similar to CL:IGNORE-ERRORS but the (unevaluated) CONDITIONS\nlist determines which specific conditions are to be ignored.\"\n `(handler-case\n (progn ,@body)\n ,@(loop for condition in conditions collect\n `(,condition (c) (values nil c)))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(minf 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by MINF", "input": "(minf 'lol-gen::some-name)", "output": "(defmacro MINF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(finishes\n nil)\n\nPattern to recognize: Macro call that should be transformed by FINISHES", "input": "(finishes\n nil)", "output": "(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\"))))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(eval-always\n common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro EVAL-ALWAYS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(fields 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by FIELDS", "input": "(fields 'lol-gen::some-name)", "output": "(defmacro fields (&rest fields)\n `(make-clause :fields ,@(mapcar #'expand-op fields)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(handler-bind nil)\n\nPattern to recognize: Macro call that should be transformed by HANDLER-BIND", "input": "(handler-bind nil)", "output": "(defmacro HANDLER-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(match nil)\n\nIssue: Macro call that should be transformed by MATCH", "input": "(match nil)", "output": "(defmacro MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(while 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WHILE", "input": "(while 'lol-gen::some-name)", "output": "(defmacro WHILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(jwhen nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by JWHEN", "input": "(jwhen nil\n (progn))", "output": "(defmacro jwhen (test &body body)\n \"JSON-aware version of `cl:when'.\nIf TEST is `jtruep' evaluate BODY.\"\n `(jif ,test\n (progn ,@body)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(secase nil\n (progn))\n\nIssue: Macro call that should be transformed by SECASE", "input": "(secase nil\n (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-global-var* nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-GLOBAL-VAR*", "input": "(define-global-var* nil nil)", "output": "(defmacro DEFINE-GLOBAL-VAR* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defloop nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFLOOP", "input": "(defloop nil\n (progn))", "output": "(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))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(as common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AS", "input": "(as common-lisp:nil)", "output": "(defmacro as (type cl:&optional (expr cl:nil expr-supplied-p))\n \"A syntactic convenience for type casting.\n\n (as )\n\nis equivalent to\n\n (the (into ))\n\nand\n\n (as )\n\nis equivalent to\n\n (fn (expr) (the (into expr))).\n\nNote that this may copy the object or allocate memory.\"\n\n (cl:let ((into (cl:ignore-errors (cl:find-symbol \"INTO\" \"COALTON/CLASSES\"))))\n (cl:assert into () \"`as` macro does not have access to `into` yet.\")\n (cl:if expr-supplied-p\n `(the ,type (,into ,expr))\n (alexandria:with-gensyms (lexpr)\n `(fn (,lexpr)\n (the ,type (,into ,lexpr)))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defgeneric* nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFGENERIC*", "input": "(defgeneric* nil\n nil)", "output": "(defmacro DEFGENERIC* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(execute 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by EXECUTE", "input": "(execute 'lol-gen::some-name)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "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 @", "input": "(@ nil (progn))", "output": "(defmacro @ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-active-layers* nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-ACTIVE-LAYERS*", "input": "(with-active-layers* nil\n nil)", "output": "(defmacro WITH-ACTIVE-LAYERS* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(eval-when-execute\n common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by EVAL-WHEN-EXECUTE", "input": "(eval-when-execute\n common-lisp:nil\n common-lisp:nil)", "output": "(defmacro EVAL-WHEN-EXECUTE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(or)\n\nWhat needs to change: Macro call that should be transformed by OR", "input": "(or)", "output": "(defmacro OR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda-cmatch\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-CMATCH", "input": "(lambda-cmatch\n common-lisp:nil)", "output": "(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)))))", "category": "capture-management", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(coercef nil (progn))\n\nWhat needs to change: Macro call that should be transformed by COERCEF", "input": "(coercef nil (progn))", "output": "(defmacro COERCEF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(or nil nil)\n\nWhat needs to change: Macro call that should be transformed by OR", "input": "(or nil nil)", "output": "(defmacro OR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(rte-case 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by RTE-CASE", "input": "(rte-case 'lol-gen::some-name)", "output": "(defmacro RTE-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(right nil (progn))\n\nWhat needs to change: Macro call that should be transformed by RIGHT", "input": "(right nil (progn))", "output": "(defmacro right (parser &rest parsers)\n \"Combination of parsers yielding the result of the rightmost one.\"\n `(*> ,parser ,@parsers))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defvar nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFVAR", "input": "(defvar nil)", "output": "(defmacro DEFVAR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(do-sequences nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DO-SEQUENCES", "input": "(do-sequences nil\n (progn))", "output": "(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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(aetypecase nil)\n\nWrite a macro that addresses: Macro call that should be transformed by AETYPECASE", "input": "(aetypecase nil)", "output": "(defmacro aetypecase (keyform &body cases)\n \"Like ETYPECASE, except binds the result of the keyform to IT (via LET) for\nthe scope of the cases.\"\n `(anaphoric etypecase ,keyform ,@cases))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(sor nil :key nil)\n\nIssue: Macro call that should be transformed by SOR", "input": "(sor nil :key nil)", "output": "(defmacro sor (first &rest rest)\n \"Like OR, except binds the first argument to IT (via SYMBOL-MACROLET) for\nthe scope of the rest of the arguments. IT can be set with SETF.\"\n `(symbolic or ,first ,@rest))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(case-using nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CASE-USING", "input": "(case-using nil\n :key\n nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.9125} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ignore-errors nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IGNORE-ERRORS", "input": "(ignore-errors nil)", "output": "(defmacro IGNORE-ERRORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "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", "input": "(cll-inner nil)", "output": "(defmacro cll-inner (expr)\n `(,expr outer-val))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(pprint-logical-block 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by PPRINT-LOGICAL-BLOCK", "input": "(pprint-logical-block 'lol-gen::some-name)", "output": "(defmacro PPRINT-LOGICAL-BLOCK ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(inext-or-error nil (progn))\n\nProblem: Macro call that should be transformed by INEXT-OR-ERROR", "input": "(inext-or-error nil (progn))", "output": "(defmacro INEXT-OR-ERROR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(c-formula nil)\n\nWrite a macro that addresses: Macro call that should be transformed by C-FORMULA", "input": "(c-formula nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defmethod* nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEFMETHOD*", "input": "(defmethod* nil nil)", "output": "(defmacro DEFMETHOD* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(define-test+run nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFINE-TEST+RUN", "input": "(define-test+run nil\n (progn))", "output": "(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))))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda-ematch*\n common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LAMBDA-EMATCH*", "input": "(lambda-ematch*\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro lambda-ematch* (&body body)\n \"Equivalent to (lambda (args...) (ematch* (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 (ematch* ,gensyms\n ,@clauses)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(pprint-coalton-codegen-ast\n common-lisp:nil\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-AST", "input": "(pprint-coalton-codegen-ast\n common-lisp:nil\n common-lisp:nil)", "output": "(defmacro PPRINT-COALTON-CODEGEN-AST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-html-string\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-HTML-STRING", "input": "(with-html-string\n nil\n :key\n nil)", "output": "(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)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(xml nil nil)\n\nPattern to recognize: Macro call that should be transformed by XML", "input": "(xml nil nil)", "output": "(defmacro xml (&rest tags)\n `(with-doctype :xml\n (loop for tag in ',tags\n append (tag->string tag))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-boolean nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-BOOLEAN", "input": "(with-boolean nil\n :key\n nil)", "output": "(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)))))))))", "category": "anaphoric", "technique": "symbol-macrolet,macrolet,anaphor", "complexity": "intermediate", "quality_score": 0.9075} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-tokens nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-TOKENS", "input": "(with-tokens nil\n :key\n nil)", "output": "(defmacro with-tokens (tokens &body body)\n `(let ((*tokens* ,tokens)\n (*toplevel* nil))\n (trivial-with-current-source-form:with-current-source-form (*tokens*)\n ,@body)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fm! nil)\n\nWhat needs to change: Macro call that should be transformed by FM!", "input": "(fm! nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(sccase 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by SCCASE", "input": "(sccase 'lol-gen::some-name)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-type-dispatch nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-TYPE-DISPATCH", "input": "(with-type-dispatch nil\n nil)", "output": "(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))))))))))))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8875} {"instruction": "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", "input": "(with-guessing-encoder\n nil\n (progn))", "output": "(defmacro with-guessing-encoder (&body body)\n `(with-local-encoder (use-guessing-encoder)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defun-advisable nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFUN-ADVISABLE", "input": "(defun-advisable nil\n (progn))", "output": "(defmacro DEFUN-ADVISABLE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defwalker-handler 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFWALKER-HANDLER", "input": "(defwalker-handler 'lol-gen::some-name)", "output": "(defmacro DEFWALKER-HANDLER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(delete-from-plistf nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DELETE-FROM-PLISTF", "input": "(delete-from-plistf nil :key nil)", "output": "(defmacro DELETE-FROM-PLISTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(enable-fn-syntax)\n\nIssue: Macro call that should be transformed by ENABLE-FN-SYNTAX", "input": "(enable-fn-syntax)", "output": "(defmacro ENABLE-FN-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defmd nil (progn))\n\nIssue: Macro call that should be transformed by DEFMD", "input": "(defmd nil (progn))", "output": "(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)))))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(min-of nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by MIN-OF", "input": "(min-of nil\n nil)", "output": "(defmacro MIN-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(select-dao nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by SELECT-DAO", "input": "(select-dao nil :key nil)", "output": "(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))))", "category": "efficiency", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-shared-method nil\n nil)\n\nIssue: Macro call that should be transformed by DEFINE-SHARED-METHOD", "input": "(define-shared-method nil\n nil)", "output": "(defmacro DEFINE-SHARED-METHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(undefreply 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by UNDEFREPLY", "input": "(undefreply 'lol-gen::some-name)", "output": "(defmacro UNDEFREPLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(deftable nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFTABLE", "input": "(deftable nil)", "output": "(defmacro deftable (name &body definitions)\n \"Define a table. name can be either a symbol or a (symbol string) list. In the\nfirst case, the table name is derived from the symbol by S-SQL's rules, in the\nsecond case, the name is given explicitly. The body of definitions can contain\nanything that evaluates to a string, as well as S-SQL expressions. In this body,\nthe variables *table-name* and *table-symbol* are bound to the relevant values.\nNote that the evaluation of the definition is ordered, so you will generally\nwant to create your table first and then define indices on it.\"\n (multiple-value-bind (symbol name)\n (if (consp name) (values-list name) (values name (to-sql-name name nil)))\n (flet ((check-s-sql (form)\n (if (and (consp form) (keywordp (car form))) (list 'sql form) form)))\n `(add-table-definition\n ',symbol\n (lambda ()\n (let ((*table-name* ,name) (*table-symbol* ',symbol))\n (dolist (stat (list ,@(mapcar #'check-s-sql definitions)))\n (execute stat))))))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-test 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-TEST", "input": "(define-test 'lol-gen::some-name)", "output": "(defmacro define-test (name &body arguments-and-body)\n (destructuring-bind (nparent name) (if (listp name) name (list NIL name))\n (form-fiddle:with-body-options (body options parent home (test-class 'test) (compile-at :compile-time) defun) arguments-and-body\n (let ((body (remove 'define-test body :key (lambda (a) (when (listp a) (car a))) :test #'eql))\n (defs (remove 'define-test body :key (lambda (a) (when (listp a) (car a))) :test-not #'eql))\n (home-form (or home `(find-package ,(package-name *package*)))))\n (when (and parent nparent)\n (error \"Cannot specify parent through name and through a keyword argument at the same time!\"))\n `(let ((*package* (find-package ,(package-name *package*)))) ; Make sure package stays consistent throughout initialisation.\n (setf (find-test ',name ,home-form)\n (ensure-test ',test-class\n :name ',name\n :home ,home-form\n :tests (list ,@(loop for form in body\n collect (ecase compile-at\n (:compile-time `(lambda () ,form))\n (:execute `(lambda () (call-compile ',form))))))\n :parent ',(or parent nparent)\n ,@(loop for option in options\n collect `',option)))\n ,@(loop for (def subname . body) in defs\n collect `(,def (,name ,subname)\n :home ,home\n ,@body))\n ,@(when defun\n `((defun ,(if (stringp name) (read-symbol name) name) (&rest test-args)\n (apply #'test (find-test ',name ,home-form) test-args))))\n ',name)))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(dynamic-relet nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DYNAMIC-RELET", "input": "(dynamic-relet nil\n :key\n nil)", "output": "(defmacro DYNAMIC-RELET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fgathering nil)\n\nProblem: Macro call that should be transformed by FGATHERING", "input": "(fgathering nil)", "output": "(defmacro FGATHERING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-symbol-access\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-SYMBOL-ACCESS", "input": "(with-symbol-access\n nil\n :key\n nil)", "output": "(defmacro WITH-SYMBOL-ACCESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(when-let* 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WHEN-LET*", "input": "(when-let* 'lol-gen::some-name)", "output": "(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))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(untrace nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by UNTRACE", "input": "(untrace nil :key nil)", "output": "(defmacro UNTRACE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(jif nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by JIF", "input": "(jif nil (progn))", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(some-> nil nil)\n\nIssue: Macro call that should be transformed by SOME->", "input": "(some-> nil nil)", "output": "(defmacro SOME-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(create-view 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by CREATE-VIEW", "input": "(create-view 'lol-gen::some-name)", "output": "(defmacro create-view (view-name &key or-replace as)\n `(make-statement :create-view ,view-name\n :or-replace ,or-replace\n :as ,as))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(match 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by MATCH", "input": "(match 'lol-gen::some-name)", "output": "(defmacro match (arg &body clauses)\n \"Matches ARG with CLAUSES. CLAUSES is a list of the form of (PATTERN\n. BODY) where PATTERN is a pattern specifier and BODY is an implicit\nprogn. If ARG matches some PATTERN, `match` then evaluates\nthe corresponding BODY and returns the evaluated value. If no pattern matches,\nthen returns NIL.\n\nEvaluating a form (FAIL) in the clause body causes the latest pattern\nmatching to fail. For example,\n\n (match 1\n (x (if (eql x 1)\n (fail)\n x))\n (_ 'ok))\n\nreturns OK, because the form (FAIL) in the first clause is\nevaluated.\n\nIf BODY starts with the symbols WHEN or UNLESS, then the next form\nwill be used to introduce (FAIL). That is,\n\n (match list ((list x) when (oddp x) x))\n (match list ((list x) unless (evenp x) x))\n\nwill be translated to\n\n (match list ((list x) (if (oddp x) x (fail))))\n (match list ((list x) (if (evenp x) (fail) x)))\n\nExamples:\n\n (match 1 (1 1))\n => 1\n (match 1 (2 2))\n => 2\n (match 1 (x x))\n => 1\n (match (list 1 2 3)\n (list x y z) (+ x y z))\n => 6\"\n (compile-match-1 arg clauses nil))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(once-only nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ONCE-ONLY", "input": "(once-only nil)", "output": "(defmacro once-only (specs &body forms)\n \"Evaluate FORMS with names rebound to temporary variables, ensuring\n that each is evaluated only once.\n\n Each SPEC must be either a NAME, or a (NAME INITFORM), with plain\n NAME using the named variable as initform.\n\n Example:\n\n CL-USER> (defmacro cons1 (x)\n (once-only (x)\n `(cons ,x ,x)))\n CL-USER> (let ((y 0))\n (cons1 (incf y)))\n (1 . 1)\n\"\n (let ((gensyms (make-gensym-list (length specs) \"OO\"))\n (names-and-forms (mapcar (lambda (spec)\n (etypecase spec\n (list\n (destructuring-bind (name form) spec\n (cons name form)))\n (symbol\n (cons spec spec))))\n (remove-if-not #`(or (symbolp %) (listp %))\n specs))))\n ;; bind in user-macro\n `(let ,(mapcar #`(list % `(gensym ,(string (car %%))))\n gensyms names-and-forms)\n ;; bind in final expansion\n `(let (,,@(mapcar (lambda (g n) ``(,,g ,,(cdr n)))\n gensyms names-and-forms))\n ;; bind in user-macro\n ,(let ,(mapcar #`(list (car %) %%)\n names-and-forms gensyms)\n ,@forms)))))", "category": "control-flow", "technique": "once-only,gensym,nested-backquote,recursive-expansion", "complexity": "advanced", "quality_score": 0.9099999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(advisable-lambda nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ADVISABLE-LAMBDA", "input": "(advisable-lambda nil\n nil)", "output": "(defmacro ADVISABLE-LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(for nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by FOR", "input": "(for nil\n nil)", "output": "(defmacro FOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(decf nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DECF", "input": "(decf nil (progn))", "output": "(defmacro DECF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-hook-restart\n nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-HOOK-RESTART", "input": "(with-hook-restart\n nil\n nil)", "output": "(defmacro with-hook-restart (&body body)\n `(with-simple-restart (continue \"Call next function in hook ~s\" *hook*)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-took-usec 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-TOOK-USEC", "input": "(with-took-usec 'lol-gen::some-name)", "output": "(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))))))))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ok nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by OK", "input": "(ok nil (progn))", "output": "(defmacro ok (offset value)\n \"Parsing was successful.\"\n `(values ,value ,offset))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(gen-lambda-with-sticky-stop)\n\nProblem: Macro call that should be transformed by GEN-LAMBDA-WITH-STICKY-STOP", "input": "(gen-lambda-with-sticky-stop)", "output": "(defmacro gen-lambda-with-sticky-stop (&rest rest)\n `(make-instance \n 'basic-generator \n :function (sticky-stop-lambda ,@rest)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-script-symbol-macro 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DEFINE-SCRIPT-SYMBOL-MACRO", "input": "(define-script-symbol-macro 'lol-gen::some-name)", "output": "(defmacro DEFINE-SCRIPT-SYMBOL-MACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fn nil (progn))\n\nProblem: Macro call that should be transformed by FN", "input": "(fn nil (progn))", "output": "(defmacro fn (name type)\n \"A shorthand for declaiming function types.\"\n `(declaim (ftype ,type ,name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(->> nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by ->>", "input": "(->> nil :key nil)", "output": "(defmacro ->> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(c_?\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by C_?", "input": "(c_?\n 'lol-gen::some-name)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do-sequences! nil)\n\nIssue: Macro call that should be transformed by DO-SEQUENCES!", "input": "(do-sequences! nil)", "output": "(defmacro do-sequences! (name/seqs &body forms &environment env)\n \"Mutable version of DO-SEQUENCES.\n\n This is the same as DO-SEQUENCES however each NAME, is the name of\n a symbol-macro, that is introduced, which expands to the 'place',\n suitable for use with SETF, of the current sequence element, rather\n than a variable storing its value. This allows the elements of the\n sequence to be mutated.\n\n NOTE: This macro does not support destructuring of the sequence\n elements.\"\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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-filtered-function nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-FILTERED-FUNCTION", "input": "(define-filtered-function nil\n nil)", "output": "(defmacro DEFINE-FILTERED-FUNCTION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(iterate\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ITERATE", "input": "(iterate\n nil\n :key\n nil)", "output": "(defmacro ITERATE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(is-values nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by IS-VALUES", "input": "(is-values nil\n nil)", "output": "(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)))))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(-> nil (progn))\n\nProblem: Macro call that should be transformed by ->", "input": "(-> nil (progn))", "output": "(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)))))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(vref nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by VREF", "input": "(vref nil (progn))", "output": "(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)))", "category": "dsl", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Generate a defmacro form that transforms code like this:\n(make-kid nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by MAKE-KID", "input": "(make-kid nil :key nil)", "output": "(defmacro make-kid (class &rest ia)\n (with-gensyms (c)\n `(let ((,c ,class))\n (make-instance ,c\n ,@ia\n :fm-parent (progn (assert self () \"make-kid: self nil making ~a\" ,c)\n self)))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "basic", "quality_score": 0.7849999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(unless 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by UNLESS", "input": "(unless 'lol-gen::some-name)", "output": "(defmacro UNLESS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(fail-compile nil)\n\nWhat needs to change: Macro call that should be transformed by FAIL-COMPILE", "input": "(fail-compile nil)", "output": "(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))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(doseq 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DOSEQ", "input": "(doseq 'lol-gen::some-name)", "output": "(defmacro doseq ((var seq-form &optional result-form) &body body)\n \"doseq iterates over the elements of an sequence and binds value-var to successive values\nand then evaluates body as a tagbody that can include declarations. Finally the result-form\nis returned after the iteration completes.\"\n #+clisp\n `(ext:doseq (,var ,seq-form ,result-form)\n ,@body)\n #+sbcl\n `(sb-sequence:dosequence (,var ,seq-form ,result-form)\n ,@body)\n #-(or clisp sbcl)\n `(doseq* (,(gensym) ,var ,seq-form ,result-form)\n ,@body))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.8225} {"instruction": "Generate a defmacro form that transforms code like this:\n(scond\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by SCOND", "input": "(scond\n 'lol-gen::some-name)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Generate a defmacro form that transforms code like this:\n(use-syntax 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by USE-SYNTAX", "input": "(use-syntax 'lol-gen::some-name)", "output": "(defmacro use-syntax (name)\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (%use-syntax ,name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(match common-lisp:nil\n (common-lisp:progn))\n\nIssue: Macro call that should be transformed by MATCH", "input": "(match common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro match (what &body clauses)\n #.+match-doc+\n `(match2 ,what\n ,@clauses\n (_ nil)))", "category": "control-flow", "technique": "recursive-expansion", "complexity": "intermediate", "quality_score": 0.8999999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(keep-bops 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by KEEP-BOPS", "input": "(keep-bops 'lol-gen::some-name)", "output": "(defmacro KEEP-BOPS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-pp)\n\nIssue: Macro call that should be transformed by WITH-PP", "input": "(with-pp)", "output": "(defmacro with-pp (&body body)\n `(symbol-macrolet ((stream (get-stream-generic pp))\n\t\t (indent (get-indent-generic pp))\n\t\t (--indent (dec-indent-generic pp))\n\t\t (++indent (inc-indent-generic pp)))\n (macrolet ((push-sign (x) `(push-sign-generic pp ,x))\n\t\t(pop-sign () `(pop-sign-generic pp))\n\t\t(top-sign () `(top-sign-generic pp))\n\t\t(find-sign (x) `(find-sign-generic pp ,x))\n\t\t(push-info (x) `(push-info-generic pp ,x))\n\t\t(pop-info () `(pop-info-generic pp))\n\t\t(top-info () `(top-info-generic pp))\n\t\t(find-info (x) `(find-info-generic pp ,x))\n\t\t(info-size () `(info-size-generic pp))\n\t\t(node-slot (x) `(slot-value item ',x)))\n ,@body)))", "category": "anaphoric", "technique": "symbol-macrolet,macrolet,nested-backquote,anaphor", "complexity": "advanced", "quality_score": 0.9175} {"instruction": "Generate a defmacro form that transforms code like this:\n(defstore nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFSTORE", "input": "(defstore nil\n (progn))", "output": "(defmacro defstore (store-name store-lambda-list &body body &environment env)\n (let* ((store-class-name (second (find :store-class body :key #'first)))\n (store-class (etypecase store-class-name\n (null (find-class 'standard-store))\n (symbol (find-class store-class-name))))\n (form (apply #'defstore-using-class store-class store-name store-lambda-list\n :environment env\n (mapcan #'(lambda (item)\n (cond ((eql (first item) :store-class)\n `(:store-class ',store-class-name))\n ((and (member (first item) '(:documentation :specialization-class)))\n (if (= 2 (length item))\n item\n (error \"Invalid store definition option: ~W.\" item)))\n (t\n (list (first item) (rest item)))))\n body))))\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n ,form)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-append 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by COLLECT-APPEND", "input": "(collect-append 'lol-gen::some-name)", "output": "(defmacro COLLECT-APPEND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(alt nil (progn))\n\nProblem: Macro call that should be transformed by ALT", "input": "(alt nil (progn))", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defrule nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFRULE", "input": "(defrule nil\n nil)", "output": "(defmacro DEFRULE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(fm? nil nil)\n\nPattern to recognize: Macro call that should be transformed by FM?", "input": "(fm? nil nil)", "output": "(defmacro fm? (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))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(eval-and-compile)\n\nWhat needs to change: Macro call that should be transformed by EVAL-AND-COMPILE", "input": "(eval-and-compile)", "output": "(defmacro eval-and-compile (&body body)\n \"Emacs's `eval-and-compile'.\nAlias for `eval-always'.\"\n `(eval-always\n ,@body))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-standard-io-syntax 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-STANDARD-IO-SYNTAX", "input": "(with-standard-io-syntax 'lol-gen::some-name)", "output": "(defmacro WITH-STANDARD-IO-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(<* nil (progn))\n\nIssue: Macro call that should be transformed by <*", "input": "(<* nil (progn))", "output": "(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)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(order-by)\n\nWhat needs to change: Macro call that should be transformed by ORDER-BY", "input": "(order-by)", "output": "(defmacro order-by (&rest expressions)\n `(make-clause :order-by ,@(expand-expression expressions)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collecting-into nil)\n\nIssue: Macro call that should be transformed by COLLECTING-INTO", "input": "(collecting-into nil)", "output": "(defmacro COLLECTING-INTO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda-ematch*\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by LAMBDA-EMATCH*", "input": "(lambda-ematch*\n common-lisp:nil)", "output": "(defmacro lambda-ematch* (&body body)\n \"Equivalent to (lambda (args...) (ematch* (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 (ematch* ,gensyms\n ,@clauses)))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(nix nil)\n\nWhat needs to change: Macro call that should be transformed by NIX", "input": "(nix nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with* nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH*", "input": "(with* nil\n :key\n nil)", "output": "(defmacro WITH* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(shift-incf 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by SHIFT-INCF", "input": "(shift-incf 'lol-gen::some-name)", "output": "(defmacro SHIFT-INCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(awhen nil)\n\nProblem: Macro call that should be transformed by AWHEN", "input": "(awhen nil)", "output": "(defmacro AWHEN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(from nil (progn))\n\nWhat needs to change: Macro call that should be transformed by FROM", "input": "(from nil (progn))", "output": "(defmacro from (&rest statements)\n `(make-clause :from ,@(mapcar #'expand-op statements)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defvar nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEFVAR", "input": "(defvar nil nil)", "output": "(defmacro DEFVAR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(eval-always\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Generate a defmacro form that transforms code like this:\n(with-reducer 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-REDUCER", "input": "(with-reducer 'lol-gen::some-name)", "output": "(defmacro WITH-REDUCER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Generate a defmacro form that transforms code like this:\n(splice-seqf nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by SPLICE-SEQF", "input": "(splice-seqf nil :key nil)", "output": "(defmacro SPLICE-SEQF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(all-of 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ALL-OF", "input": "(all-of 'lol-gen::some-name)", "output": "(defmacro ALL-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defpattern-inline common-lisp:nil\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPATTERN-INLINE", "input": "(defpattern-inline common-lisp:nil\n common-lisp:nil)", "output": "(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))))))))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.9125} {"instruction": "Generate a defmacro form that transforms code like this:\n(export-constructors\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by EXPORT-CONSTRUCTORS", "input": "(export-constructors\n 'lol-gen::some-name)", "output": "(defmacro EXPORT-CONSTRUCTORS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(returning 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by RETURNING", "input": "(returning 'lol-gen::some-name)", "output": "(defmacro returning (&rest expressions)\n `(apply #'make-clause :returning\n (list ,@(mapcar (lambda (expr)\n (if (and (listp expr)\n (keywordp (car expr)))\n (expand-op expr)\n `,expr))\n expressions))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-standard-input-syntax\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-STANDARD-INPUT-SYNTAX", "input": "(with-standard-input-syntax\n nil\n :key\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-type-dispatch nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-TYPE-DISPATCH", "input": "(with-type-dispatch nil\n :key\n nil)", "output": "(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))))))))))))", "category": "anaphoric", "technique": "anaphor", "complexity": "advanced", "quality_score": 0.8875} {"instruction": "Generate a defmacro form that transforms code like this:\n(global\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by GLOBAL", "input": "(global\n nil\n (progn))", "output": "(defmacro GLOBAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lambda* nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA*", "input": "(lambda* nil\n :key\n nil)", "output": "(defmacro LAMBDA* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(mvlet nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by MVLET", "input": "(mvlet nil\n :key\n nil)", "output": "(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))))))", "category": "control-flow", "technique": "gensym,recursive-expansion", "complexity": "advanced", "quality_score": 0.8975} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dispatch-case nil\n nil)\n\nIssue: Macro call that should be transformed by DISPATCH-CASE", "input": "(dispatch-case nil\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.835} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(destructuring-bind () nil)\n\nProblem: Macro call that should be transformed by DESTRUCTURING-BIND", "input": "(destructuring-bind () nil)", "output": "(defmacro DESTRUCTURING-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Generate a defmacro form that transforms code like this:\n(do+\n nil)\n\nPattern to recognize: Macro call that should be transformed by DO+", "input": "(do+\n nil)", "output": "(defmacro do+ (&body body)\n \"High-level, extensible iteration construct. Refer to the manual for syntax and semantics.\"\n `(do+/internal nil ,@body))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-unknown-first-class-functions-allowed\n nil)\n\nProblem: Macro call that should be transformed by WITH-UNKNOWN-FIRST-CLASS-FUNCTIONS-ALLOWED", "input": "(with-unknown-first-class-functions-allowed\n nil)", "output": "(defmacro with-unknown-first-class-functions-allowed (&body body)\n `(let ((*allow-call-function-signature* t))\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(like nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LIKE", "input": "(like nil nil)", "output": "(defmacro like (got regex &optional desc)\n (with-gensyms (duration result)\n (once-only (regex desc)\n `(with-catching-errors (:description ,desc :expected ,regex)\n (with-duration ((,duration ,result) ,got)\n (test ,result ,regex ,desc\n :duration ,duration\n :test-fn (lambda (x y) (not (null (ppcre:scan y x))))\n :report-expected-label \"be like\"))))))", "category": "capture-management", "technique": "once-only,gensym", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(builder)\n\nWrite a macro that addresses: Macro call that should be transformed by BUILDER", "input": "(builder)", "output": "(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)))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(setypecase nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SETYPECASE", "input": "(setypecase nil\n :key\n nil)", "output": "(defmacro setypecase (keyform &body cases)\n \"Like ETYPECASE, except binds the keyform to IT (via SYMBOL-MACROLET) for\nthe scope of the cases. IT can be set with SETF.\"\n `(symbolic etypecase ,keyform ,@cases))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(optimize)\n\nWrite a macro that addresses: Macro call that should be transformed by OPTIMIZE", "input": "(optimize)", "output": "(defmacro OPTIMIZE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(caching-types)\n\nProblem: Macro call that should be transformed by CACHING-TYPES", "input": "(caching-types)", "output": "(defmacro CACHING-TYPES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(lambda (quote lol-gen::some-name))\n\nIssue: Macro call that should be transformed by LAMBDA", "input": "(lambda (quote lol-gen::some-name))", "output": "(defmacro LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(ccase-of nil\n (progn))\n\nProblem: Macro call that should be transformed by CCASE-OF", "input": "(ccase-of nil\n (progn))", "output": "(defmacro ccase-of (type keyplace &body body &environment env)\n \"Like `ecase-of', but providing a `store-value' restart to correct KEYPLACE and try again.\"\n (check-exhaustiveness 'case type body env)\n `(ccase ,keyplace ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do+)\n\nIssue: Macro call that should be transformed by DO+", "input": "(do+)", "output": "(defmacro do+ (&body body)\n \"High-level, extensible iteration construct. Refer to the manual for syntax and semantics.\"\n `(do+/internal nil ,@body))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(cond-> nil (progn))\n\nWhat needs to change: Macro call that should be transformed by COND->", "input": "(cond-> nil (progn))", "output": "(defmacro COND-> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(dreletf nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DRELETF", "input": "(dreletf nil\n :key\n nil)", "output": "(defmacro DRELETF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-yield\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-YIELD", "input": "(with-yield\n 'lol-gen::some-name)", "output": "(defmacro WITH-YIELD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defmacro/ps nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFMACRO/PS", "input": "(defmacro/ps nil\n (progn))", "output": "(defmacro DEFMACRO/PS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(re-setf nil :key nil)\n\nProblem: Macro call that should be transformed by RE-SETF", "input": "(re-setf nil :key nil)", "output": "(defmacro re-setf (var &rest clauses)\n \"SETFs VAR to the value of each clause subsequently.\n Re-uses the new value of VAR in subsequent clauses.\n Expects VAR to be a valid place for SETF.\"\n `(progn ,@(mapcar (lambda (clause)\n `(setf ,var ,clause))\n clauses)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fn common-lisp:nil\n (common-lisp:progn))\n\nIssue: Macro call that should be transformed by FN", "input": "(fn common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro FN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(as->* nil)\n\nWhat needs to change: Macro call that should be transformed by AS->*", "input": "(as->* nil)", "output": "(defmacro AS->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nix nil nil)\n\nIssue: Macro call that should be transformed by NIX", "input": "(nix nil nil)", "output": "(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))))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(asif nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by ASIF", "input": "(asif nil (progn))", "output": "(defmacro asif (test then &optional else)\n \"Like IF, except binds the result of the test to IT (via LET) for\nthe the scope of the then-expression, and the test form to IT (via\nSYMBOL-MACROLET) for the scope of the else-expression. Within scope of\nthe else-expression, IT can be set with SETF.\"\n `(let ((it ,test))\n (if it\n\t ,then\n\t (symbolic ignore-first ,test ,else))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(resolving)\n\nWhat needs to change: Macro call that should be transformed by RESOLVING", "input": "(resolving)", "output": "(defmacro RESOLVING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(some-<>\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by SOME-<>", "input": "(some-<>\n 'lol-gen::some-name)", "output": "(defmacro SOME-<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defmethod* nil)\n\nWhat needs to change: Macro call that should be transformed by DEFMETHOD*", "input": "(defmethod* nil)", "output": "(defmacro DEFMETHOD* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(def-launched-iter nil\n nil)\n\nProblem: Macro call that should be transformed by DEF-LAUNCHED-ITER", "input": "(def-launched-iter nil\n nil)", "output": "(defmacro DEF-LAUNCHED-ITER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(do* () (progn))\n\nProblem: Macro call that should be transformed by DO*", "input": "(do* () (progn))", "output": "(defmacro DO* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do-sequences! nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by DO-SEQUENCES!", "input": "(do-sequences! nil\n :key\n nil)", "output": "(defmacro do-sequences! (name/seqs &body forms &environment env)\n \"Mutable version of DO-SEQUENCES.\n\n This is the same as DO-SEQUENCES however each NAME, is the name of\n a symbol-macro, that is introduced, which expands to the 'place',\n suitable for use with SETF, of the current sequence element, rather\n than a variable storing its value. This allows the elements of the\n sequence to be mutated.\n\n NOTE: This macro does not support destructuring of the sequence\n elements.\"\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))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(try-as common-lisp:nil common-lisp:nil)\n\nProblem: Macro call that should be transformed by TRY-AS", "input": "(try-as common-lisp:nil common-lisp:nil)", "output": "(defmacro try-as (type cl:&optional (expr cl:nil expr-supplied-p))\n \"A syntactic convenience for type casting.\n\n (try-as )\n\nis equivalent to\n\n (the (Optional ) (tryInto ))\n\nand\n\n (try-as )\n\nis equivalent to\n\n (fn (expr) (the (Optional ) (tryInto expr))).\n\nNote that this may copy the object or allocate memory.\"\n\n (cl:let ((try-into (cl:ignore-errors (cl:find-symbol \"TRYINTO\" \"COALTON/CLASSES\")))\n (Optional (cl:ignore-errors (cl:find-symbol \"OPTIONAL\" \"COALTON/CLASSES\"))))\n (cl:assert try-into () \"`try-as` macro does not have access to `try-into` yet.\")\n (cl:assert Optional () \"`try-as` macro does not have access to `Optional` yet.\")\n (cl:if expr-supplied-p\n `(the (,Optional ,type) (,try-into ,expr))\n (alexandria:with-gensyms (lexpr)\n `(fn (,lexpr)\n (the (,Optional ,type) (,try-into ,lexpr)))))))", "category": "anaphoric", "technique": "gensym,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.85} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(gen-lambda-with-sticky-stop 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by GEN-LAMBDA-WITH-STICKY-STOP", "input": "(gen-lambda-with-sticky-stop 'lol-gen::some-name)", "output": "(defmacro gen-lambda-with-sticky-stop (&rest rest)\n `(make-instance \n 'basic-generator \n :function (sticky-stop-lambda ,@rest)))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(initially nil)\n\nProblem: Macro call that should be transformed by INITIALLY", "input": "(initially nil)", "output": "(defmacro INITIALLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(letrec* nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by LETREC*", "input": "(letrec* nil\n :key\n nil)", "output": "(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))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} {"instruction": "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", "input": "(define-class-method nil\n nil)", "output": "(defmacro DEFINE-CLASS-METHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(alet nil\n nil)\n\nIssue: Macro call that should be transformed by ALET", "input": "(alet nil\n nil)", "output": "(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)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8225} {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(js-inline nil (progn))\n\nProblem: Macro call that should be transformed by JS-INLINE", "input": "(js-inline nil (progn))", "output": "(defmacro JS-INLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(instead nil nil)\n\nIssue: Macro call that should be transformed by INSTEAD", "input": "(instead nil nil)", "output": "(defmacro instead (item parser)\n \"Run some parser, but substitute its inner value with some `item' if parsing was\n successful.\"\n `(<$ ,item ,parser))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(do-external-symbols (quote lol-gen::some-name))\n\nWrite a macro that addresses: Macro call that should be transformed by DO-EXTERNAL-SYMBOLS", "input": "(do-external-symbols (quote lol-gen::some-name))", "output": "(defmacro DO-EXTERNAL-SYMBOLS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} {"instruction": "Define a macro that eliminates this repetitive pattern:\n(listcase nil\n nil)\n\nIssue: Macro call that should be transformed by LISTCASE", "input": "(listcase nil\n nil)", "output": "(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)))))", "category": "control-flow", "technique": "once-only", "complexity": "intermediate", "quality_score": 0.86}