4 ms·
If you have multiple threads which try to bind the dynamically scoped variable to a new value, that should work fine and result in different values for the vari
by catern 6y ago
If you have multiple threads which try to bind the dynamically scoped variable to a new value, that should work fine and result in different values for the variable in each thread.
In this implementation, the threads will corrupt the data structure and result in undefined behavior.
- jolmg 6y agoYes, that's why: > besides the thread issue you mentioned
- masklinn 6y ago> If you have multiple threads which try to bind the dynamically scoped variable to a new value, that should work fine and result in different values for the variable in each thread. That would work with proper threadlocals. However with dynamic variables you'd also get this for different sub-thread stacks. Not all languages can expose that but languages with generators do e.g. in Python if you `yield` then the stack is suspended, this means a threadlocal you've changed would not be rolled back, but a dynamic variable (which Python does not have) would.