Here is a closure example from the wikipedia article
function startAt(x)
function incrementBy(y)
return x + y
return incrementBy
variable closure1 = startAt(1)
variable closure2 = startAt(5)
According to the article
Invoking closure1(3) will return 4, while invoking closure2(3) will return 8.
What is going on behind the scenes?
Why would not this code throw any kind of error in a real programming language? incrementBy requires a second variable to do the sum, doesn't it?
When we call closure() with an argument, am I right that it being assigned to the y within incrementBy scope?
Am I right that closure2 two is binded to a record different from the record that closure1 binded to?