Monday, December 18, 2006

Another Program As Story

Here's another attempt to convey both code and text in one shot.

The solution the author uses is simply to start every paragraph of text with a comment character. As the author explains:

Also, beginning with this post you will notice that the paragraphs all start with semicolons, as if this were a source file. Well you would be correct. In an effort to keep the code in these discussions as real as possible, the entire post starts off life as a scheme source file. Further, every effort is made such that you can merely cut and paste this entire post, text and all, into your favorite editor or directly into DrScheme and you should get precisely the same results as I show in the text.

It's a neat hack that provides for some lightweight literate programming.

Still, I'd love to see a Scheme solution where code was marked off by delimiters instead of the text of the article. I think the Haskell version I found earlier is easier to read and run than this approach.

No comments:

Post a Comment