85.1k views
5 votes
It is stated in this chapter that when nonlocal variables are accessed in a dynamic-scoped language using the dynamic chain, variable names must be stored in the activation records with the values. If this were actually done, every nonlocal access would require a sequence of costly string comparisons on names. Design an alternative to these string comparisons that would be faster.

User Puudeli
by
8.0k points

1 Answer

4 votes

Answer:

See the explanation for the answer.

Step-by-step explanation:

As in the dynamically scoped language, using the dynamic chain, variable name must be stored in the activation records with the values. The alternative strategy is as follows:

Collection sort() can be used for this as an alternative to compare the String which is completely based on a different way by implementing interfaces for comparison and sorting being happened in different ways.

User Alex Choroshin
by
8.4k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.