[Openmcl-devel] Slime / CCL interaction: random returning the same value

Patrick May patrick.may at mac.com
Sun Dec 13 16:24:34 PST 2009


	I raised the following issue on the Slime mailing list and got a couple of helpful responses that at least explained why I was seeing what I was seeing:

>>>> 	I'm using Slime in Aquamacs with CCL.  When I evaluate (random
>>>> 100) repeatedly in CCL started from a shell, I get a randomly
>>>> generated  number between 0 and 99 inclusive.  When I do the same with
>>>> C-x C-e  within Slime, I get the same number every time.  (random 100
>>>> (make-random-state)) gives the same behavior, but
>>>> (random 100 (make-random-state t)) works properly.
>>>> 	Is Slime caching something or have I hosed up my environment?
>>> Sorry for the late response.  CCL's swank backend uses threads by
>>> default, and threads inherit values from the global
>>> environment. *RANDOM-STATE* probably becomes thread-local automatically
>>> in CCL, resulting in the behaviour you described.
>>> It should work when you type in the form at the Slime REPL which
>>> evaluates all forms in the same thread.

Some poking around with the Slime documentation shows that I can change swank:*communication-style* from :SPAWN to :SIGIO or :FD-HANDLER to avoid this issue, but :SIGIO has some caveats associated with it.

	Is there a way to make the random state not thread local?



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2421 bytes
Desc: not available
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20091213/1918c189/attachment.bin>

More information about the Openmcl-devel mailing list