| {"instruction": "Generate a defmacro form that transforms code like this:\n(advisable-lambda nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by ADVISABLE-LAMBDA", "input": "(advisable-lambda nil\n (progn))", "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(c-input nil (progn))\n\nProblem: Macro call that should be transformed by C-INPUT", "input": "(c-input nil (progn))", "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(vect-of nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by VECT-OF", "input": "(vect-of nil :key 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(make-window-or-instance nil)\n\nWhat needs to change: Macro call that should be transformed by MAKE-WINDOW-OR-INSTANCE", "input": "(make-window-or-instance nil)", "output": "(defmacro MAKE-WINDOW-OR-INSTANCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(order-by)\n\nWrite a macro that addresses: Macro call that should be transformed by ORDER-BY", "input": "(order-by)", "output": "(defmacro ORDER-BY ...)", "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? 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by FM-OTHERV?", "input": "(fm-otherv? 'lol-gen::some-name)", "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.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(time nil)\n\nPattern to recognize: Macro call that should be transformed by TIME", "input": "(time nil)", "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(for nil nil)\n\nWhat needs to change: Macro call that should be transformed by FOR", "input": "(for nil nil)", "output": "(defmacro FOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-array nil)\n\nProblem: Macro call that should be transformed by WITH-ARRAY", "input": "(with-array 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": "Generate a defmacro form that transforms code like this:\n(if-and-let* nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by IF-AND-LET*", "input": "(if-and-let* nil\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": "Define a macro that eliminates this repetitive pattern:\n(local-output\n nil\n nil)\n\nIssue: Macro call that should be transformed by LOCAL-OUTPUT", "input": "(local-output\n nil\n nil)", "output": "(defmacro LOCAL-OUTPUT ...)", "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 :key nil)\n\nWhat needs to change: Macro call that should be transformed by RIGHT", "input": "(right nil :key 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": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda-ematch\n common-lisp:nil\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 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": "Define a macro that eliminates this repetitive pattern:\n(generating nil nil)\n\nIssue: Macro call that should be transformed by GENERATING", "input": "(generating nil nil)", "output": "(defmacro GENERATING ...)", "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\n :key\n nil)\n\nWrite a macro that addresses: 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": "Write a Common Lisp macro to handle this code pattern:\n(without-c-dependency\n nil\n (progn))\n\nProblem: Macro call that should be transformed by WITHOUT-C-DEPENDENCY", "input": "(without-c-dependency\n nil\n (progn))", "output": "(defmacro without-c-dependency (&body body)\n ` (let (*depender*)\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(pop-assoc nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by POP-ASSOC", "input": "(pop-assoc nil :key nil)", "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": "Define a macro that eliminates this repetitive pattern:\n(defstore nil\n nil)\n\nIssue: Macro call that should be transformed by DEFSTORE", "input": "(defstore nil\n nil)", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(with-context-variables nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-CONTEXT-VARIABLES", "input": "(with-context-variables 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.8674999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(doiter 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DOITER", "input": "(doiter 'lol-gen::some-name)", "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": "Define a macro that eliminates this repetitive pattern:\n(do-iter-values 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DO-ITER-VALUES", "input": "(do-iter-values 'lol-gen::some-name)", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(iterate\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by ITERATE", "input": "(iterate\n nil\n (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(global\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by GLOBAL", "input": "(global\n nil\n :key\n nil)", "output": "(defmacro GLOBAL ...)", "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:progn))\n\nProblem: Macro call that should be transformed by DEFUN-MATCH", "input": "(defun-match common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro defun-match (name (arg) &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 (,arg)\n ,@preamble\n (match ,arg\n ,@clauses))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8999999999999999} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(match* common-lisp:nil\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by MATCH*", "input": "(match* common-lisp:nil\n 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.8624999999999999} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(summing-to-and-returning 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by SUMMING-TO-AND-RETURNING", "input": "(summing-to-and-returning 'lol-gen::some-name)", "output": "(defmacro SUMMING-TO-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(c?1\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by C?1", "input": "(c?1\n 'lol-gen::some-name)", "output": "(defmacro c?1 (&body body)\n `(c?once ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(declaim (quote lol-gen::some-name))\n\nPattern to recognize: Macro call that should be transformed by DECLAIM", "input": "(declaim (quote lol-gen::some-name))", "output": "(defmacro DECLAIM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(dynamic-let* nil)\n\nWhat needs to change: Macro call that should be transformed by DYNAMIC-LET*", "input": "(dynamic-let* nil)", "output": "(defmacro DYNAMIC-LET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} |
| {"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 <*> (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": "Define a macro that eliminates this repetitive pattern:\n(define-declaration nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFINE-DECLARATION", "input": "(define-declaration nil\n (progn))", "output": "(defmacro DEFINE-DECLARATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(def$frame nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DEF$FRAME", "input": "(def$frame nil :key nil)", "output": "(defmacro DEF$FRAME ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(prog () nil)\n\nIssue: 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": "You are a Common Lisp macro expert. Given this code pattern:\n(ith-value nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ITH-VALUE", "input": "(ith-value nil :key 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(delete-from 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DELETE-FROM", "input": "(delete-from 'lol-gen::some-name)", "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.8374999999999999} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ensure-transaction\n nil\n (progn))\n\nIssue: Macro call that should be transformed by ENSURE-TRANSACTION", "input": "(ensure-transaction\n nil\n (progn))", "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(drop-table nil)\n\nWhat needs to change: Macro call that should be transformed by DROP-TABLE", "input": "(drop-table nil)", "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.8225} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(cond-bind nil\n nil)\n\nIssue: Macro call that should be transformed by COND-BIND", "input": "(cond-bind nil\n 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(maxf nil nil)\n\nPattern to recognize: Macro call that should be transformed by MAXF", "input": "(maxf nil nil)", "output": "(defmacro MAXF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(defmessage nil (progn))\n\nPattern to recognize: Macro call that should be transformed by DEFMESSAGE", "input": "(defmessage nil (progn))", "output": "(defmacro DEFMESSAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(sum-of nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by SUM-OF", "input": "(sum-of nil\n nil)", "output": "(defmacro SUM-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(ensure-arg-list-key-value! nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by ENSURE-ARG-LIST-KEY-VALUE!", "input": "(ensure-arg-list-key-value! nil :key nil)", "output": "(defmacro ensure-arg-list-key-value! (default ids place &key (test '#'equalper) (key '#'identity))\n `(progn\n (iter (for id in (ensure-list ,ids))\n (setf ,place (ensure-arg-list-key-value ,default 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(do-iterator 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DO-ITERATOR", "input": "(do-iterator 'lol-gen::some-name)", "output": "(defmacro DO-ITERATOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(with-collectors 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-COLLECTORS", "input": "(with-collectors 'lol-gen::some-name)", "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(defsubst nil\n (progn))\n\nProblem: Macro call that should be transformed by DEFSUBST", "input": "(defsubst nil\n (progn))", "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": "Write a Common Lisp macro to handle this code pattern:\n(defgeneric nil (progn))\n\nProblem: Macro call that should be transformed by DEFGENERIC", "input": "(defgeneric nil (progn))", "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(matrix-ecase nil)\n\nIssue: Macro call that should be transformed by MATRIX-ECASE", "input": "(matrix-ecase nil)", "output": "(defmacro MATRIX-ECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-alias-binding nil nil)\n\nIssue: Macro call that should be transformed by DEFINE-ALIAS-BINDING", "input": "(define-alias-binding nil nil)", "output": "(defmacro define-alias-binding (name referenced-binding-name)\n `(progn (setf (binding ',name) ',referenced-binding-name)\n ',name))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8225} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(scase 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by SCASE", "input": "(scase 'lol-gen::some-name)", "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(iter)\n\nPattern to recognize: Macro call that should be transformed by ITER", "input": "(iter)", "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": "Define a macro that eliminates this repetitive pattern:\n(def-suite 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DEF-SUITE", "input": "(def-suite 'lol-gen::some-name)", "output": "(defmacro def-suite (name &key description in)\n \"Define a new test-suite named NAME.\n\nIN (a symbol), if provided, causes this suite te be nested in the\nsuite named by IN. NB: This macro is built on top of make-suite,\nas such it, like make-suite, will overrwrite any existing suite\nnamed NAME.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (make-suite ',name\n ,@(when description `(:description ,description))\n ,@(when in `(:in ',in)))\n ',name))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(make-name-transformer nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by MAKE-NAME-TRANSFORMER", "input": "(make-name-transformer nil :key nil)", "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": "Write a Common Lisp macro to handle this code pattern:\n(with-guessing-encoder\n nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-GUESSING-ENCODER", "input": "(with-guessing-encoder\n nil\n nil)", "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": "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))", "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 <* (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": "Generate a defmacro form that transforms code like this:\n(eval-when-compile)\n\nPattern to recognize: Macro call that should be transformed by EVAL-WHEN-COMPILE", "input": "(eval-when-compile)", "output": "(defmacro EVAL-WHEN-COMPILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(defpackage nil nil)\n\nPattern to recognize: 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(special 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by SPECIAL", "input": "(special 'lol-gen::some-name)", "output": "(defmacro SPECIAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"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* (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(->> nil nil)\n\nPattern to recognize: Macro call that should be transformed by ->>", "input": "(->> nil nil)", "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(c?n\n nil\n (progn))\n\nWrite a macro that addresses: 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 :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(-<> nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by -<>", "input": "(-<> nil\n :key\n nil)", "output": "(defmacro -<> (init &body exps) (diamond-wand init exps))", "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 :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-SHADOWED-CUSTOM-VARS", "input": "(with-shadowed-custom-vars\n nil\n :key\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": "Generate a defmacro form that transforms code like this:\n(when-let* nil)\n\nPattern to recognize: Macro call that should be transformed by WHEN-LET*", "input": "(when-let* 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.79} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-shared-method nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-SHARED-METHOD", "input": "(define-shared-method nil\n (progn))", "output": "(defmacro DEFINE-SHARED-METHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(match common-lisp:nil\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by MATCH", "input": "(match common-lisp:nil\n 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.8999999999999999} |
| {"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": "You are a Common Lisp macro expert. Given this code pattern:\n(do-for nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DO-FOR", "input": "(do-for nil\n nil)", "output": "(defmacro DO-FOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(dictq nil nil)\n\nProblem: Macro call that should be transformed by DICTQ", "input": "(dictq nil nil)", "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(pprint-coalton-codegen-types\n common-lisp:nil\n (common-lisp:progn))\n\nWrite a macro that addresses: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-TYPES", "input": "(pprint-coalton-codegen-types\n common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro PPRINT-COALTON-CODEGEN-TYPES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(form-attribute nil nil)\n\nProblem: Macro call that should be transformed by FORM-ATTRIBUTE", "input": "(form-attribute nil 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(nlet nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NLET", "input": "(nlet nil\n nil)", "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(lret nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by LRET", "input": "(lret nil\n (progn))", "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(f_n\n 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by F_N", "input": "(f_n\n 'lol-gen::some-name)", "output": "(defmacro F_N ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"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": "You are a Common Lisp macro expert. Given this code pattern:\n(with-column-writers nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-COLUMN-WRITERS", "input": "(with-column-writers nil\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(define-alias-binding nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-ALIAS-BINDING", "input": "(define-alias-binding nil (progn))", "output": "(defmacro define-alias-binding (name referenced-binding-name)\n `(progn (setf (binding ',name) ',referenced-binding-name)\n ',name))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(symbol-value-in-$instance nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by SYMBOL-VALUE-IN-$INSTANCE", "input": "(symbol-value-in-$instance nil (progn))", "output": "(defmacro SYMBOL-VALUE-IN-$INSTANCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(resolve\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by RESOLVE", "input": "(resolve\n 'lol-gen::some-name)", "output": "(defmacro RESOLVE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(deftable nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFTABLE", "input": "(deftable nil\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": "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 ~> (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(lambda* 'lol-gen::some-name)\n\nIssue: 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": "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": "Write a Common Lisp macro to handle this code pattern:\n(def-kid-slots)\n\nProblem: Macro call that should be transformed by DEF-KID-SLOTS", "input": "(def-kid-slots)", "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(with-html\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-HTML", "input": "(with-html\n 'lol-gen::some-name)", "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.8624999999999999} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-attributes nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-ATTRIBUTES", "input": "(with-attributes nil\n nil)", "output": "(defmacro WITH-ATTRIBUTES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(once-on nil\n (progn))\n\nIssue: Macro call that should be transformed by ONCE-ON", "input": "(once-on nil\n (progn))", "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": "Define a macro that eliminates this repetitive pattern:\n(define-form-symbol-macro-binding nil\n (progn))\n\nIssue: Macro call that should be transformed by DEFINE-FORM-SYMBOL-MACRO-BINDING", "input": "(define-form-symbol-macro-binding nil\n (progn))", "output": "(defmacro define-form-symbol-macro-binding (name (var &rest args) &body body)\n (emit-binding-definition name var args body :symbol-macro-p T))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fbind* nil)\n\nProblem: Macro call that should be transformed by FBIND*", "input": "(fbind* 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.815} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(eval-when-load\n common-lisp:nil\n :key\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by EVAL-WHEN-LOAD", "input": "(eval-when-load\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro EVAL-WHEN-LOAD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(update nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by UPDATE", "input": "(update nil\n nil)", "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(some-<>>\n 'lol-gen::some-name)\n\nProblem: 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": "You are a Common Lisp macro expert. Given this code pattern:\n(with nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH", "input": "(with nil :key nil)", "output": "(defmacro WITH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(remove-from-plistf nil (progn))\n\nIssue: Macro call that should be transformed by REMOVE-FROM-PLISTF", "input": "(remove-from-plistf nil (progn))", "output": "(defmacro REMOVE-FROM-PLISTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(f0\n nil)\n\nWhat needs to change: Macro call that should be transformed by F0", "input": "(f0\n nil)", "output": "(defmacro F0 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-collectors 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-COLLECTORS", "input": "(with-collectors 'lol-gen::some-name)", "output": "(defmacro WITH-COLLECTORS ...)", "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 'lol-gen::some-name)\n\nWrite a macro that addresses: 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 :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(defmacro nil (progn))\n\nPattern to recognize: 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": "Generate a defmacro form that transforms code like this:\n(to nil)\n\nPattern to recognize: Macro call that should be transformed by TO", "input": "(to nil)", "output": "(defmacro TO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(nsplice-seqf nil nil)\n\nProblem: Macro call that should be transformed by NSPLICE-SEQF", "input": "(nsplice-seqf nil nil)", "output": "(defmacro NSPLICE-SEQF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(psetf nil nil)\n\nIssue: 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": "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": "You are a Common Lisp macro expert. Given this code pattern:\n(defcondition nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFCONDITION", "input": "(defcondition nil\n :key\n nil)", "output": "(defmacro defcondition (name supers &body (slots &rest options))\n \"Alias for `define-condition'.\n\nLike (define-condition ...), but blissfully conforming to the same\nnomenclatural convention as every other definition form in Common\nLisp.\"\n `(define-condition ,name ,supers\n ,slots\n ,@options))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defproto nil (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFPROTO", "input": "(defproto nil (progn))", "output": "(defmacro DEFPROTO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fmv nil)\n\nIssue: Macro call that should be transformed by FMV", "input": "(fmv nil)", "output": "(defmacro fmv (name)\n `(value (fm-other ,name)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(wnotrc nil\n (progn))\n\nProblem: Macro call that should be transformed by WNOTRC", "input": "(wnotrc nil\n (progn))", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(is-type nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IS-TYPE", "input": "(is-type nil nil)", "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": "Write a Common Lisp macro to handle this code pattern:\n(aecase 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by AECASE", "input": "(aecase 'lol-gen::some-name)", "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": "Write a Common Lisp macro to handle this code pattern:\n(ps-html nil :key nil)\n\nProblem: Macro call that should be transformed by PS-HTML", "input": "(ps-html nil :key 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(c-in-lazy\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by C-IN-LAZY", "input": "(c-in-lazy\n nil\n (progn))", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(with-slots nil\n :key\n nil)\n\nWrite a macro that addresses: 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": "You are a Common Lisp macro expert. Given this code pattern:\n(as-> nil nil)\n\nWrite a macro that addresses: 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": "Write a Common Lisp macro to handle this code pattern:\n(restart-case nil)\n\nProblem: Macro call that should be transformed by RESTART-CASE", "input": "(restart-case nil)", "output": "(defmacro RESTART-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\n nil)\n\nWhat needs to change: Macro call that should be transformed by -<>>", "input": "(-<>> nil\n nil)", "output": "(defmacro -<>> (init &body exps) (diamond-wand init exps t))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-savepoint nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-SAVEPOINT", "input": "(with-savepoint nil\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.86} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(lret* nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by LRET*", "input": "(lret* nil\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": "Write a Common Lisp macro to handle this code pattern:\n(defobject 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DEFOBJECT", "input": "(defobject 'lol-gen::some-name)", "output": "(defmacro DEFOBJECT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-destructured-lambda-form nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-DESTRUCTURED-LAMBDA-FORM", "input": "(with-destructured-lambda-form nil\n :key\n nil)", "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(compile-$flavor-$methods nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by COMPILE-$FLAVOR-$METHODS", "input": "(compile-$flavor-$methods nil :key nil)", "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(gathering nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by GATHERING", "input": "(gathering nil\n :key\n 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(opf nil nil)\n\nProblem: Macro call that should be transformed by OPF", "input": "(opf nil nil)", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(nest nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by NEST", "input": "(nest nil (progn))", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(ensure2 nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ENSURE2", "input": "(ensure2 nil\n :key\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": "Write a Common Lisp macro to handle this code pattern:\n(ensure-get nil\n nil)\n\nProblem: Macro call that should be transformed by ENSURE-GET", "input": "(ensure-get nil\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.8474999999999999} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(none-of nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by NONE-OF", "input": "(none-of nil\n :key\n 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(with-custom-decoder-level 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-CUSTOM-DECODER-LEVEL", "input": "(with-custom-decoder-level 'lol-gen::some-name)", "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": "Write a Common Lisp macro to handle this code pattern:\n(c_?\n nil)\n\nProblem: Macro call that should be transformed by C_?", "input": "(c_?\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": "Generate a defmacro form that transforms code like this:\n(the)\n\nPattern to recognize: Macro call that should be transformed by THE", "input": "(the)", "output": "(defmacro THE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(collect nil)\n\nPattern to recognize: Macro call that should be transformed by COLLECT", "input": "(collect nil)", "output": "(defmacro COLLECT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(eko-if nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by EKO-IF", "input": "(eko-if nil :key 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(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 \"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(when-let 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WHEN-LET", "input": "(when-let 'lol-gen::some-name)", "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": "Generate a defmacro form that transforms code like this:\n(matrix-ctypecase nil)\n\nPattern to recognize: Macro call that should be transformed by MATRIX-CTYPECASE", "input": "(matrix-ctypecase nil)", "output": "(defmacro MATRIX-CTYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(multiple-value-cmatch common-lisp:nil\n (common-lisp:progn))\n\nIssue: Macro call that should be transformed by MULTIPLE-VALUE-CMATCH", "input": "(multiple-value-cmatch common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro multiple-value-cmatch (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 (cerror \"continue\" 'match-error :pattern ',clauses :values (list ,@temps))))))))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.9125} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(eval-when-compile\n common-lisp:nil\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\n common-lisp:nil)", "output": "(defmacro EVAL-WHEN-COMPILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(restart-bind nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by RESTART-BIND", "input": "(restart-bind nil\n (progn))", "output": "(defmacro RESTART-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(v-defmacro nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by V-DEFMACRO", "input": "(v-defmacro nil\n (progn))", "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(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": "Write a Common Lisp macro to handle this code pattern:\n(group-by 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by GROUP-BY", "input": "(group-by 'lol-gen::some-name)", "output": "(defmacro GROUP-BY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(restart-case 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by RESTART-CASE", "input": "(restart-case 'lol-gen::some-name)", "output": "(defmacro RESTART-CASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(nearest nil nil)\n\nPattern to recognize: Macro call that should be transformed by NEAREST", "input": "(nearest nil nil)", "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(c-envalue\n nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by C-ENVALUE", "input": "(c-envalue\n nil\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": "Create a Common Lisp macro for the following transformation. Before code:\n(define-declaration nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFINE-DECLARATION", "input": "(define-declaration nil\n (progn))", "output": "(defmacro DEFINE-DECLARATION ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-last nil)\n\nIssue: Macro call that should be transformed by COLLECT-LAST", "input": "(collect-last nil)", "output": "(defmacro COLLECT-LAST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(export-only-always nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by EXPORT-ONLY-ALWAYS", "input": "(export-only-always nil (progn))", "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": "Generate a defmacro form that transforms code like this:\n(u^ 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by U^", "input": "(u^ 'lol-gen::some-name)", "output": "(defmacro u^ (type)\n `(upper 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(defmacro* nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFMACRO*", "input": "(defmacro* nil\n 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-destructured-lambda-form nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-DESTRUCTURED-LAMBDA-FORM", "input": "(with-destructured-lambda-form nil\n nil)", "output": "(defmacro WITH-DESTRUCTURED-LAMBDA-FORM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(when-let* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by WHEN-LET*", "input": "(when-let* nil\n (progn))", "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": "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": "Generate a defmacro form that transforms code like this:\n(defclause nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by DEFCLAUSE", "input": "(defclause nil\n nil)", "output": "(defmacro defclause (name arglist &body body)\n \"Same as cl:defmacro, but additionally records <name> 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": "Generate a defmacro form that transforms code like this:\n(eval-when-execute\n common-lisp:nil\n (common-lisp:progn))\n\nPattern to recognize: Macro call that should be transformed by EVAL-WHEN-EXECUTE", "input": "(eval-when-execute\n common-lisp:nil\n (common-lisp:progn))", "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(export-slots\n common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by EXPORT-SLOTS", "input": "(export-slots\n common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro EXPORT-SLOTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(pecase nil (progn))\n\nProblem: Macro call that should be transformed by PECASE", "input": "(pecase nil (progn))", "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": "Generate a defmacro form that transforms code like this:\n(with-out-file 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-OUT-FILE", "input": "(with-out-file 'lol-gen::some-name)", "output": "(defmacro with-out-file ((var path) &body body)\n `(with-open-file (,var ,path :direction :output\n :if-exists :supersede :if-does-not-exist :create)\n ,@body))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(prog1 nil nil)\n\nProblem: Macro call that should be transformed by PROG1", "input": "(prog1 nil 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(c?? nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by C??", "input": "(c?? nil\n (progn))", "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": "Generate a defmacro form that transforms code like this:\n(eval-always\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n nil\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.8474999999999999} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(export-structure)\n\nWhat needs to change: Macro call that should be transformed by EXPORT-STRUCTURE", "input": "(export-structure)", "output": "(defmacro EXPORT-STRUCTURE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-test+run-interactively 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-TEST+RUN-INTERACTIVELY", "input": "(define-test+run-interactively 'lol-gen::some-name)", "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.8999999999999999} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-pp\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-PP", "input": "(with-pp\n 'lol-gen::some-name)", "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.9325} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(batch)\n\nWhat needs to change: Macro call that should be transformed by BATCH", "input": "(batch)", "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(fluid-bind nil\n (progn))\n\nIssue: Macro call that should be transformed by FLUID-BIND", "input": "(fluid-bind nil\n (progn))", "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(defun* nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFUN*", "input": "(defun* nil\n 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(identifier 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by IDENTIFIER", "input": "(identifier 'lol-gen::some-name)", "output": "(defmacro IDENTIFIER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-unique-names nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-UNIQUE-NAMES", "input": "(with-unique-names nil\n (progn))", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(c?+n\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by C?+N", "input": "(c?+n\n nil\n :key\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(with-tokens nil\n nil)\n\nProblem: Macro call that should be transformed by WITH-TOKENS", "input": "(with-tokens nil\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": "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 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(export-slots\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by EXPORT-SLOTS", "input": "(export-slots\n 'lol-gen::some-name)", "output": "(defmacro EXPORT-SLOTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(fail nil (progn))\n\nPattern to recognize: Macro call that should be transformed by FAIL", "input": "(fail nil (progn))", "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(js-inline nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by JS-INLINE", "input": "(js-inline nil :key nil)", "output": "(defmacro JS-INLINE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(iterate)\n\nProblem: Macro call that should be transformed by ITERATE", "input": "(iterate)", "output": "(defmacro ITERATE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(doc common-lisp:nil)\n\nIssue: Macro call that should be transformed by DOC", "input": "(doc common-lisp:nil)", "output": "(defmacro DOC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-parse-tree-synonym nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-PARSE-TREE-SYNONYM", "input": "(define-parse-tree-synonym nil nil)", "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(as-array-member nil\n (progn))\n\nIssue: Macro call that should be transformed by AS-ARRAY-MEMBER", "input": "(as-array-member nil\n (progn))", "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": "Define a macro that eliminates this repetitive pattern:\n(is-print nil (progn))\n\nIssue: Macro call that should be transformed by IS-PRINT", "input": "(is-print nil (progn))", "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(live\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by LIVE", "input": "(live\n nil\n :key\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": "Generate a defmacro form that transforms code like this:\n(listcase nil)\n\nPattern to recognize: Macro call that should be transformed by LISTCASE", "input": "(listcase 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} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(print-values\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by PRINT-VALUES", "input": "(print-values\n nil\n :key\n nil)", "output": "(defmacro PRINT-VALUES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(jmatch 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by JMATCH", "input": "(jmatch 'lol-gen::some-name)", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(c-in-lazy)\n\nWhat needs to change: Macro call that should be transformed by C-IN-LAZY", "input": "(c-in-lazy)", "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": "Generate a defmacro form that transforms code like this:\n(select nil)\n\nPattern to recognize: Macro call that should be transformed by SELECT", "input": "(select 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(collect-stream nil nil)\n\nProblem: Macro call that should be transformed by COLLECT-STREAM", "input": "(collect-stream nil nil)", "output": "(defmacro COLLECT-STREAM ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-fixture-capture nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-FIXTURE-CAPTURE", "input": "(define-fixture-capture nil\n :key\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": "Write a Common Lisp macro to handle this code pattern:\n(isnt nil (progn))\n\nProblem: Macro call that should be transformed by ISNT", "input": "(isnt nil (progn))", "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(decase 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DECASE", "input": "(decase 'lol-gen::some-name)", "output": "(defmacro decase (keyform &body clauses)\n \"DECASE is a combination of ECASE 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 ECASE,\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 'ecase))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(destructuring-ccase 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DESTRUCTURING-CCASE", "input": "(destructuring-ccase 'lol-gen::some-name)", "output": "(defmacro destructuring-ccase (keyform &body clauses)\n (expand-destructuring-case keyform clauses 'ccase))", "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\nWrite a macro that addresses: Macro call that should be transformed by C?1", "input": "(c?1)", "output": "(defmacro c?1 (&body body)\n `(c?once ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(setypecase 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by SETYPECASE", "input": "(setypecase 'lol-gen::some-name)", "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.8624999999999999} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(shiftf nil nil)\n\nIssue: Macro call that should be transformed by SHIFTF", "input": "(shiftf nil nil)", "output": "(defmacro SHIFTF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-transaction nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-TRANSACTION", "input": "(with-transaction 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.7975} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(ntrcx)\n\nPattern to recognize: Macro call that should be transformed by NTRCX", "input": "(ntrcx)", "output": "(defmacro ntrcx (&rest os)\n (declare (ignore os))\n '(progn))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ematch* common-lisp:nil\n (common-lisp:progn))\n\nIssue: Macro call that should be transformed by EMATCH*", "input": "(ematch* common-lisp:nil\n (common-lisp:progn))", "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": "Write a Common Lisp macro to handle this code pattern:\n(disable-interpol-syntax)\n\nProblem: Macro call that should be transformed by DISABLE-INTERPOL-SYNTAX", "input": "(disable-interpol-syntax)", "output": "(defmacro disable-interpol-syntax ()\n \"Restore readtable which was active before last call to\nENABLE-INTERPOL-SYNTAX. If there was no such call, the standard\nreadtable is used.\"\n `(eval-when (:compile-toplevel :load-toplevel :execute)\n (%disable-interpol-syntax)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(pmap nil nil)\n\nWhat needs to change: Macro call that should be transformed by PMAP", "input": "(pmap nil nil)", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(v-define-compiler-macro nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by V-DEFINE-COMPILER-MACRO", "input": "(v-define-compiler-macro nil\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": "You are a Common Lisp macro expert. Given this code pattern:\n(scase nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SCASE", "input": "(scase nil\n :key\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": "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 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda-coro\n nil)\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-CORO", "input": "(lambda-coro\n nil)", "output": "(defmacro LAMBDA-CORO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"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 (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": "Define a macro that eliminates this repetitive pattern:\n(export-class\n common-lisp:nil\n (common-lisp:progn))\n\nIssue: Macro call that should be transformed by EXPORT-CLASS", "input": "(export-class\n common-lisp:nil\n (common-lisp:progn))", "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(fail 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by FAIL", "input": "(fail 'lol-gen::some-name)", "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": "Define a macro that eliminates this repetitive pattern:\n(cond-every)\n\nIssue: Macro call that should be transformed by COND-EVERY", "input": "(cond-every)", "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 ;; <https://gitlab.common-lisp.net/iterate/iterate/-/issues/11>.\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": "Write a Common Lisp macro to handle this code pattern:\n(xor nil)\n\nProblem: Macro call that should be transformed by XOR", "input": "(xor 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(nth-value-or nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NTH-VALUE-OR", "input": "(nth-value-or nil\n :key\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.8374999999999999} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(.> common-lisp:nil common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by .>", "input": "(.> common-lisp:nil 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": "Define a macro that eliminates this repetitive pattern:\n(define-simple-definition-resolver nil\n nil)\n\nIssue: Macro call that should be transformed by DEFINE-SIMPLE-DEFINITION-RESOLVER", "input": "(define-simple-definition-resolver nil\n nil)", "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.8624999999999999} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(sor 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by SOR", "input": "(sor 'lol-gen::some-name)", "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": "Generate a defmacro form that transforms code like this:\n(actypecase nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by ACTYPECASE", "input": "(actypecase nil\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": "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 *> (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": "Define a macro that eliminates this repetitive pattern:\n(multiple-value-ematch 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by MULTIPLE-VALUE-EMATCH", "input": "(multiple-value-ematch 'lol-gen::some-name)", "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": "Generate a defmacro form that transforms code like this:\n(advisable-lambda 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by ADVISABLE-LAMBDA", "input": "(advisable-lambda 'lol-gen::some-name)", "output": "(defmacro ADVISABLE-LAMBDA ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(if-and-let* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by IF-AND-LET*", "input": "(if-and-let* nil\n (progn))", "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": "Generate a defmacro form that transforms code like this:\n(cond-it\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by COND-IT", "input": "(cond-it\n nil\n (progn))", "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(defvar nil :key nil)\n\nProblem: 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": "Write a Common Lisp macro to handle this code pattern:\n(the-part nil)\n\nProblem: Macro call that should be transformed by THE-PART", "input": "(the-part nil)", "output": "(defmacro THE-PART ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(quoty 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by QUOTY", "input": "(quoty 'lol-gen::some-name)", "output": "(defmacro quoty (item &environment env)\n \"Quote undefined symbols, build functions from unknown lists\"\n (cond ((eql item nil)\n\t (values))\n\t((listp item)\n\t (if (or (listp (first item))\n\t\t (not (fboundp! (first item) env)))\n\t `(function-call\n\t (make-node ,(first item))\n\t (make-nodelist ,(rest item)))\n\t item))\n\t((symbolp item)\n\t (if (vboundp! item env)\n\t item\n\t `',item))\n\t(t item)))", "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)\n\nWhat needs to change: Macro call that should be transformed by EKX", "input": "(ekx 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": "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(c_1)\n\nProblem: Macro call that should be transformed by C_1", "input": "(c_1)", "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(fm-other?! 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by FM-OTHER?!", "input": "(fm-other?! 'lol-gen::some-name)", "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.8624999999999999} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(defprepared nil nil)\n\nPattern to recognize: Macro call that should be transformed by DEFPREPARED", "input": "(defprepared nil nil)", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(finc 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by FINC", "input": "(finc 'lol-gen::some-name)", "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": "Generate a defmacro form that transforms code like this:\n(ignore-some-conditions nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by IGNORE-SOME-CONDITIONS", "input": "(ignore-some-conditions nil\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": "Create a Common Lisp macro for the following transformation. Before code:\n(max-of nil)\n\nWhat needs to change: Macro call that should be transformed by MAX-OF", "input": "(max-of nil)", "output": "(defmacro MAX-OF ...)", "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)\n\nWhat needs to change: Macro call that should be transformed by KEEP-BOPS", "input": "(keep-bops)", "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(f_n\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by F_N", "input": "(f_n\n nil\n (progn))", "output": "(defmacro F_N ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-logical-transaction nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-LOGICAL-TRANSACTION", "input": "(with-logical-transaction nil\n (progn))", "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(with-standard-io-syntax nil)\n\nIssue: Macro call that should be transformed by WITH-STANDARD-IO-SYNTAX", "input": "(with-standard-io-syntax nil)", "output": "(defmacro WITH-STANDARD-IO-SYNTAX ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dynamic-relet* nil\n :key\n nil)\n\nIssue: 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": "Define a macro that eliminates this repetitive pattern:\n(with-connection 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-CONNECTION", "input": "(with-connection 'lol-gen::some-name)", "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(with-tokens 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WITH-TOKENS", "input": "(with-tokens 'lol-gen::some-name)", "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.8624999999999999} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(fm^ nil)\n\nPattern to recognize: Macro call that should be transformed by FM^", "input": "(fm^ nil)", "output": "(defmacro fm^ (md-name &key (skip-tree 'self) (must-find t))\n `(without-c-dependency\n (fm-find-one (fm-parent self) ,md-name\n :skip-tree ,skip-tree\n :must-find ,must-find\n :global-search t)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-hash nil (progn))\n\nWhat needs to change: Macro call that should be transformed by COLLECT-HASH", "input": "(collect-hash nil (progn))", "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(export\n common-lisp:nil\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EXPORT", "input": "(export\n common-lisp:nil\n common-lisp:nil)", "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(make-name-transformer)\n\nWhat needs to change: Macro call that should be transformed by MAKE-NAME-TRANSFORMER", "input": "(make-name-transformer)", "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(with-none-awake nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-NONE-AWAKE", "input": "(with-none-awake nil\n :key\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.7675} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dlet* nil)\n\nIssue: 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": "Write a Common Lisp macro to handle this code pattern:\n(with-read-only-vars nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-READ-ONLY-VARS", "input": "(with-read-only-vars nil\n :key\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": "You are a Common Lisp macro expert. Given this code pattern:\n(define-parse-method nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-PARSE-METHOD", "input": "(define-parse-method nil\n :key\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": "Write a Common Lisp macro to handle this code pattern:\n(or 'lol-gen::some-name)\n\nProblem: 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": "Generate a defmacro form that transforms code like this:\n(fail nil)\n\nPattern to recognize: Macro call that should be transformed by FAIL", "input": "(fail 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(dict-of nil)\n\nPattern to recognize: Macro call that should be transformed by DICT-OF", "input": "(dict-of nil)", "output": "(defmacro DICT-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(-> nil nil)\n\nProblem: 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(aif nil (progn))\n\nPattern to recognize: Macro call that should be transformed by AIF", "input": "(aif nil (progn))", "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(if-it nil :key nil)\n\nProblem: Macro call that should be transformed by IF-IT", "input": "(if-it nil :key 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": "Generate a defmacro form that transforms code like this:\n(flet* nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by FLET*", "input": "(flet* nil\n (progn))", "output": "(defmacro FLET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(match2 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by MATCH2", "input": "(match2 'lol-gen::some-name)", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(lambda () :key nil)\n\nWrite a macro that addresses: 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(tree-case nil)\n\nWhat needs to change: Macro call that should be transformed by TREE-CASE", "input": "(tree-case 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(loop-finish)\n\nProblem: Macro call that should be transformed by LOOP-FINISH", "input": "(loop-finish)", "output": "(defmacro LOOP-FINISH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defun-match* common-lisp:nil\n :key\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by DEFUN-MATCH*", "input": "(defun-match* common-lisp:nil\n :key\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.8999999999999999} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(pprint-coalton-codegen\n common-lisp:nil\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PPRINT-COALTON-CODEGEN", "input": "(pprint-coalton-codegen\n common-lisp:nil\n common-lisp:nil)", "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(select-dao 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by SELECT-DAO", "input": "(select-dao 'lol-gen::some-name)", "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.9249999999999999} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-vari-function nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-VARI-FUNCTION", "input": "(define-vari-function nil\n nil)", "output": "(defmacro define-vari-function (name args &body body)\n (check-args-for-constant-names :function name args)\n (destructuring-bind (in-args uniforms context shared)\n (split-arguments args '(&uniform &context &shared))\n (declare (ignore context))\n (assert (not shared) () 'shared-in-function :name name)\n `(progn\n (add-external-function ',name ',in-args ',uniforms ',body)\n ',name)))", "category": "dsl", "technique": "", "complexity": "intermediate", "quality_score": 0.875} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(compile-$flavor-$methods nil)\n\nPattern to recognize: Macro call that should be transformed by COMPILE-$FLAVOR-$METHODS", "input": "(compile-$flavor-$methods nil)", "output": "(defmacro COMPILE-$FLAVOR-$METHODS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do-sequences! nil\n (progn))\n\nIssue: Macro call that should be transformed by DO-SEQUENCES!", "input": "(do-sequences! nil\n (progn))", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(prog2 nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PROG2", "input": "(prog2 nil nil)", "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(whichever nil)\n\nWrite a macro that addresses: Macro call that should be transformed by WHICHEVER", "input": "(whichever nil)", "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.79} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(maybe-once-only nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by MAYBE-ONCE-ONLY", "input": "(maybe-once-only nil\n nil)", "output": "(defmacro MAYBE-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(doleaves 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DOLEAVES", "input": "(doleaves 'lol-gen::some-name)", "output": "(defmacro doleaves ((node tree &optional result) &body body)\n \"Iterate over each leaf NODE of the TREE in depth-first order.\n Optionally return RESULT.\"\n (with-gensyms (rec child)\n `(block nil\n (labels ((,rec (,node)\n (unless (atom ,node)\n (dolist (,child (cdr ,node))\n (if (atom ,child)\n (let ((,node ,child))\n ,@body)\n (,rec ,child))))))\n (when-it ,tree\n (,rec it))\n ,result))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(splice-seqf nil (progn))\n\nIssue: Macro call that should be transformed by SPLICE-SEQF", "input": "(splice-seqf nil (progn))", "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(quoty nil)\n\nWhat needs to change: Macro call that should be transformed by QUOTY", "input": "(quoty nil)", "output": "(defmacro quoty (item &environment env)\n \"Quote undefined symbols, build functions from unknown lists\"\n (cond ((eql item nil)\n\t (values))\n\t((listp item)\n\t (if (or (listp (first item))\n\t\t (not (fboundp! (first item) env)))\n\t `(function-call\n\t (make-node ,(first item))\n\t (make-nodelist ,(rest item)))\n\t item))\n\t((symbolp item)\n\t (if (vboundp! item env)\n\t item\n\t `',item))\n\t(t item)))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.79} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(-<> nil)\n\nIssue: Macro call that should be transformed by -<>", "input": "(-<> nil)", "output": "(defmacro -<> (init &body exps) (diamond-wand 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(dynamic-let* nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DYNAMIC-LET*", "input": "(dynamic-let* nil\n nil)", "output": "(defmacro DYNAMIC-LET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(pipe common-lisp:nil common-lisp:nil)\n\nProblem: Macro call that should be transformed by PIPE", "input": "(pipe common-lisp:nil common-lisp:nil)", "output": "(defmacro pipe (cl:&rest items)\n \"A syntactic convenience for function application, sometimes called a \\\"threading macro\\\". Transform\n\n (pipe x h g f)\n\nto\n\n (f (g (h x))).\"\n (cl:assert (cl:<= 2 (cl:list-length items)))\n `(nest ,@(cl:reverse items)))", "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(matrix-ctypecase 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by MATRIX-CTYPECASE", "input": "(matrix-ctypecase 'lol-gen::some-name)", "output": "(defmacro MATRIX-CTYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ltbdd-with-new-hash nil\n (progn))\n\nIssue: Macro call that should be transformed by LTBDD-WITH-NEW-HASH", "input": "(ltbdd-with-new-hash nil\n (progn))", "output": "(defmacro LTBDD-WITH-NEW-HASH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(iter)\n\nWhat needs to change: Macro call that should be transformed by ITER", "input": "(iter)", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(of-type nil nil)\n\nWhat needs to change: Macro call that should be transformed by OF-TYPE", "input": "(of-type nil 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": "Generate a defmacro form that transforms code like this:\n(lambda-match1 common-lisp:nil\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-MATCH1", "input": "(lambda-match1 common-lisp:nil\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.8374999999999999} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(appendf nil (progn))\n\nWhat needs to change: 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": "Create a Common Lisp macro for the following transformation. Before code:\n(nodelist nil)\n\nWhat needs to change: Macro call that should be transformed by NODELIST", "input": "(nodelist nil)", "output": "(defmacro NODELIST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defprettymethod nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPRETTYMETHOD", "input": "(defprettymethod nil\n :key\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.875} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(ps-html 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by PS-HTML", "input": "(ps-html 'lol-gen::some-name)", "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(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 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(c_?dbg\n nil\n (progn))\n\nProblem: Macro call that should be transformed by C_?DBG", "input": "(c_?dbg\n nil\n (progn))", "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(with-tokens nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-TOKENS", "input": "(with-tokens nil\n (progn))", "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": "Define a macro that eliminates this repetitive pattern:\n(make-name-transformer nil nil)\n\nIssue: Macro call that should be transformed by MAKE-NAME-TRANSFORMER", "input": "(make-name-transformer nil 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(defdata nil)\n\nWhat needs to change: Macro call that should be transformed by DEFDATA", "input": "(defdata nil)", "output": "(defmacro defdata (adt-name &body constructors)\n \"Define a new ADT. ADT-name has the following grammar:\n\nADT-NAME := <symbol>\n | (<symbol> <options>*)\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 <adt-type>: Specifies whether another defined ADT\n should be inherited.\n\nConstructors is a list of clauses with the following grammar:\n\n<clause> := <symbol>\n | (<symbol> <type-specifier>*)\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": "Write a Common Lisp macro to handle this code pattern:\n(appendf nil nil)\n\nProblem: 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": "Create a Common Lisp macro for the following transformation. Before code:\n(fbindrec* 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by FBINDREC*", "input": "(fbindrec* 'lol-gen::some-name)", "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.875} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(trace$method 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by TRACE$METHOD", "input": "(trace$method 'lol-gen::some-name)", "output": "(defmacro TRACE$METHOD ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(mvlet nil\n nil)\n\nProblem: Macro call that should be transformed by MVLET", "input": "(mvlet nil\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(true 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by TRUE", "input": "(true 'lol-gen::some-name)", "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": "Generate a defmacro form that transforms code like this:\n(finc nil (progn))\n\nPattern to recognize: Macro call that should be transformed by FINC", "input": "(finc nil (progn))", "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": "Write a Common Lisp macro to handle this code pattern:\n(defpattern nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFPATTERN", "input": "(defpattern nil\n :key\n nil)", "output": "(defmacro DEFPATTERN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(c?n-until 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by C?N-UNTIL", "input": "(c?n-until 'lol-gen::some-name)", "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.8624999999999999} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defrequirement nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFREQUIREMENT", "input": "(defrequirement nil\n nil)", "output": "(defmacro defrequirement (name (&rest lambda-list) &body body)\n \"Adds a precondition 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-precondition-checks-disabled\n (declare (ignore name lambda-list body))\n #+qpq-precondition-checks-disabled\n (values)\n #-qpq-precondition-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 :require\n ,(format nil \"~A\"\n (or doc-string\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 :require ,lambda-list\n (declare (ignorable ,@lambda-vars))\n ,@body)\n ,method)\n method))))", "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 nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITH-EXPLICIT-ENCODER", "input": "(with-explicit-encoder\n nil\n :key\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.8374999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(aecase nil\n nil)\n\nProblem: Macro call that should be transformed by AECASE", "input": "(aecase nil\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": "Define a macro that eliminates this repetitive pattern:\n(with-html-string\n nil\n (progn))\n\nIssue: Macro call that should be transformed by WITH-HTML-STRING", "input": "(with-html-string\n nil\n (progn))", "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(ematch* common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by EMATCH*", "input": "(ematch* 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.8474999999999999} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(sctypecase nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by SCTYPECASE", "input": "(sctypecase nil\n :key\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(do-blocks-in-lexenv 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DO-BLOCKS-IN-LEXENV", "input": "(do-blocks-in-lexenv 'lol-gen::some-name)", "output": "(defmacro DO-BLOCKS-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(defprettymethod nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFPRETTYMETHOD", "input": "(defprettymethod nil\n (progn))", "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.875} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make-name-transformer nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAKE-NAME-TRANSFORMER", "input": "(make-name-transformer nil)", "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.8975} |
| {"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": "Define a macro that eliminates this repetitive pattern:\n(lexpr-$send nil nil)\n\nIssue: Macro call that should be transformed by LEXPR-$SEND", "input": "(lexpr-$send nil nil)", "output": "(defmacro LEXPR-$SEND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(once-only nil\n nil)\n\nProblem: Macro call that should be transformed by ONCE-ONLY", "input": "(once-only nil\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": "Define a macro that eliminates this repetitive pattern:\n(for nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by FOR", "input": "(for nil\n :key\n nil)", "output": "(defmacro FOR ...)", "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 nil)\n\nPattern to recognize: Macro call that should be transformed by DISPATCH-CASEQL-LET", "input": "(dispatch-caseql-let nil\n 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.8624999999999999} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(with-connection 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-CONNECTION", "input": "(with-connection 'lol-gen::some-name)", "output": "(defmacro with-connection ((conn-sym &rest rest) &body body)\n `(let ((,conn-sym (connect ,@rest)))\n (unwind-protect\n (progn ,@body)\n (disconnect ,conn-sym))))", "category": "dsl", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-inactive-layers nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by WITH-INACTIVE-LAYERS", "input": "(with-inactive-layers nil\n :key\n nil)", "output": "(defmacro WITH-INACTIVE-LAYERS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(let-match common-lisp:nil)\n\nPattern to recognize: 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, 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.8474999999999999} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(whichever nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by WHICHEVER", "input": "(whichever nil :key nil)", "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": "Generate a defmacro form that transforms code like this:\n(once-only nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by ONCE-ONLY", "input": "(once-only nil\n (progn))", "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 ((<gensym-1> <expr-1>)\n ...\n (<gensym-n> <expr-n>))\n <res>)\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": "Write a Common Lisp macro to handle this code pattern:\n(newq 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by NEWQ", "input": "(newq 'lol-gen::some-name)", "output": "(defmacro NEWQ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(defunit nil)\n\nPattern to recognize: Macro call that should be transformed by DEFUNIT", "input": "(defunit nil)", "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(define-templated-dispatch nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-TEMPLATED-DISPATCH", "input": "(define-templated-dispatch nil\n :key\n nil)", "output": "(defmacro DEFINE-TEMPLATED-DISPATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(typecase 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by TYPECASE", "input": "(typecase 'lol-gen::some-name)", "output": "(defmacro TYPECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(class/std 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by CLASS/STD", "input": "(class/std 'lol-gen::some-name)", "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.9125} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(incf nil nil)\n\nPattern to recognize: 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": "Define a macro that eliminates this repetitive pattern:\n(iterate)\n\nIssue: Macro call that should be transformed by ITERATE", "input": "(iterate)", "output": "(defmacro iterate (&body body)\n \"Jonathan Amsterdam's powerful iteration facility\"\n `(iter .,body))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nth-value nil nil)\n\nIssue: Macro call that should be transformed by NTH-VALUE", "input": "(nth-value nil nil)", "output": "(defmacro NTH-VALUE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(export-structure\n common-lisp:nil\n :key\n common-lisp:nil)\n\nIssue: Macro call that should be transformed by EXPORT-STRUCTURE", "input": "(export-structure\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro EXPORT-STRUCTURE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-logical-transaction nil)\n\nProblem: Macro call that should be transformed by WITH-LOGICAL-TRANSACTION", "input": "(with-logical-transaction 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.835} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(having 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by HAVING", "input": "(having 'lol-gen::some-name)", "output": "(defmacro having (expression)\n `(make-clause :having\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(quasiquote nil nil)\n\nWhat needs to change: Macro call that should be transformed by QUASIQUOTE", "input": "(quasiquote nil nil)", "output": "(defmacro QUASIQUOTE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(skip 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by SKIP", "input": "(skip 'lol-gen::some-name)", "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(lambda-cmatch\n common-lisp:nil\n common-lisp:nil)\n\nPattern to recognize: 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 (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": "Define a macro that eliminates this repetitive pattern:\n(make-node nil)\n\nIssue: Macro call that should be transformed by MAKE-NODE", "input": "(make-node nil)", "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.8474999999999999} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(with-gensyms 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by WITH-GENSYMS", "input": "(with-gensyms 'lol-gen::some-name)", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(static-let nil\n :key\n nil)\n\nWhat needs to change: 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)\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(named-lambda nil\n (progn))\n\nPattern to recognize: 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\ncorresponding function.\"\n `(labels ((,name ,lambda-list ,@body))\n #',name))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8474999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defmacro common-lisp:nil\n :key\n common-lisp:nil)\n\nProblem: Macro call that should be transformed by DEFMACRO", "input": "(defmacro common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro DEFMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(pass nil (progn))\n\nPattern to recognize: Macro call that should be transformed by PASS", "input": "(pass nil (progn))", "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(alt nil nil)\n\nIssue: Macro call that should be transformed by ALT", "input": "(alt nil 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": "Generate a defmacro form that transforms code like this:\n(required common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by REQUIRED", "input": "(required common-lisp:nil)", "output": "(defmacro REQUIRED ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(dletf nil\n nil)\n\nPattern to recognize: 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": "Define a macro that eliminates this repetitive pattern:\n(c?1\n nil)\n\nIssue: Macro call that should be transformed by C?1", "input": "(c?1\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(some-<>>\n nil\n :key\n nil)\n\nIssue: 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(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) (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(xor)\n\nPattern to recognize: Macro call that should be transformed by XOR", "input": "(xor)", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(with nil)\n\nWhat needs to change: Macro call that should be transformed by WITH", "input": "(with nil)", "output": "(defmacro WITH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-guessing-encoder\n nil)\n\nProblem: Macro call that should be transformed by WITH-GUESSING-ENCODER", "input": "(with-guessing-encoder\n nil)", "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(some-<>>)\n\nWrite a macro that addresses: Macro call that should be transformed by SOME-<>>", "input": "(some-<>>)", "output": "(defmacro SOME-<>> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with nil\n :key\n nil)\n\nWhat needs to change: 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.6825} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(adowhile nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ADOWHILE", "input": "(adowhile nil)", "output": "(defmacro ADOWHILE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-stemcell-infer-hook nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-STEMCELL-INFER-HOOK", "input": "(with-stemcell-infer-hook nil\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": "You are a Common Lisp macro expert. Given this code pattern:\n(fluid-bind nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FLUID-BIND", "input": "(fluid-bind nil\n :key\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": "You are a Common Lisp macro expert. Given this code pattern:\n(f0\n nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by F0", "input": "(f0\n nil\n :key\n nil)", "output": "(defmacro F0 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(current-decoder nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CURRENT-DECODER", "input": "(current-decoder nil 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": "Create a Common Lisp macro for the following transformation. Before code:\n(is-values nil (progn))\n\nWhat needs to change: Macro call that should be transformed by IS-VALUES", "input": "(is-values nil (progn))", "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": "Generate a defmacro form that transforms code like this:\n(drelet* nil)\n\nPattern to recognize: 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": "Create a Common Lisp macro for the following transformation. Before code:\n(fm-mapc nil (progn))\n\nWhat needs to change: Macro call that should be transformed by FM-MAPC", "input": "(fm-mapc nil (progn))", "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": "Write a Common Lisp macro to handle this code pattern:\n(filterf nil :key nil)\n\nProblem: Macro call that should be transformed by FILTERF", "input": "(filterf nil :key nil)", "output": "(defmacro FILTERF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fgather-next nil nil)\n\nProblem: Macro call that should be transformed by FGATHER-NEXT", "input": "(fgather-next nil nil)", "output": "(defmacro FGATHER-NEXT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(finc nil nil)\n\nWhat needs to change: Macro call that should be transformed by FINC", "input": "(finc nil 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(set-custom-vars)\n\nIssue: Macro call that should be transformed by SET-CUSTOM-VARS", "input": "(set-custom-vars)", "output": "(defmacro set-custom-vars (&rest key-args)\n `(setq\n ,@(loop for (supplied-key value) on key-args by #'cddr\n append (loop for (var . var-key) in *custom-vars*\n thereis (if (eql var-key supplied-key)\n (list var value))))))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7775} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(jor)\n\nWhat needs to change: Macro call that should be transformed by JOR", "input": "(jor)", "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.7775} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(->\n nil\n (progn))\n\nPattern to recognize: 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": "Define a macro that eliminates this repetitive pattern:\n(html5 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by HTML5", "input": "(html5 'lol-gen::some-name)", "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": "Define a macro that eliminates this repetitive pattern:\n(void nil)\n\nIssue: Macro call that should be transformed by VOID", "input": "(void nil)", "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(multiple-value-cmatch nil\n nil)\n\nProblem: Macro call that should be transformed by MULTIPLE-VALUE-CMATCH", "input": "(multiple-value-cmatch nil\n 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.875} |
| {"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))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(define-layered-class nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-LAYERED-CLASS", "input": "(define-layered-class nil\n (progn))", "output": "(defmacro DEFINE-LAYERED-CLASS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(f_%\n nil\n (progn))\n\nPattern to recognize: 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(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 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(batch\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by BATCH", "input": "(batch\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(make-name-transformer nil (progn))\n\nPattern to recognize: Macro call that should be transformed by MAKE-NAME-TRANSFORMER", "input": "(make-name-transformer nil (progn))", "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": "Generate a defmacro form that transforms code like this:\n(pipe common-lisp:nil :key common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by PIPE", "input": "(pipe common-lisp:nil :key common-lisp:nil)", "output": "(defmacro pipe (cl:&rest items)\n \"A syntactic convenience for function application, sometimes called a \\\"threading macro\\\". Transform\n\n (pipe x h g f)\n\nto\n\n (f (g (h x))).\"\n (cl:assert (cl:<= 2 (cl:list-length items)))\n `(nest ,@(cl:reverse items)))", "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(dynamic-relet* 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DYNAMIC-RELET*", "input": "(dynamic-relet* 'lol-gen::some-name)", "output": "(defmacro DYNAMIC-RELET* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(rem-bops nil (progn))\n\nPattern to recognize: Macro call that should be transformed by REM-BOPS", "input": "(rem-bops nil (progn))", "output": "(defmacro REM-BOPS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(peek nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PEEK", "input": "(peek nil)", "output": "(defmacro peek (form)\n \"Read the value of cells without triggering a recomputation.\n\nFORM is evaluated in a context such that when the value of a cell is\nreferenced it is not registered as an argument cell of the cell in\nwhich the PEEK form is evaluated. This means that the value of the\ncell, in which the PEEK form is evaluated, will not be recomputed when\nthe values of the cells referenced in FORM change.\n\nIn the following example\n\n.. code-block::\n\n (defcell a 0)\n (defcell b 1)\n\n (defcell sum (+ a (peek b))\n\nthe SUM cell references the value of A directly and *peeks* the value\nof B (using PEEK). Changing the value of A will cause the value of the\nSUM cell to be recomputed. However, changing the value of B will not\ncause the value of SUM to be computed.\n\n.. important::\n\n This macro has no effect if CELL is referenced outside a PEEK form\n within the same cell definition.\n\n .. code-block::\n\n (defcell sum (+ b (peek b))\n\n In this example, PEEK has no effect because the SUM cell references\n B outside a PEEK form.\n\n\"\n\n (with-gensyms (arg-cell\n did-change\n observer-arg\n tracker\n update\n will-update)\n\n (let* ((key ``(peek ,(argument-key ,arg-cell)))\n (observer-record\n `(make-observer\n :key ,key\n :will-update #',will-update\n :update #',update)))\n\n `(flet ((,update (,arg-cell ,did-change)\n (declare (ignore ,arg-cell ,did-change)))\n (,will-update (,arg-cell)\n (declare (ignore ,arg-cell))))\n\n (let ((,tracker *track-cell-callback*))\n (with-tracker\n ((,arg-cell)\n (let ((*track-cell-callback* ,tracker))\n (track-argument\n (make-argument\n :key ,key\n :add-observer (lambda (,observer-arg)\n (declare (ignore ,observer-arg))\n (call-add-observer ,arg-cell ,observer-record))\n :remove-observer (lambda (,observer-arg)\n (declare (ignore ,observer-arg))\n (call-remove-observer ,arg-cell ,observer-record))))))\n\n ,form))))))", "category": "anaphoric", "technique": "gensym,nested-backquote,anaphor,recursive-expansion", "complexity": "advanced", "quality_score": 0.8474999999999999} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(econd-let nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ECOND-LET", "input": "(econd-let nil\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": "Define a macro that eliminates this repetitive pattern:\n(defconst nil nil)\n\nIssue: Macro call that should be transformed by DEFCONST", "input": "(defconst nil 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": "Generate a defmacro form that transforms code like this:\n(with-decoder-simple-clos-semantics\n nil\n (progn))\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 (progn))", "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": "Generate a defmacro form that transforms code like this:\n(declare-deprecated-operators nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by DECLARE-DEPRECATED-OPERATORS", "input": "(declare-deprecated-operators nil :key nil)", "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;; Sorting multiple places requires manual compare-and-swap\n(when (> b a) (rotatef a b))\n(when (> c a) (rotatef a c))\n(when (> c b) (rotatef b c))\n;; This is a sorting network but manually written - error-prone\n;; For more than 3 elements, the network is complex\n\nWhat needs to change: Sorting multiple values in-place requires compare-and-swap networks \u2014 want automatic sorting network generation", "input": ";; Sorting multiple places requires manual compare-and-swap\n(when (> b a) (rotatef a b))\n(when (> c a) (rotatef a c))\n(when (> c b) (rotatef b c))\n;; This is a sorting network but manually written - error-prone\n;; For more than 3 elements, the network is complex", "output": "(defun build-batcher-sn (n)\n (let* (network\n (tee (ceiling (log n 2)))\n (p (ash 1 (- tee 1))))\n (loop while (> p 0) do\n (let ((q (ash 1 (- tee 1)))\n (r 0)\n (d p))\n (loop while (> d 0) do\n (loop for i from 0 to (- n d 1) do\n (if (= (logand i p) r)\n (push (list i (+ i d))\n network)))\n (setf d (- q p)\n q (ash q -1)\n r p)))\n (setf p (ash p -1)))\n (nreverse network)))\n\n(defmacro! sortf (comparator &rest places)\n (if places\n `(tagbody\n ,@(mapcar\n #`(let ((,g!a #1=,(nth (car a1) places))\n (,g!b #2=,(nth (cadr a1) places)))\n (if (,comparator ,g!b ,g!a)\n (setf #1# ,g!b\n #2# ,g!a)))\n (build-batcher-sn (length places))))))", "category": "efficiency", "technique": "gensym,tagbody-go", "complexity": "advanced", "quality_score": 0.9624999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(with-object nil)\n\nProblem: Macro call that should be transformed by WITH-OBJECT", "input": "(with-object 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": "Generate a defmacro form that transforms code like this:\n(do-iterator 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DO-ITERATOR", "input": "(do-iterator 'lol-gen::some-name)", "output": "(defmacro DO-ITERATOR ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(mapping nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by MAPPING", "input": "(mapping nil :key nil)", "output": "(defmacro MAPPING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(c?once\n nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by C?ONCE", "input": "(c?once\n nil\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": "You are a Common Lisp macro expert. Given this code pattern:\n(list-of nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LIST-OF", "input": "(list-of nil)", "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(defjsmacro nil)\n\nProblem: Macro call that should be transformed by DEFJSMACRO", "input": "(defjsmacro nil)", "output": "(defmacro DEFJSMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defun-advisable nil\n nil)\n\nIssue: Macro call that should be transformed by DEFUN-ADVISABLE", "input": "(defun-advisable nil\n nil)", "output": "(defmacro DEFUN-ADVISABLE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(if-not nil (progn))\n\nPattern to recognize: Macro call that should be transformed by IF-NOT", "input": "(if-not nil (progn))", "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": "Generate a defmacro form that transforms code like this:\n(local-output\n nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by LOCAL-OUTPUT", "input": "(local-output\n nil\n :key\n nil)", "output": "(defmacro LOCAL-OUTPUT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(pass nil)\n\nWrite a macro that addresses: Macro call that should be transformed by PASS", "input": "(pass 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": "Generate a defmacro form that transforms code like this:\n(with-contracts-enabled nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-CONTRACTS-ENABLED", "input": "(with-contracts-enabled nil\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(c-lambda\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by C-LAMBDA", "input": "(c-lambda\n nil\n :key\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": "Create a Common Lisp macro for the following transformation. Before code:\n(f nil)\n\nWhat needs to change: Macro call that should be transformed by F", "input": "(f 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(nor nil)\n\nProblem: Macro call that should be transformed by NOR", "input": "(nor 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.815} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is-condition nil (progn))\n\nProblem: Macro call that should be transformed by IS-CONDITION", "input": "(is-condition nil (progn))", "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": "Define a macro that eliminates this repetitive pattern:\n(cond->> nil)\n\nIssue: 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(unwind-protect nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by UNWIND-PROTECT", "input": "(unwind-protect nil\n (progn))", "output": "(defmacro UNWIND-PROTECT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(undefmessage 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by UNDEFMESSAGE", "input": "(undefmessage 'lol-gen::some-name)", "output": "(defmacro UNDEFMESSAGE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(stypecase nil)\n\nProblem: Macro call that should be transformed by STYPECASE", "input": "(stypecase 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": "Define a macro that eliminates this repetitive pattern:\n(define-global-parameter* nil nil)\n\nIssue: Macro call that should be transformed by DEFINE-GLOBAL-PARAMETER*", "input": "(define-global-parameter* nil 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(define-test+run 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFINE-TEST+RUN", "input": "(define-test+run 'lol-gen::some-name)", "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": "Generate a defmacro form that transforms code like this:\n(defgeneric* nil\n (progn))\n\nPattern to recognize: 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": "You are a Common Lisp macro expert. Given this code pattern:\n(collect-append nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECT-APPEND", "input": "(collect-append nil (progn))", "output": "(defmacro COLLECT-APPEND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-unknown-first-class-functions-allowed\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-UNKNOWN-FIRST-CLASS-FUNCTIONS-ALLOWED", "input": "(with-unknown-first-class-functions-allowed\n nil\n (progn))", "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(incf nil (progn))\n\nProblem: Macro call that should be transformed by INCF", "input": "(incf nil (progn))", "output": "(defmacro INCF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defpackage nil)\n\nIssue: 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(as~> nil nil)\n\nIssue: Macro call that should be transformed by AS~>", "input": "(as~> nil 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": "You are a Common Lisp macro expert. Given this code pattern:\n(gen-lambda 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by GEN-LAMBDA", "input": "(gen-lambda 'lol-gen::some-name)", "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.8624999999999999} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(alter-table nil)\n\nPattern to recognize: Macro call that should be transformed by ALTER-TABLE", "input": "(alter-table 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": "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(defrequirement nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by DEFREQUIREMENT", "input": "(defrequirement nil\n (progn))", "output": "(defmacro defrequirement (name (&rest lambda-list) &body body)\n \"Adds a precondition 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-precondition-checks-disabled\n (declare (ignore name lambda-list body))\n #+qpq-precondition-checks-disabled\n (values)\n #-qpq-precondition-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 :require\n ,(format nil \"~A\"\n (or doc-string\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 :require ,lambda-list\n (declare (ignorable ,@lambda-vars))\n ,@body)\n ,method)\n method))))", "category": "anaphoric", "technique": "anaphor", "complexity": "intermediate", "quality_score": 0.875} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(optional common-lisp:nil common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by OPTIONAL", "input": "(optional common-lisp:nil common-lisp:nil)", "output": "(defmacro OPTIONAL ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(is nil :key nil)\n\nProblem: Macro call that should be transformed by IS", "input": "(is nil :key 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": "You are a Common Lisp macro expert. Given this code pattern:\n(is 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by IS", "input": "(is 'lol-gen::some-name)", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(ensure-transaction\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by ENSURE-TRANSACTION", "input": "(ensure-transaction\n nil\n :key\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": "Write a Common Lisp macro to handle this code pattern:\n(handler-case nil)\n\nProblem: Macro call that should be transformed by HANDLER-CASE", "input": "(handler-case nil)", "output": "(defmacro HANDLER-CASE ...)", "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)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFMETHOD", "input": "(defmethod 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": "You are a Common Lisp macro expert. Given this code pattern:\n(all-values\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by ALL-VALUES", "input": "(all-values\n nil\n (progn))", "output": "(defmacro ALL-VALUES ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(is nil (progn))\n\nIssue: Macro call that should be transformed by IS", "input": "(is nil (progn))", "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": "Generate a defmacro form that transforms code like this:\n(c_in)\n\nPattern to recognize: Macro call that should be transformed by C_IN", "input": "(c_in)", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(c?dbg\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by C?DBG", "input": "(c?dbg\n nil\n (progn))", "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(make-$instance nil (progn))\n\nWhat needs to change: Macro call that should be transformed by MAKE-$INSTANCE", "input": "(make-$instance nil (progn))", "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(->* nil nil)\n\nPattern to recognize: Macro call that should be transformed by ->*", "input": "(->* nil nil)", "output": "(defmacro ->* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-gensyms nil)\n\nIssue: Macro call that should be transformed by WITH-GENSYMS", "input": "(with-gensyms 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.7275} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(without-c-dependency\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by WITHOUT-C-DEPENDENCY", "input": "(without-c-dependency\n nil\n :key\n nil)", "output": "(defmacro without-c-dependency (&body body)\n ` (let (*depender*)\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(nsib)\n\nProblem: Macro call that should be transformed by NSIB", "input": "(nsib)", "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": "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) (diamond-wand init exps))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nth-value-or nil)\n\nIssue: Macro call that should be transformed by NTH-VALUE-OR", "input": "(nth-value-or 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(with* nil)\n\nWhat needs to change: 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": "Generate a defmacro form that transforms code like this:\n(defjsmacro nil nil)\n\nPattern to recognize: Macro call that should be transformed by DEFJSMACRO", "input": "(defjsmacro nil nil)", "output": "(defmacro DEFJSMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ignore common-lisp:nil\n (common-lisp:progn))\n\nWrite a macro that addresses: Macro call that should be transformed by IGNORE", "input": "(ignore common-lisp:nil\n (common-lisp:progn))", "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(cmatch 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by CMATCH", "input": "(cmatch 'lol-gen::some-name)", "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(destructuring-ecase-of nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DESTRUCTURING-ECASE-OF", "input": "(destructuring-ecase-of nil\n nil)", "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": "Write a Common Lisp macro to handle this code pattern:\n(with-pointer-to-vector-data 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by WITH-POINTER-TO-VECTOR-DATA", "input": "(with-pointer-to-vector-data 'lol-gen::some-name)", "output": "(defmacro with-pointer-to-vector-data ((ptr-var vector) &body body)\n \"Bind 'ptr-var to a foreign pointer to the data in 'vector.\"\n (let ((vector-var (gensym (symbol-name '#:vector))))\n `(let ((,vector-var ,vector))\n (ext:with-pinned-object (,vector-var)\n (let ((,ptr-var (sys:vector-sap ,vector-var)))\n ,@body)))))", "category": "dsl", "technique": "gensym", "complexity": "basic", "quality_score": 0.8624999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(without-c-dependency\n nil\n nil)\n\nProblem: Macro call that should be transformed by WITHOUT-C-DEPENDENCY", "input": "(without-c-dependency\n nil\n nil)", "output": "(defmacro without-c-dependency (&body body)\n ` (let (*depender*)\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8374999999999999} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(minf nil nil)\n\nWhat needs to change: Macro call that should be transformed by MINF", "input": "(minf nil nil)", "output": "(defmacro MINF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defunwalker-handler nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFUNWALKER-HANDLER", "input": "(defunwalker-handler nil\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(class-stealth-mixins nil)\n\nWhat needs to change: Macro call that should be transformed by CLASS-STEALTH-MIXINS", "input": "(class-stealth-mixins nil)", "output": "(defmacro CLASS-STEALTH-MIXINS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fgatherlet nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by FGATHERLET", "input": "(fgatherlet nil\n :key\n nil)", "output": "(defmacro FGATHERLET ...)", "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(declaim)\n\nWrite a macro that addresses: Macro call that should be transformed by DECLAIM", "input": "(declaim)", "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(with-took-usec nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-TOOK-USEC", "input": "(with-took-usec nil\n (progn))", "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(lambda-cmatch*\n common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: 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 (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": "Write a Common Lisp macro to handle this code pattern:\n(f0\n nil\n nil)\n\nProblem: Macro call that should be transformed by F0", "input": "(f0\n nil\n nil)", "output": "(defmacro F0 ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(*let nil\n (progn))\n\nProblem: Macro call that should be transformed by *LET", "input": "(*let nil\n (progn))", "output": "(defmacro *LET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fbindrec nil)\n\nProblem: Macro call that should be transformed by FBINDREC", "input": "(fbindrec 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.79} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(ccase-of nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CCASE-OF", "input": "(ccase-of nil\n :key\n nil)", "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": "Generate a defmacro form that transforms code like this:\n(rg? 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by RG?", "input": "(rg? 'lol-gen::some-name)", "output": "(defmacro rg? (id)\n `(fm-find-registered ,id self nil))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(metaclass common-lisp:nil)\n\nIssue: Macro call that should be transformed by METACLASS", "input": "(metaclass common-lisp:nil)", "output": "(defmacro METACLASS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(callback nil)\n\nWrite a macro that addresses: Macro call that should be transformed by CALLBACK", "input": "(callback nil)", "output": "(defmacro callback (name)\n `(%callback ',name))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(match common-lisp:nil\n :key\n common-lisp:nil)\n\nPattern to recognize: Macro call that should be transformed by MATCH", "input": "(match common-lisp:nil\n :key\n 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.8999999999999999} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(collect-max nil nil)\n\nIssue: Macro call that should be transformed by COLLECT-MAX", "input": "(collect-max nil 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(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 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(pushnew nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by PUSHNEW", "input": "(pushnew nil :key nil)", "output": "(defmacro PUSHNEW ...)", "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 (progn))\n\nProblem: Macro call that should be transformed by DEF-LAUNCHED-ITER", "input": "(def-launched-iter nil\n (progn))", "output": "(defmacro DEF-LAUNCHED-ITER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(econd-let nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ECOND-LET", "input": "(econd-let 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": "Define a macro that eliminates this repetitive pattern:\n(coexit!)\n\nIssue: Macro call that should be transformed by COEXIT!", "input": "(coexit!)", "output": "(defmacro COEXIT! ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(class-stealth-mixins 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by CLASS-STEALTH-MIXINS", "input": "(class-stealth-mixins 'lol-gen::some-name)", "output": "(defmacro CLASS-STEALTH-MIXINS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(drelet* nil\n nil)\n\nIssue: 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": "You are a Common Lisp macro expert. Given this code pattern:\n(with-c-syntax common-lisp:nil\n (common-lisp:progn))\n\nWrite a macro that addresses: Macro call that should be transformed by WITH-C-SYNTAX", "input": "(with-c-syntax common-lisp:nil\n (common-lisp:progn))", "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(aprog1 nil\n (progn))\n\nIssue: Macro call that should be transformed by APROG1", "input": "(aprog1 nil\n (progn))", "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(with-decoder-simple-clos-semantics\n nil)\n\nIssue: Macro call that should be transformed by WITH-DECODER-SIMPLE-CLOS-SEMANTICS", "input": "(with-decoder-simple-clos-semantics\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.8624999999999999} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(nest common-lisp:nil :key common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by NEST", "input": "(nest common-lisp:nil :key 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": "Write a Common Lisp macro to handle this code pattern:\n(create-table nil\n nil)\n\nProblem: Macro call that should be transformed by CREATE-TABLE", "input": "(create-table nil\n nil)", "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": "Define a macro that eliminates this repetitive pattern:\n(fgathering nil\n nil)\n\nIssue: Macro call that should be transformed by FGATHERING", "input": "(fgathering nil\n nil)", "output": "(defmacro FGATHERING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(collect-min nil)\n\nProblem: Macro call that should be transformed by COLLECT-MIN", "input": "(collect-min 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(resolving\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by RESOLVING", "input": "(resolving\n 'lol-gen::some-name)", "output": "(defmacro RESOLVING ...)", "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": "Define a macro that eliminates this repetitive pattern:\n(accumulating-to-and-returning 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by ACCUMULATING-TO-AND-RETURNING", "input": "(accumulating-to-and-returning 'lol-gen::some-name)", "output": "(defmacro ACCUMULATING-TO-AND-RETURNING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(receive nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by RECEIVE", "input": "(receive nil\n :key\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": "Write a Common Lisp macro to handle this code pattern:\n(make* nil :key nil)\n\nProblem: Macro call that should be transformed by MAKE*", "input": "(make* nil :key nil)", "output": "(defmacro MAKE* ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(ensure nil)\n\nPattern to recognize: Macro call that should be transformed by ENSURE", "input": "(ensure 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(min-of 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by MIN-OF", "input": "(min-of 'lol-gen::some-name)", "output": "(defmacro MIN-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-integrity nil)\n\nIssue: Macro call that should be transformed by WITH-INTEGRITY", "input": "(with-integrity 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": "Define a macro that eliminates this repetitive pattern:\n(econd-let nil\n (progn))\n\nIssue: Macro call that should be transformed by ECOND-LET", "input": "(econd-let nil\n (progn))", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(fm-other? nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FM-OTHER?", "input": "(fm-other? nil 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": "You are a Common Lisp macro expert. Given this code pattern:\n(|^K2|)\n\nWrite a macro that addresses: Macro call that should be transformed by ^K2", "input": "(|^K2|)", "output": "(defmacro ^k2 () `(kid2 self))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(pass 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by PASS", "input": "(pass 'lol-gen::some-name)", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(nsib 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by NSIB", "input": "(nsib 'lol-gen::some-name)", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(update nil\n :key\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by UPDATE", "input": "(update nil\n :key\n nil)", "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(sql nil)\n\nWrite a macro that addresses: Macro call that should be transformed by SQL", "input": "(sql nil)", "output": "(defmacro sql (form)\n \"Convert the given form (a list starting with a keyword) to an SQL query\nstring at compile time, according to the rules described here. For example:\n\n (sql (:select '* :from 'country :where (:= 'a 1)))\n \\\"(SELECT * FROM country WHERE (a = 1))\\\"\n\nbut\n\n (sql '(:select '* :from 'country :where (:= 'a 1)))\n\nwould throw an error. For the later case you need to use sql-compile.\"\n (let ((list (reduce-strings (sql-expand form))))\n (if (= 1 (length list))\n (car list)\n `(strcat (list ,@list)))))", "category": "dsl", "technique": "recursive-expansion", "complexity": "advanced", "quality_score": 0.8274999999999999} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(nth-value nil (progn))\n\nIssue: Macro call that should be transformed by NTH-VALUE", "input": "(nth-value nil (progn))", "output": "(defmacro NTH-VALUE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(enable-markup-syntax)\n\nIssue: Macro call that should be transformed by ENABLE-MARKUP-SYNTAX", "input": "(enable-markup-syntax)", "output": "(defmacro enable-markup-syntax ()\n '(eval-when (:compile-toplevel :load-toplevel :execute)\n (%enable-markup-syntax)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8225} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(def-suite* 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DEF-SUITE*", "input": "(def-suite* 'lol-gen::some-name)", "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.8624999999999999} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defgeneric nil nil)\n\nWrite a macro that addresses: 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(old 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by OLD", "input": "(old 'lol-gen::some-name)", "output": "(defmacro old (expression)\n \"Only available in postconditions, OLD evaluates its expression before the\n primary method is executed and stores it for use in the postcondition.\"\n (let ((value (gensym)))\n `(if *preparing-postconditions*\n (let ((,value ,expression))\n (push ,value *postcondition-values*)\n ,value)\n (pop *postcondition-values*))))", "category": "anaphoric", "technique": "gensym,anaphor", "complexity": "intermediate", "quality_score": 0.7975} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(define-global-var nil (progn))\n\nProblem: 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": "Generate a defmacro form that transforms code like this:\n(ps-doc\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by PS-DOC", "input": "(ps-doc\n 'lol-gen::some-name)", "output": "(defmacro PS-DOC ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(destructuring-methods nil\n nil)\n\nIssue: Macro call that should be transformed by DESTRUCTURING-METHODS", "input": "(destructuring-methods nil\n nil)", "output": "(defmacro DESTRUCTURING-METHODS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(w/uniqs 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by W/UNIQS", "input": "(w/uniqs 'lol-gen::some-name)", "output": "(defmacro W/UNIQS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(iterate\n nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by ITERATE", "input": "(iterate\n nil\n :key\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": "Create a Common Lisp macro for the following transformation. Before code:\n(resolve\n nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by RESOLVE", "input": "(resolve\n nil\n :key\n nil)", "output": "(defmacro RESOLVE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(inext 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by INEXT", "input": "(inext 'lol-gen::some-name)", "output": "(defmacro INEXT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(max-of 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by MAX-OF", "input": "(max-of 'lol-gen::some-name)", "output": "(defmacro MAX-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(v-define-compiler-macro nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by V-DEFINE-COMPILER-MACRO", "input": "(v-define-compiler-macro nil\n (progn))", "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": "Write a Common Lisp macro to handle this code pattern:\n(with-yield\n nil\n (progn))\n\nProblem: Macro call that should be transformed by WITH-YIELD", "input": "(with-yield\n nil\n (progn))", "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(alter nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by ALTER", "input": "(alter nil (progn))", "output": "(defmacro ALTER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(with-ps-gensyms nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-PS-GENSYMS", "input": "(with-ps-gensyms nil\n (progn))", "output": "(defmacro WITH-PS-GENSYMS ...)", "category": "control-flow", "technique": "gensym", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(who-ps-html)\n\nWhat needs to change: Macro call that should be transformed by WHO-PS-HTML", "input": "(who-ps-html)", "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(upper nil (progn))\n\nWhat needs to change: Macro call that should be transformed by UPPER", "input": "(upper nil (progn))", "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(iterate nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by ITERATE", "input": "(iterate nil :key nil)", "output": "(defmacro ITERATE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(receive nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by RECEIVE", "input": "(receive nil\n (progn))", "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(let-match1 common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by LET-MATCH1", "input": "(let-match1 common-lisp:nil\n :key\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.875} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(finally nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FINALLY", "input": "(finally nil 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(collect-append nil nil)\n\nProblem: Macro call that should be transformed by COLLECT-APPEND", "input": "(collect-append nil nil)", "output": "(defmacro COLLECT-APPEND ...)", "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 '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 \"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(alambda nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by ALAMBDA", "input": "(alambda nil\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(ftype common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by FTYPE", "input": "(ftype common-lisp:nil)", "output": "(defmacro FTYPE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(skip-on nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by SKIP-ON", "input": "(skip-on nil\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": "Generate a defmacro form that transforms code like this:\n(printing-unreadably nil (progn))\n\nPattern to recognize: Macro call that should be transformed by PRINTING-UNREADABLY", "input": "(printing-unreadably nil (progn))", "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.8125} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(eko nil nil)\n\nIssue: Macro call that should be transformed by EKO", "input": "(eko nil 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": "Define a macro that eliminates this repetitive pattern:\n(lambda-match\n 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by LAMBDA-MATCH", "input": "(lambda-match\n 'lol-gen::some-name)", "output": "(defmacro LAMBDA-MATCH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(returning 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by RETURNING", "input": "(returning 'lol-gen::some-name)", "output": "(defmacro RETURNING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(make* nil (progn))\n\nWrite a macro that addresses: 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": "Create a Common Lisp macro for the following transformation. Before code:\n(foreign-funcall nil)\n\nWhat needs to change: Macro call that should be transformed by FOREIGN-FUNCALL", "input": "(foreign-funcall nil)", "output": "(defmacro foreign-funcall (name-and-options &rest args)\n \"Wrapper around %FOREIGN-FUNCALL that translates its arguments.\"\n (let ((name (car (ensure-list name-and-options)))\n (options (cdr (ensure-list name-and-options))))\n (foreign-funcall-form name options args nil)))", "category": "anaphoric", "technique": "anaphor,recursive-expansion", "complexity": "intermediate", "quality_score": 0.885} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(subtest nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by SUBTEST", "input": "(subtest nil\n nil)", "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(collecting\n nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by COLLECTING", "input": "(collecting\n nil\n (progn))", "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": "Write a Common Lisp macro to handle this code pattern:\n(newq nil)\n\nProblem: Macro call that should be transformed by NEWQ", "input": "(newq nil)", "output": "(defmacro NEWQ ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(unless nil (progn))\n\nWhat needs to change: 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": "Create a Common Lisp macro for the following transformation. Before code:\n(c?once\n 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by C?ONCE", "input": "(c?once\n 'lol-gen::some-name)", "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(html5 nil :key nil)\n\nIssue: Macro call that should be transformed by HTML5", "input": "(html5 nil :key 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": "Define a macro that eliminates this repetitive pattern:\n(nest nil :key nil)\n\nIssue: Macro call that should be transformed by NEST", "input": "(nest nil :key 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.8975} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(eko-if 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by EKO-IF", "input": "(eko-if 'lol-gen::some-name)", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(none-of nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by NONE-OF", "input": "(none-of nil\n 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(->> 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by ->>", "input": "(->> 'lol-gen::some-name)", "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": "Write a Common Lisp macro to handle this code pattern:\n(v-defun nil\n nil)\n\nProblem: Macro call that should be transformed by V-DEFUN", "input": "(v-defun nil\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": "Write a Common Lisp macro to handle this code pattern:\n(from)\n\nProblem: Macro call that should be transformed by FROM", "input": "(from)", "output": "(defmacro from (&rest statements)\n `(make-clause :from ,@(mapcar #'expand-op statements)))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(export-slots\n common-lisp:nil\n :key\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by EXPORT-SLOTS", "input": "(export-slots\n common-lisp:nil\n :key\n common-lisp:nil)", "output": "(defmacro EXPORT-SLOTS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(who-ps-html 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by WHO-PS-HTML", "input": "(who-ps-html 'lol-gen::some-name)", "output": "(defmacro WHO-PS-HTML ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(dlet* 'lol-gen::some-name)\n\nIssue: 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": "You are a Common Lisp macro expert. Given this code pattern:\n(on-conflict-do-update nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by ON-CONFLICT-DO-UPDATE", "input": "(on-conflict-do-update nil (progn))", "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": "Generate a defmacro form that transforms code like this:\n(is nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by IS", "input": "(is nil :key nil)", "output": "(defmacro is (comp expected form &optional description &rest format-args)\n `(eval-in-context\n *context*\n (make-instance 'comparison-result\n :expression '(is ,comp ,expected ,form)\n :value-form ',form\n :body (lambda () ,form)\n :expected ,expected\n :comparison ,(maybe-quote comp)\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(jand nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by JAND", "input": "(jand nil (progn))", "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": "Generate a defmacro form that transforms code like this:\n(prog* ())\n\nPattern to recognize: Macro call that should be transformed by PROG*", "input": "(prog* ())", "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(modf-eval nil nil)\n\nWhat needs to change: Macro call that should be transformed by MODF-EVAL", "input": "(modf-eval nil nil)", "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(when 'lol-gen::some-name)\n\nWrite a macro that addresses: 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": "Create a Common Lisp macro for the following transformation. Before code:\n(def-kid-slots nil nil)\n\nWhat needs to change: Macro call that should be transformed by DEF-KID-SLOTS", "input": "(def-kid-slots nil 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(with-column-writers nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by WITH-COLUMN-WRITERS", "input": "(with-column-writers nil\n (progn))", "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(the-part nil nil)\n\nWrite a macro that addresses: Macro call that should be transformed by THE-PART", "input": "(the-part nil nil)", "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(cond-let nil\n nil)\n\nWhat needs to change: Macro call that should be transformed by COND-LET", "input": "(cond-let nil\n 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": "Generate a defmacro form that transforms code like this:\n(bind-custom-vars nil)\n\nPattern to recognize: Macro call that should be transformed by BIND-CUSTOM-VARS", "input": "(bind-custom-vars 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.7775} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda-coro\n 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-CORO", "input": "(lambda-coro\n 'lol-gen::some-name)", "output": "(defmacro LAMBDA-CORO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(collect-hash nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by COLLECT-HASH", "input": "(collect-hash nil :key nil)", "output": "(defmacro COLLECT-HASH ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(defconstant nil nil)\n\nProblem: Macro call that should be transformed by DEFCONSTANT", "input": "(defconstant nil nil)", "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-column-writers nil)\n\nProblem: Macro call that should be transformed by WITH-COLUMN-WRITERS", "input": "(with-column-writers 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.86} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(match nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by MATCH", "input": "(match nil\n :key\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<var> := <symbol> | '_'\n<lhs> := '_'\n | (<symbol> <var>*)\n<clause> := (<lhs> <lisp code>)\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(nconcf nil)\n\nIssue: Macro call that should be transformed by NCONCF", "input": "(nconcf 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(let-match common-lisp:nil\n :key\n common-lisp:nil)\n\nWhat needs to change: 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, 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.8999999999999999} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(any-of nil\n nil)\n\nIssue: Macro call that should be transformed by ANY-OF", "input": "(any-of nil\n 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(with-took-usec nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-TOOK-USEC", "input": "(with-took-usec nil\n 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(lambda-cmatch1 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-CMATCH1", "input": "(lambda-cmatch1 'lol-gen::some-name)", "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-special-initargs nil\n nil)\n\nIssue: 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": "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 &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.8624999999999999} |
| {"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 -<> ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(m 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by M", "input": "(m 'lol-gen::some-name)", "output": "(defmacro M ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fm^ 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by FM^", "input": "(fm^ 'lol-gen::some-name)", "output": "(defmacro fm^ (md-name &key (skip-tree 'self) (must-find t))\n `(without-c-dependency\n (fm-find-one (fm-parent self) ,md-name\n :skip-tree ,skip-tree\n :must-find ,must-find\n :global-search t)))", "category": "anaphoric", "technique": "anaphor", "complexity": "basic", "quality_score": 0.8474999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(make-nodelist nil)\n\nProblem: Macro call that should be transformed by MAKE-NODELIST", "input": "(make-nodelist nil)", "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.86} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(lambda-bind nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by LAMBDA-BIND", "input": "(lambda-bind nil\n (progn))", "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": "Write a Common Lisp macro to handle this code pattern:\n(dowhile-let 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by DOWHILE-LET", "input": "(dowhile-let 'lol-gen::some-name)", "output": "(defmacro dowhile-let ((var test) &body body)\n \"Like DOWHILE. VAR will be bound to TEST.\"\n `(do ((,var ,test ,test))\n ((not ,var))\n ,@body))", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8624999999999999} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(fm-map nil nil)\n\nProblem: Macro call that should be transformed by FM-MAP", "input": "(fm-map nil nil)", "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": "Define a macro that eliminates this repetitive pattern:\n(fbindrec* nil\n :key\n nil)\n\nIssue: Macro call that should be transformed by FBINDREC*", "input": "(fbindrec* nil\n :key\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": "You are a Common Lisp macro expert. Given this code pattern:\n(local*\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by LOCAL*", "input": "(local*\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(w/uniqs nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by W/UNIQS", "input": "(w/uniqs nil\n :key\n nil)", "output": "(defmacro W/UNIQS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(with-array nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-ARRAY", "input": "(with-array nil\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(defjsmacro 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by DEFJSMACRO", "input": "(defjsmacro 'lol-gen::some-name)", "output": "(defmacro DEFJSMACRO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(do-sequences! 'lol-gen::some-name)\n\nIssue: 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 \"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": "Create a Common Lisp macro for the following transformation. Before code:\n(gatherlet nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by GATHERLET", "input": "(gatherlet nil\n (progn))", "output": "(defmacro GATHERLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(defpattern common-lisp:nil\n common-lisp:nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPATTERN", "input": "(defpattern common-lisp:nil\n common-lisp:nil)", "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 \"~<Lambda-List: ~s~\n ~:@_~< ~@;~a~:>~\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.875} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(swhen nil)\n\nPattern to recognize: Macro call that should be transformed by SWHEN", "input": "(swhen 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": "You are a Common Lisp macro expert. Given this code pattern:\n(mapping)\n\nWrite a macro that addresses: Macro call that should be transformed by MAPPING", "input": "(mapping)", "output": "(defmacro MAPPING ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(nsplice-seqf nil :key nil)\n\nProblem: Macro call that should be transformed by NSPLICE-SEQF", "input": "(nsplice-seqf nil :key nil)", "output": "(defmacro NSPLICE-SEQF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(define-shared-method nil\n :key\n nil)\n\nWhat needs to change: Macro call that should be transformed by DEFINE-SHARED-METHOD", "input": "(define-shared-method nil\n :key\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(make-window-or-instance 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by MAKE-WINDOW-OR-INSTANCE", "input": "(make-window-or-instance 'lol-gen::some-name)", "output": "(defmacro MAKE-WINDOW-OR-INSTANCE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defvariant 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DEFVARIANT", "input": "(defvariant 'lol-gen::some-name)", "output": "(defmacro DEFVARIANT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(asif nil :key nil)\n\nProblem: Macro call that should be transformed by ASIF", "input": "(asif nil :key 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": "Create a Common Lisp macro for the following transformation. Before code:\n(export-accessors\n common-lisp:nil\n (common-lisp:progn))\n\nWhat needs to change: Macro call that should be transformed by EXPORT-ACCESSORS", "input": "(export-accessors\n common-lisp:nil\n (common-lisp:progn))", "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(adowhile nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by ADOWHILE", "input": "(adowhile nil\n (progn))", "output": "(defmacro ADOWHILE ...)", "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 nil)\n\nWrite a macro that addresses: Macro call that should be transformed by IS-FALSE", "input": "(is-false nil 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": "Write a Common Lisp macro to handle this code pattern:\n(local\n nil)\n\nProblem: Macro call that should be transformed by LOCAL", "input": "(local\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(with-took-usec nil\n :key\n nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-TOOK-USEC", "input": "(with-took-usec nil\n :key\n 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.8624999999999999} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(keep-bops nil nil)\n\nIssue: Macro call that should be transformed by KEEP-BOPS", "input": "(keep-bops nil nil)", "output": "(defmacro KEEP-BOPS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(rg! nil)\n\nPattern to recognize: Macro call that should be transformed by RG!", "input": "(rg! nil)", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(decase nil)\n\nWhat needs to change: Macro call that should be transformed by DECASE", "input": "(decase nil)", "output": "(defmacro decase (keyform &body clauses)\n \"DECASE is a combination of ECASE 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 ECASE,\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 'ecase))", "category": "control-flow", "technique": "", "complexity": "intermediate", "quality_score": 0.86} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(eval-always\n 'lol-gen::some-name)\n\nProblem: Macro call that should be transformed by EVAL-ALWAYS", "input": "(eval-always\n 'lol-gen::some-name)", "output": "(defmacro EVAL-ALWAYS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(fn nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FN", "input": "(fn nil)", "output": "(defmacro FN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(set-data nil (progn))\n\nPattern to recognize: Macro call that should be transformed by SET-DATA", "input": "(set-data nil (progn))", "output": "(defmacro set-data (obj (name &rest new-values))\n \"Mutate the fields of the ADT value OBJ whose constructor is NAME\nand whose updated values are NEW-VALUES based on order. If the symbol\n'_' is used as a value, that field is not updated. Trailing '_' may be\nomitted.\"\n (let ((once (gensym \"ONCE\")))\n `(let ((,once ,obj))\n (psetf\n ,@(loop :for i :from 0\n :for x :in new-values\n :when (not (wild? x))\n :append (list `(,(field name i) ,once)\n x))))))", "category": "control-flow", "technique": "gensym", "complexity": "intermediate", "quality_score": 0.86} |
| {"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": "Generate a defmacro form that transforms code like this:\n(finish nil (progn))\n\nPattern to recognize: Macro call that should be transformed by FINISH", "input": "(finish nil (progn))", "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": "Generate a defmacro form that transforms code like this:\n(ccase-of nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by CCASE-OF", "input": "(ccase-of nil\n nil)", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(defobject nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFOBJECT", "input": "(defobject nil\n (progn))", "output": "(defmacro DEFOBJECT ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(when nil :key nil)\n\nPattern to recognize: Macro call that should be transformed by WHEN", "input": "(when nil :key 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(either\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by EITHER", "input": "(either\n nil\n (progn))", "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(of-type nil (progn))\n\nProblem: Macro call that should be transformed by OF-TYPE", "input": "(of-type nil (progn))", "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": "Create a Common Lisp macro for the following transformation. Before code:\n(is-every nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by IS-EVERY", "input": "(is-every nil\n (progn))", "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": "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 <*> (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-in nil)\n\nProblem: Macro call that should be transformed by C-IN", "input": "(c-in nil)", "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": "Define a macro that eliminates this repetitive pattern:\n(true nil)\n\nIssue: Macro call that should be transformed by TRUE", "input": "(true 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": "You are a Common Lisp macro expert. Given this code pattern:\n(js nil)\n\nWrite a macro that addresses: Macro call that should be transformed by JS", "input": "(js nil)", "output": "(defmacro JS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(some-<> 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by SOME-<>", "input": "(some-<> 'lol-gen::some-name)", "output": "(defmacro some-<> (init &body exps) (diamond-wand 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(finally nil (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by FINALLY", "input": "(finally nil (progn))", "output": "(defmacro FINALLY ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(fm? nil (progn))\n\nIssue: Macro call that should be transformed by FM?", "input": "(fm? nil (progn))", "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(dynamic-relet nil\n (progn))\n\nIssue: Macro call that should be transformed by DYNAMIC-RELET", "input": "(dynamic-relet nil\n (progn))", "output": "(defmacro DYNAMIC-RELET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(with-transaction nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-TRANSACTION", "input": "(with-transaction nil\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.7975} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(with-unique-js-names)\n\nPattern to recognize: Macro call that should be transformed by WITH-UNIQUE-JS-NAMES", "input": "(with-unique-js-names)", "output": "(defmacro WITH-UNIQUE-JS-NAMES ...)", "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-of nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DESTRUCTURING-CCASE-OF", "input": "(destructuring-ccase-of nil\n (progn))", "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": "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": "Define a macro that eliminates this repetitive pattern:\n(defmacro-driver 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by DEFMACRO-DRIVER", "input": "(defmacro-driver 'lol-gen::some-name)", "output": "(defmacro DEFMACRO-DRIVER ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"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) (diamond-wand 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(w/uniqs nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by W/UNIQS", "input": "(w/uniqs nil\n (progn))", "output": "(defmacro W/UNIQS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(swhen 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by SWHEN", "input": "(swhen 'lol-gen::some-name)", "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": "You are a Common Lisp macro expert. Given this code pattern:\n(defun* nil\n nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFUN*", "input": "(defun* nil\n 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(lambda-match\n nil\n (progn))\n\nWhat needs to change: Macro call that should be transformed by LAMBDA-MATCH", "input": "(lambda-match\n nil\n (progn))", "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(ignore common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by IGNORE", "input": "(ignore common-lisp:nil)", "output": "(defmacro IGNORE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(like nil (progn))\n\nWhat needs to change: Macro call that should be transformed by LIKE", "input": "(like nil (progn))", "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(defalias nil\n (progn))\n\nWrite a macro that addresses: Macro call that should be transformed by DEFALIAS", "input": "(defalias nil\n (progn))", "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(with-c-syntax common-lisp:nil)\n\nWhat needs to change: Macro call that should be transformed by WITH-C-SYNTAX", "input": "(with-c-syntax 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.9125} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(rte-ecase 'lol-gen::some-name)\n\nWhat needs to change: Macro call that should be transformed by RTE-ECASE", "input": "(rte-ecase 'lol-gen::some-name)", "output": "(defmacro RTE-ECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7675} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(do-combinations 'lol-gen::some-name)\n\nPattern to recognize: Macro call that should be transformed by DO-COMBINATIONS", "input": "(do-combinations 'lol-gen::some-name)", "output": "(defmacro DO-COMBINATIONS ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6975} |
| {"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": "Define a macro that eliminates this repetitive pattern:\n(jor nil)\n\nIssue: Macro call that should be transformed by JOR", "input": "(jor 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(dotimes (quote lol-gen::some-name))\n\nWhat needs to change: 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": "Write a Common Lisp macro to handle this code pattern:\n(defdata nil\n :key\n nil)\n\nProblem: Macro call that should be transformed by DEFDATA", "input": "(defdata nil\n :key\n nil)", "output": "(defmacro defdata (adt-name &body constructors)\n \"Define a new ADT. ADT-name has the following grammar:\n\nADT-NAME := <symbol>\n | (<symbol> <options>*)\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 <adt-type>: Specifies whether another defined ADT\n should be inherited.\n\nConstructors is a list of clauses with the following grammar:\n\n<clause> := <symbol>\n | (<symbol> <type-specifier>*)\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": "Generate a defmacro form that transforms code like this:\n(ensure-list nil\n nil)\n\nPattern to recognize: Macro call that should be transformed by ENSURE-LIST", "input": "(ensure-list nil\n 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": "Create a Common Lisp macro for the following transformation. Before code:\n(and-bind nil nil)\n\nWhat needs to change: Macro call that should be transformed by AND-BIND", "input": "(and-bind nil nil)", "output": "(defmacro AND-BIND ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.6825} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(with-packages-unlocked nil)\n\nPattern to recognize: Macro call that should be transformed by WITH-PACKAGES-UNLOCKED", "input": "(with-packages-unlocked nil)", "output": "(defmacro WITH-PACKAGES-UNLOCKED ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(defgeneric nil\n (progn))\n\nIssue: 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": "Define a macro that eliminates this repetitive pattern:\n(with-foreign-objects nil\n nil)\n\nIssue: Macro call that should be transformed by WITH-FOREIGN-OBJECTS", "input": "(with-foreign-objects nil\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": "Generate a defmacro form that transforms code like this:\n(possibly?\n nil\n (progn))\n\nPattern to recognize: Macro call that should be transformed by POSSIBLY?", "input": "(possibly?\n nil\n (progn))", "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(scase nil\n (progn))\n\nProblem: Macro call that should be transformed by SCASE", "input": "(scase nil\n (progn))", "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": "Define a macro that eliminates this repetitive pattern:\n(ecase nil (progn))\n\nIssue: Macro call that should be transformed by ECASE", "input": "(ecase nil (progn))", "output": "(defmacro ECASE ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(2nd 'lol-gen::some-name)\n\nWrite a macro that addresses: Macro call that should be transformed by 2ND", "input": "(2nd 'lol-gen::some-name)", "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(all-of nil)\n\nIssue: Macro call that should be transformed by ALL-OF", "input": "(all-of nil)", "output": "(defmacro ALL-OF ...)", "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\nWhat needs to change: 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 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.815} |
| {"instruction": "Write a Common Lisp macro to handle this code pattern:\n(when-let nil)\n\nProblem: Macro call that should be transformed by WHEN-LET", "input": "(when-let 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(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(pprint-coalton-codegen-ast\n common-lisp:nil\n (common-lisp:progn))\n\nPattern to recognize: Macro call that should be transformed by PPRINT-COALTON-CODEGEN-AST", "input": "(pprint-coalton-codegen-ast\n common-lisp:nil\n (common-lisp:progn))", "output": "(defmacro PPRINT-COALTON-CODEGEN-AST ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.8049999999999999} |
| {"instruction": "Create a Common Lisp macro for the following transformation. Before code:\n(defproto nil :key nil)\n\nWhat needs to change: Macro call that should be transformed by DEFPROTO", "input": "(defproto nil :key nil)", "output": "(defmacro DEFPROTO ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(list-of nil\n nil)\n\nIssue: Macro call that should be transformed by LIST-OF", "input": "(list-of nil\n nil)", "output": "(defmacro LIST-OF ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Generate a defmacro form that transforms code like this:\n(static-let* nil)\n\nPattern to recognize: Macro call that should be transformed by STATIC-LET*", "input": "(static-let* 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.8025} |
| {"instruction": "You are a Common Lisp macro expert. Given this code pattern:\n(maxf nil :key nil)\n\nWrite a macro that addresses: Macro call that should be transformed by MAXF", "input": "(maxf nil :key nil)", "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(static-let nil)\n\nWhat needs to change: Macro call that should be transformed by STATIC-LET", "input": "(static-let 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": "Define a macro that eliminates this repetitive pattern:\n(with-gensyms 'lol-gen::some-name)\n\nIssue: Macro call that should be transformed by WITH-GENSYMS", "input": "(with-gensyms 'lol-gen::some-name)", "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": "Write a Common Lisp macro to handle this code pattern:\n(wnotrc nil\n nil)\n\nProblem: Macro call that should be transformed by WNOTRC", "input": "(wnotrc nil\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": "You are a Common Lisp macro expert. Given this code pattern:\n(fgatherlet nil)\n\nWrite a macro that addresses: Macro call that should be transformed by FGATHERLET", "input": "(fgatherlet nil)", "output": "(defmacro FGATHERLET ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
| {"instruction": "Define a macro that eliminates this repetitive pattern:\n(define-template nil :key nil)\n\nIssue: Macro call that should be transformed by DEFINE-TEMPLATE", "input": "(define-template nil :key nil)", "output": "(defmacro DEFINE-TEMPLATE ...)", "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 nil)\n\nWrite a macro that addresses: Macro call that should be transformed by DEFPATTERN", "input": "(defpattern nil\n nil)", "output": "(defmacro DEFPATTERN ...)", "category": "control-flow", "technique": "", "complexity": "basic", "quality_score": 0.7525} |
|
|