Patrick May pjm@spe.com writes:
Hi,
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.
-T.
On Dec 6, 2008, at 3:12 AM, Tobias C. Rittweiler wrote:
Patrick May pjm@spe.com writes:
Hi,
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.
Almost exactly a year later, I get bit by a similar issue (although it did trigger my memory of this discussion). Basically, the same thing happens with gensym as with random -- in Slime it returns a symbol with the same name every time. Is this a ccl issue or a slime issue? Has anyone got a workaround so that I can run unit tests within slime?
Thanks,
Patrick
On Nov 30, 2009, at 12:45 PM, Patrick May wrote:
On Dec 6, 2008, at 3:12 AM, Tobias C. Rittweiler wrote:
Patrick May pjm@spe.com writes:
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.
Almost exactly a year later, I get bit by a similar issue (although it did trigger my memory of this discussion). Basically, the same thing happens with gensym as with random -- in Slime it returns a symbol with the same name every time. Is this a ccl issue or a slime issue? Has anyone got a workaround so that I can run unit tests within slime?
*GENSYM-COUNTER* is thread-loaal in CCL.
Using GENSYM as a shortcut way to generate lisp-wide unique strings therefore does not work.
Patrick May patrick.may@mac.com writes:
On Dec 6, 2008, at 3:12 AM, Tobias C. Rittweiler wrote:
Patrick May pjm@spe.com writes:
Hi,
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.
Almost exactly a year later, I get bit by a similar issue (although it did trigger my memory of this discussion). Basically, the same thing happens with gensym as with random -- in Slime it returns a symbol with the same name every time. Is this a ccl issue or a slime issue? Has anyone got a workaround so that I can run unit tests within slime?
(funcall (cdr (assoc '*gensym-counter* (ccl::standard-initial-bindings)))) => 0
But why do you care?
On Nov 30, 2009, at 2:26 PM, Stas Boukarev wrote:
Patrick May patrick.may@mac.com writes:
On Dec 6, 2008, at 3:12 AM, Tobias C. Rittweiler wrote:
Patrick May pjm@spe.com writes:
Hi,
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.
Almost exactly a year later, I get bit by a similar issue (although it did trigger my memory of this discussion). Basically, the same thing happens with gensym as with random -- in Slime it returns a symbol with the same name every time. Is this a ccl issue or a slime issue? Has anyone got a workaround so that I can run unit tests within slime?
(funcall (cdr (assoc '*gensym-counter* (ccl::standard-initial-bindings)))) => 0
But why do you care?
What I'm trying to do is test incrementally within Slime, but the fact that these kinds of things behave differently than they do from the repl or from a loaded image makes that impossible.
That's not to say that I'm not abusing gensym a little bit in this particular instance. ;-)
Thanks,
Patrick