📝Dynamic scoping is a better model for global variables



Dynamic scoping for global variables allows for better dependency injection and testability. You can override the variable’s value for one function call without affecting the rest of the program.

They can parameterize the behavior of a module in a disciplined way; they are “tamed” global variables that support concurrency and re-entrance. —https://wiki.c2.com/?SpecialVariable

See also