News for hackers. Stuff that matters.
Re:Dynamic Scoping in C++ by kazinator on Monday September 21, 2020 @02:31PM (#24546802)
I implemented exactly the same thing 20 years ago. It looked something like:

  Dynamic<int> foo;  // define at global scope

  {
     DynamicBind<int> foo; // re-bind dynamically
  }
It used thread-local storage and all. The global constructor for the Dynamic<> template class would allocate the thread specific key. The DynamicBind<> template class did the saving, location altering, and restoring.
Re:Dynamic Scoping in C++ by stettberger on Wednesday September 23, 2020 @08:25AM (#24566154)
That is very cool! Do you have a link to that implementation? I would be very interested in the problems that arise when you want to provide a rock solid implementation of this.