6.7 Dynamic Scoping

In a dynamically scoped language, the determination of the declaration to which a reference is bound requires run-time information. In a typical implementation of dynamic scoping, it is the calling sequence of procedures, and not their lexical relationship to each other, that is used to determine the declaration to which each reference is bound. While Scheme uses lexical scoping, for the purpose of demonstration, we use the following Scheme expression to demonstrate dynamic scoping:

A set of seven code lines in a Scheme expression for demonstrating dynamic scoping.
Description

In this expression we see nonlocal references to x and y in the definition of proc2 on line 2, which does not provide declarations ...

Get Programming Languages: Concepts and Implementation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.