On 13 October 2012 15:47, Damien Cassou <[email protected]> wrote:
> I'm looking for a piece of code that is hard to understand by looking
> at the source code but which has unit tests that help understanding
> the behavior.
>
> Do you have any idea?

http://ss3.gemstone.com/ss/Control/ has tests for delimited dynamic
variables. The idea's not terribly complicated - close over a variable
and use resumable exceptions to refer to it or change it - but if you
don't have that in-a-nutshell idea in your head it can look a bit
strange. But the tests in ControlTests' DelimitedDynamicVariableTest
show quite clearly how dynamic binding works.

(The delimited part probably won't make a lot of sense until one's
managed to wrap one's head around control operators - shift, in this
case - so the nice interaction between the delimited continuations and
the delimited dynamic variables might be lost on a newbie.)

frank

> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm."
> Winston Churchill
>

Reply via email to