Your confusion is due to using “scope”, which is actually a lexical concept. What you’re dealing with here is variable substitution: in order to evaluate a function call such as posterior = ApplyBayes(prior, evidence1), the actual function arguments need to be plugged into the definition of ApplyBayes(·, ·). This is always true, regardless of what variable names are used in the code for ApplyBayes.
I certainly hope that I’m not confused about my word choice. I write compilers for a living, so I might be in trouble if I don’t understand elementary terms.
In all seriousness, my use of the word “scope” was imprecise, because the phenomenon I’m describing is more general than that. I don’t know of a better term though, so I don’t regret my choice. Perhaps you can help? Students that I’ve seen have difficulty with variable substitution seem to have difficulty with static scoping as well, and vice versa. To me they feel like different parts of the same confusion.
In a related note, I once took some of my students aside who where having great difficulty getting static scoping, and tried to teach them a bit of a dynamically-scoped LISP. I had miserable results, which is to say that I don’t think the idea of dynamic scope resonated with them any more than static scope; I was hoping maybe it would, that there were “dynamic scoping people” and “static scoping people”. Maybe there are; my experiment is far from conclusive.
EDIT: Hilariously, right after I wrote this comment the newest story on Hacker News was http://news.ycombinator.com/item?id=4534408, “Actually, YOU don’t understand lexical scope!”. To be honest, the coincidence of the headline gave me a bit of a start.
Your confusion is due to using “scope”, which is actually a lexical concept. What you’re dealing with here is variable substitution: in order to evaluate a function call such as
posterior = ApplyBayes(prior, evidence1)
, the actual function arguments need to be plugged into the definition ofApplyBayes(·, ·)
. This is always true, regardless of what variable names are used in the code forApplyBayes
.I certainly hope that I’m not confused about my word choice. I write compilers for a living, so I might be in trouble if I don’t understand elementary terms.
In all seriousness, my use of the word “scope” was imprecise, because the phenomenon I’m describing is more general than that. I don’t know of a better term though, so I don’t regret my choice. Perhaps you can help? Students that I’ve seen have difficulty with variable substitution seem to have difficulty with static scoping as well, and vice versa. To me they feel like different parts of the same confusion.
In a related note, I once took some of my students aside who where having great difficulty getting static scoping, and tried to teach them a bit of a dynamically-scoped LISP. I had miserable results, which is to say that I don’t think the idea of dynamic scope resonated with them any more than static scope; I was hoping maybe it would, that there were “dynamic scoping people” and “static scoping people”. Maybe there are; my experiment is far from conclusive.
EDIT: Hilariously, right after I wrote this comment the newest story on Hacker News was http://news.ycombinator.com/item?id=4534408, “Actually, YOU don’t understand lexical scope!”. To be honest, the coincidence of the headline gave me a bit of a start.