The remove-duplicates function should receive (:key #'car ) argument, since it is intended to remove the same variable being bound. Patch attached.<br><br>By the way, I was thinking if it could be possible to bind some local variables (since not all implementations support closures).<br>
<br><span style="font-family: courier new,monospace;"> (defvar *closure-value-table* (make-hash-table :test #'eq :size 10))<br><br>(defmacro make-thread-with-closure ((&rest vars) function<br>                                    &rest make-thread-args)<br>
  (let ((vars (mapcar #'(lambda (var)<br>                          (if (atom var) (list var) var))<br>                      vars))<br>        (table-code (gensym)))<br>    `(progn<br>       (setf (gethash ',table-code *closure-value-table*)<br>
             (list ,@(mapcar #'second vars)))<br>       (make-thread (lambda ()<br>                      (destructuring-bind ,(mapcar #'car vars)<br>                          (gethash ',table-code *closure-value-table*)<br>
                        (remhash ',table-code *closure-value-table*)<br>                        (funcall ,function))) ,@make-thread-args))))<br><br>cl-user> (make-thread-with-closure ((a 1) (b 2))<br>                   (lambda ()<br>
                     (+ a b)))<br>#<sb-thread:thread "Anonymous" running {1005745721}><br>cl-user> *<br>#<sb-thread:thread "Anonymous" finished values: 3 {1005745721}><br>cl-user> </span><br>
<br>Maybe a lock is needed to access the hash-table since not all implementations support concurrent table access, but that is the general idea.<br><br>Gustavo.<br>