Mark H. <mark.hoemmen@gmail.com> wrote:
+---------------
| Would it be accurate to assume that in all reasonable multithreaded
| CL's out there, calling a named function FOO does NOT involve locking
| (SYMBOL-FUNCTION 'FOO) with a mutex or something of the sort?
+---------------
I should think so, since unlike the SYMBOL-VALUE slot of a symbol,
which is rebound *dynamically* by LET, the SYMBOL-FUNCTION slot
of a symbol is rebound *lexically* by FLET (or LABELS), and thus
(unlike the SYMBOL-VALUE slot) doesn't need to interact with the
threading system at all.[1] E.g.:
> (defvar foo 'global-value)
FOO
> (defun foo () 'global-function)
FOO
> (defun bar () (list foo (foo)))
BAR
> (bar)
(GLOBAL-VALUE GLOBAL-FUNCTION)
> (let ((foo 'local-value))
(flet ((foo () 'local-function))
(list* foo (foo) (bar))))
(LOCAL-VALUE LOCAL-FUNCTION LOCAL-VALUE GLOBAL-FUNCTION)
>
Capische?
-Rob
[1] Well, unless you're changing the value of the SYMBOL-FUNCTION
slot yourself, in which case since you've caused the issue it's
up to you to fix it (e.g., with explicitly-coded locks).
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607