Re: Maxima and thread safety
Michel Talon <[email protected]> Tue, 9 Jun 2026 22:47:44 +0200
| Newsgroups | gmane.comp.mathematics.maxima.general |
|---|---|
| Message-ID | <[email protected]> |
Le 09/06/2026 à 17:33, Stavros Macrakis a écrit : > Binding it locally just saves the outside value and sets the value > cell to the new value. I don't think this is what happens with sbcl with threading support -at the lisp level. As David has shown by looking at the value of sb-vm::*free-tls-index*, when binding a special variable in a form like let, prog, etc. what people call dynamic binding, the value is not stored in the value cell of the special variable, but in thread local storage. Unfortunately this does not happen for special variables defined in the global scope like those defined by defvar or defparameter at the top level, which can be seen and modified everywhere, and in all threads, with the "exception" that the value in a child thread doesn't inherit from the value in the parent thread as modified in a let form. The example i have provided shows that. This is the cause of problems with maxima which has a lot of global special variables. By the way, for the ignorant like me, the binding of the special variable *x* is called dynamic because it subsists for all duration of the form which establishes it, for example (let ((*x* 3)...)....) including eventual function calls in the let form, and disappears at the end of the form. There are examples of this in the simptimes program, which puzzled me a lot. Finally, in view of that, one can understand the following sentence of CLTL: "It is convenient to define /dynamic scope/ to mean /indefinite scope and dynamic extent/. Thus we speak of ``special'' variables as having dynamic scope, or being dynamically scoped, because they have indefinite scope and dynamic extent: a special variable can be referred to anywhere as long as its binding is currently in effect" Conversely lexical variables have lexical scope, can be referred to only inside the form where they are defined, but may have indefinite extent, that is the binding can subsist outside of the form creating it in closures. -- Michel Talon _______________________________________________ Maxima-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/maxima-discuss