[Openmcl-devel] process-run-function and "dynamic vs lexical"
taoufik.dachraoui at wanadoo.fr
Thu Oct 22 16:51:53 UTC 2009
On Oct 22, 2009, at 6:36 PM, Jon S. Anthony wrote:
> Also, note the :initial-bindings parameter to process-run-function.
Ok, now I learn that there :initial-bindings, thanks.
But still, the behavior was totally unexpected for me for the
reasons I tried to explain in my earlier post.
Please look again at my post, and tell me what is wrong with my
> This enables you to achieve the sort of thing you seem to want.
> One other thing, I strongly suggest you adopt (in all cases) the idiom
> of naming top level specials (definitely things in def(var|parameter))
> with '*' bookends:
> (defvar *y* 1)
> You will be a happier camper...
> On Thu, 2009-10-22 at 12:08 -0400, Greg Pfeil wrote:
>> On 22 Oct 2009, at 11:42, Taoufik Dachraoui wrote:
>>> Just for completeness I include the example:
>>> ? (defvar y 1)
>>> ? (let ((x 2) (y 3))
>>> (labels ((f () (format t "~%x=~A y=~A~%" x y)))
>>> (ccl:process-run-function "test" #'f)))
>>> #<PROCESS test(3) [Reset] #x8D43546>
>>> x=2 y=1
>>> let creates new variable binding for the names x and y and these
>>> bindings are lexical unless they are declared special.
>>> Where is my mistake, please note here that I would like to reconcile
>>> my understanding with what I see while running ccl code.
>> If you check Ron's guide to specials (http://www.flownet.com/ron/specials.pdf
>> ), the section "The pervasiveness of DEFVAR" explains what you're
>> "Because DEFVAR does more than just establish a dynamic binding for
>> It pervasively declares all references to X and all subsequent
>> bindings for X to be dynamic (or special -- same thing). In other
>> words, DEFVAR turns its argument (permanently and pervasively) into a
>> special variable."
>> So the Y <= 3 binding is actually for the special variable, but the
>> binding of the 3 is thread-local, so your function run in its own
>> thread still sees the value 1.
>> Openmcl-devel mailing list
>> Openmcl-devel at clozure.com
More information about the Openmcl-devel