Transcript from the "Dynamic Scope" Lesson
[00:00:21] And we would normally think of it as resolving to that variable because that's how we think lexically. But in a dynamically scoped language, it wouldn't even consult the lexical scope nesting, it would say, hey, where was ask called from. So where was ask called from? It was called from the scope of other class and it would end up resolving teacher to that variable.
>> Kyle: Can you see then that the idea of a dynamic scope is the idea that a function's references to its variables are depended upon where that function was called from? The same function called from 100 different places ends up giving 100 different answers to what the variables are, that may sound like chaos but you should also think of that as sounding like an amazing amount of flexibility and reuse.
[00:01:10] Imagine writing one function that could be re-used in all of those different contexts, and these are not right or wrong, by the way. It's not like dynamic scope is bad and evil or weird, it's just so unfamiliar to us because we don't think of it that way. But if you had only ever written dynamic scope and somebody explained lexical scope, they'd say, but how do you like re-use your functions?
[00:01:59] So I want you to keep in your mind right now this difference between fixed, predictable, and dynamic, and flexible.