[Openmcl-devel] process-run-function and "dynamic vs lexical"

james anderson james.anderson at setf.de
Thu Oct 22 18:27:10 UTC 2009


[something makes me wonder, that's mr dachraoui may just be testing.]

On 2009-10-22, at 19:58 , Daniel Weinreb wrote:

> Taoufik,
>
> Just to make sure this was clear, the difference
> between the two examples isn't whether funcall
> per se is being used; the difference is what thread
> the closure is run in.  The first example runs the
> closure in another process.  The symbol f
> is intepreted as a dynamic variable, and it sees
> the global value, rather than 3, because the value 3
> is specific to the main thread, and does not apply
> to the newly-created thread.  Bindings of dynamic
> varaibles apply only to the thread in which they
> were bound.

the thread issue is a red-herring.
cf issues re special variables and scheduler predicates.

? (funcall (let ((x 2) (y 3))
              (labels ((f () (format t "~%@~s: x=~A y=~A~%" *current- 
process* x y)))
                (ccl:process-run-function "test" #'f)
                (funcall #'f)
                #'f)))

@#<PROCESS Listener [Running] #x3328746>: x=2 y=3

@#<PROCESS Listener [Running] #x3328746>: x=2 y=1
NIL

@#<PROCESS test [Running] #x38B5D9E>: x=2 y=1
? 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20091022/7762c83c/attachment.html>


More information about the Openmcl-devel mailing list