[Ecls-list] separate environments for threads

Dustin Long dlong at stevens.edu
Tue Jun 26 02:48:07 UTC 2007


Has anyone ever used ECL threads much, to the extent that they could see 
separate environments for each thread? I'm running this code sample:

(defun demo-envs ()
  (let (p q)
    (setf p (mp:make-process))
    (setf q (mp:make-process))
    (mp:process-preset p
                       (lambda ()
                         (eval '(progn (defvar x 1)
                                       (dotimes (i 1000)
                                         (format t "A ~s ~s~%" x i))))))
    (mp:process-preset q
                       (lambda ()
                         (eval '(progn (defvar x 2)
                                       (dotimes (i 1000)
                                         (format t "B ~s ~s~%" x i))))))
    (mp:process-enable p)
    (mp:process-enable q)))

And I thought that it should yield a series of "A 1 ..." and "B 2 ..." 
printouts, but instead I'm seeing "A 1 ..." and "B 1 ...". I was under 
the impression that x should be distinct in p and q because it is 
defined in that thread's environment, but it looks like it's being 
defined globally instead. What am I doing wrong here? Problem appears in 
both WinXP and Ubuntu.

Dustin




More information about the ecl-devel mailing list