generators with continuations

This implementation is actually buggy. It is possible to get into infinite loops. For an explanation of why that happens I recommend reading the following section of a continuation passing interpreter written in JavaScript.

I didn’t understand continuations until I read somewhere about the connection between generators and continuations. The idea kept gnawing at me until I went ahead and tried to make a generator with continuations and that’s when things clicked into place. So without further ado here is a step by step guide on how to implement generators in Ruby with callcc. Continue reading

exploring a problem solving design space

This post started out as

because I was trying to write about designing a DSL that deals with variables with multiple values. Continue reading

How does Ruby do X?

The answer can usually be found with ruby -rdebug or ruby -rtracer. There is also the trick with RUBYOPT. If you are executing something with bundler then you can run RUBYOPT="-rdebug" bundle exec ${command} and you will be dropped in the debugger as usual.