Tuesday, July 22, 2003

Continuations
Alright, I played arounda little bit with continuations in Dolphin Smalltalk and it was great! I worked on the Generator code that is in Hal Fulton's excellent book on Ruby. I rewrote the code in Ruby originally and had a lot of problems with it, but could not find the problem. Well, I ran the exact same code (same design and layout) in Dolphin and it worked perfectly. I think Ruby might have a problem with its local variables in its continuations, but I'll keep playing with it before I pass judgement. I did the Fibonacci number scheme which is boring, I know. But, the thing I love about continuations is the possibility of writing direct code (placing items in a stream) and using the continuations to get the next values. This is great for not only web navigation, but the handling of large amounts of data! Imagine writing code that processes the input stream as its coming and then writing directly back out to the output stream without the need of bringing both completely into memory. My next project is to do a PipedInput/PipedOutput stream implementation using continuations instead of threads. This way you could use the pipe within a thread, but still write your code in a more direct and accessible way.

No comments: