Please help with 3.15. Thank you
The principal argument in favor of dynamic scoping is that it facilitates the customization of subroutines. Suppose, for example, that we have a library routine print-integer that is capable of printing its argument in any of several bases (decimal, binary, hexadecimal, etc.). Suppose further that we want the routine to use decimal notation most of the time, and to use other bases only in a few special cases: we do not want to have to specify a base explicitly on each individual call. We can achieve this result with dynamic scoping by having print-integer obtain its base from a nonlocal variable print-base. We can establish the default behavior by declaring a variable print-base and setting its value to 10 in a scope encountered early in execution. Then, any time we want to change the base temporarily, we can write The problem with this argument is that there are usually other ways to achieve the same effect, without dynamic scoping. Describe at least two for the print_integer example.
1) First way would be using a stack, whenever a function is called and it requires some other base, new base can be pushed on top of stack and that value can be used. and when the function completes execution it can be removed from top. It always gives the topmost element of stack as the current base so access time is decresed compared to dynamic scoping.
2) One other way would be passing the current base as argument which will increse memory usage a little but all over the performance will increse as less time will be required for searching.