<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body text="#000000" bgcolor="#ffffff">
<br>
<br>
Raffael Cavallaro wrote:
<blockquote type="cite" cite="mid:833D6118-592A-426B-8830-9F9770C4D1E1@mac.com">
<pre wrap="">On Mar 19, 2011, at 1:09 AM, Jason E. Aten wrote:
</pre>
<blockquote type="cite">
<pre wrap="">In order words, when two different threads need to be able to name the same variable (after locking the thread inspects the shared variable, possibly updates it, then releases the lock), how do I tell lisp this is what I'd like?
</pre>
</blockquote>
<pre wrap=""><!---->
See section 4.8 of the documentation "Static Variables"
e.g., (defstatic *foo* 3)
It's an error to dynamically rebind a static variable; its value is always the same across all threads. Naturally, as you suggest, you'll want to avoid race conditions by using a lock or semaphore.
</pre>
</blockquote>
By the way, defstatic is not part of the Common Lisp standard.<br>
It is provided by CCL ("OpenMCL"), but I have no idea which<br>
other Common Lisp implementations support it. This may or<br>
may not matter to you. If you need to port to a Common<br>
Lisp dialect that doesn't have defstatic, you can simply<br>
change it (perhaps under read-time conditionalization<br>
or using a macro) to another form, such as defparameter<br>
or defvar depending on how you're using it, so you<br>
are not painting yourself into a corner by using<br>
defstatic.<br>
<br>
-- Dan<br>
<br>
</body>
</html>