Lexical scope vs. Dynamic scope

Modern languages don’t really do dynamic scope. The only vaguely recent language I can think of that has it is Perl 5, which has both, and that’s not really a modern language, and I think using dynamically scoped variables is generally considered a bad idea even in Perl. Perhaps there’s some confusion about what dynamic and lexical scope mean. When you say “parent scope” what do you mean by that? Do you mean the scope of the caller? Or the surrounding scope in the code?

4 Likes