Sometimes dynamic scoping is convenient. The behavior of a function can be changed without recompiling, just by calling it from inside an environment where global identifiers have different bindings. The example above shows that assignment commands also make programs harder to understand. The fundamental advantage of functional programming languages is that they are easier to understand, because they do not have the complexity of assignment commands. If a program is easier to understand, it is also easier for a compiler to optimize.
Files are persistent variables.
Most languages have implementation-dependent restrictions on persistent variables. For example in Pascal a persistent variable must be of the type file of X for some component type X . These limitations were to take account of implementation constraints, but they are excessive. For example Pascal has no random-access files. When it is called, it yields a result value.