On this page:
A Note on Dynamic Scope
2016-04-02

A Note on Dynamic Scope

Éric Tanter

This note complements the discussion on dynamic scope from PLAI (Sect 5.2). The book regards dynamic scope simply as a mistake. In doing so, it fails to recognize the value of dynamically-scoped bindings, which most modern languages support in some way or another, for good reasons.

The bottom line is that dynamic scope by default is indeed a mistake, but dynamic scope as a feature is not.

    1 Alternatives to Dynamic Scope

      1.1 Extra Arguments

      1.2 Global Variables

    2 When is Dynamic Scope Useful?

      2.1 Configuration

      2.2 Adaptation

      2.3 The Case of Exceptions

    3 Dynamic Scope in Programming Languages

      3.1 Dynamic Scope by Default

      3.2 Dynamic Scope as a Feature

    4 Perspective