One criticism of using the static chain to access nonlocal variables is that
references to variables in scopes beyond the static parent cost more than references
to locals. The static chain must be followed, one link per enclosing scope from the reference to the declaration. Fortunately, in practice, references to
distant nonlocal variables are rare, so this is not a serious problem. Another
criticism of the static-chain approach is that it is difficult for a programmer
working on a time-critical program to estimate the costs of nonlocal references,
because the cost of each reference depends on the depth of nesting between the
reference and the scope of declaration. Further complicating this problem is
that subsequent code modifications may change nesting depths, thereby changing
the timing of some references, both in the changed code and possibly in
code far from the changes.
Are there any more potential problems with this approach?
Excluded two problems are:
A nonlocal reference is slow if the number of scopes between the reference and the declaration of the referenced variable is large. Time-critical code is difficult, because the costs of nonlocal references are not equal, and can change with code upgrades and fixes.
However, the static chain must be modified for each subprogram call and return. The action required at a subprogram call is complex. Although the correct parent scope is easily determined at compile time, the most recent activation record instance of the parent scope must be found at the time of the call. The long walk through the static chain would be an overhead. Some alternatives to static chains have been developed, most notably an approach that uses an auxiliary data structure called a display (Static chain is better, unless the display can be kept in registers). However, none of the alternatives has been found to be superior to the static-chain method, which is still the most widely, used approach. Also, deep access which also superior in dynamic scoping acts in a similar way in creating the dynamic link.