Schemes for Indirect Control

There are two fundamental approaches to indirect control in code.1

In an open approach, we can change the behavior of dereferencing code by conveying different values. The decision-making mechanism must be unordered. Typically, this is implemented in code using a data structure with a distinct set of keys, i.e. a lookup table.

In a closed approach, we can only change the decision-making process by changing the underlying code. A conditional, e.g. an expression that uses an if/elif/else or match/case form in Python, is closed. It is ordered, and if predicates aren’t disjoint, order matters.

While an open table conveys values, a conditional decides based on values. For a table to be useful, it must avoid conflicts. Conditionals avoid conflicts by making explicit, fixed decisions. An open approach must avoid conflicts in a dynamic way.

Consider all the kinds of tricks we use to try to force ourselves to work when we’re tired or distracted:

So many schemes for self-control! How do we choose which ones to use? There isn’t any easy way. Self-discipline takes years to learn; it grows inside us stage by stage.

This post was adapted from a note sent to my email list on Machine-Centric Science.
I'd love for you to subscribe.

  1. Z. Tellman, Elements of Clojure. Monee, IL:, 2019. ↩︎