(call-with-dynamic-bind ((var1 val1)(var2 val2)...) stuff...)
It lets you introduce dynamically scoped variables that work pretty much the way you described.
(call-with-dynamic-bind ((var1 val1)(var2 val2)...) stuff...)
It lets you introduce dynamically scoped variables that work pretty much the way you described.
(There is a dynamic binding operator called progv, but the situation for that is when the variable names are computed.)
So dynamically scoped contexts are achieved just by binding these special variables. By convention, they are usually given names beginning and ending with an asterisk ("earmuffs") to put them into an effectively separate namespace.
That parametrize is reminiscent of fluid-let; another Scheme hack to simulate dynamic scope.
Most of the major scheme implementations I've used have had real dynamic scoping of some sort. I don't think it's very well supported in the standard, but they all seem to have it as a proper language feature.
(with-output-to-string (*standard-output*)
... code ... )
Here, code's output to the default standard output stream is captured in a string.