back

by matheusmoreira·8y ago·view on hn ↗
> Imagine that function A binds the variable FOO, and calls the function B, which calls the function C, and C uses the value of FOO.

Languages that lack dynamic scoping typically propagate a reference to a "context" through the B function. One can see this common pattern in threading libraries such as pthreads, for example. The A function creates a data structure that contains everything C needs, passes it to B as the "context" parameter and it is then forwarded to C.

It's more verbose but also more explicit.