freenode/#lisp - IRC Chatlog
Search
21:26:56
VincentVega
Good day/night all! Wondering, so I have a dynamic variable (it's global and all functions use it conveniently). Now, I want to run the code in a few threads (independently), each having it's own (thread-specific) value of the dynamic variable. Can this be done?
21:27:51
aeth
I think dynamic variables are always thread-specific? Probably an implementation-specific thing, but I thought it's sort of part of the bordeaux-threads assumptions.
21:30:26
aeth
VincentVega: I think the most portable way to do it would be to wrap the thread entry point (inside of the lambda that's run on the new thread in bt:make-thread) in a LET?
21:31:10
aeth
initial-bindings is what I must've been thinking of, but it has some implementation-specific behavior
21:36:31
aeth
let over lambda is the implementation-specific behavior BT is warning you not to do in bt:make-thread's documentation
21:49:23
aeth
It's a design pattern. This means the proper solution is to use a make-thread* macro to do that instead. :-p
22:19:55
White_Flame
I guess a with-* macro would be a design pattern, as there aren't specifically scope management operations in lisp
22:22:17
aeth
White_Flame: Correct. When Lispers criticize design patterns as unnecessary in Common Lisp, I bring up the case of "macro design pattern" conventions, like with-foo (usually with an unwind-protect), define-foo (usually with a defun, but maybe it deals with a different global definition), do-foo (iteration), etc.
22:22:55
aeth
White_Flame: Although to be fair, you could turn some of these into macros, even though only define-modify-macro (like incf/decf) actually is like that in the standard.
22:23:19
fwoaroof[m]
I generally think of "design patterns" as involving fairly complicated code structures that have to be manually implemented every time
22:27:09
aeth
solve the package name conflict issue in Quicklisp so you can say with-every-single-asdf-system-in-quicklisp-loaded
22:29:47
aeth
think of all of the fun surprises realized by modifying global state, e.g. you might discover that (with-every-system-loaded (+ 1 1)) => ٢
7:18:27
phoe
sure thing I would, since the original term "design pattern" attaches itself to things as petty as the Singleton and the Decorator