updated with a code example
The example is very impressive but I didn't grok it at first (I'm still not sure to have understood it yet!).
I don't see yet where and when I would use them but it's a new way for me to think about the execution of the code that I'm not accustomed to. Very interesting stuff!
Here is the Ruby code corresponding to the analogy:
puts "Walking..." turn_left = callcc do | turn_left | turn_left end if turn_left puts "Turning left..." puts "Bitten by a dog!" bitten = callcc do | bitten | bitten end turn_left.call false if turn_left puts "I prefer to bleed!" else puts "Turning right..." puts "Hit by a train!" bitten.call puts "DEAD!!" end
Walking... Turning left... Bitten by a dog Turning right... Hit by a train! I prefer to bleed!