Comment 3 for bug 1761306

Revision history for this message
Andrzej Walczak (andrzejwalczak) wrote :

I am sorry to reopen this.
I believe that propagating DX property outside of a non-DX closure is an error.

The &rest args list here is an example of things that get into the closure of BAR - it was just used as an example. Having outside scope variables become DX is contrary to the referential transparency check.

code2:

(defun thread-loop (count bar)
  (loop :repeat count :do (funcall bar)))

(defmacro spaw (count &body body)
 `(sb-thread:make-thread
   (lambda ()
     (flet ((bar () ,@body))
       ;; The assumption here is that BAR is local to
       ;; the above LAMBDA and it will not be called outside DX.
       (declare (dynamic-extent #'bar))
       (thread-loop ,count #'bar)))))

(defun foo (&rest args)
  ;; ARGS not declare here as DX.
  (spawn 10 (apply #'format t args)))