Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • not sure why this is downvoted. Completely true Commented Jul 15, 2023 at 21:31
  • 2
    The most efficient way to implement dynamic scoping is NOT to walk up the stack, but instead to have a "global" stack (for each dynamic thingy) for which the top can be consulted in O(1)... Commented Jul 16, 2023 at 17:05
  • @MatthieuM. sure, as an implementation detail (although it gets tricky with concurrency). I don't like that as a mental model though, since it relies on semantics of mutability, time, etc. which we may not want/have in our surface language: e.g. dynamic scope works perfectly well in a pure-functional setting, pushing/popping a stack in-place has no meaning. Commented Jul 17, 2023 at 9:25