News for hackers. Stuff that matters.
Re:Dynamic Scoping in C++ by catern on Monday September 21, 2020 @12:23PM (#24545247)
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.

Re:Dynamic Scoping in C++ by masklinn on Monday September 21, 2020 @01:32PM (#24546132)
> 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.

Re:Dynamic Scoping in C++ by jolmg on Monday September 21, 2020 @12:25PM (#24545272)
Yes, that's why:

> besides the thread issue you mentioned