02 Jul '12, 12am

@stilkov I agree with @Carnage4Life

There is a chain of lexical scopes, each with local variables. When code needs to lookup a variable, it while search that environment, by iterating up that chain until it finds it. A closure is an function object that references a specific inner scope. It is said to “capture” that lexical scope. For example if you return an routine that references some local variables. Two closures can close over the same scope, thus sharing state as it gets modified. There is a second such chain which represents the chain of control (tracking which instruction you’re at in a given function). When a function is called, an exception occurs,... that chain gets involved. For example, when a function is invoked, a new lexical scope is created and a marker is also added to the control chain. If you take a chain of lexical variable scopes (as found in a closure) and associate it with a chain of ...

Full article: http://www.intertwingly.net/blog/2005/04/13/Continuations...

Tweets