Thursday, June 08, 2006

Practical Common Lisp - Google Video

Practical Common Lisp - Google Video

The above is a link to an excellent Lisp propaganda education video by Peter Seibel. Peter is the author of Practical Common Lisp and in this talk he discusses why Common Lisp is such a terrific language. He takes you through three language features which you don't find in Java and other mainstream languages.

One of the three topics covered was about how Common Lisp allows you to handle errors in a fairly non-conventional way. In Java, for example, when an error happens you throw an exception. This causes the signaling of an error, as well as the actual control flow, to be taken back up the stack.

Peter explains that in Common Lisp you can send send the signal of an error up the stack, yet have the control flow remain at the lower level in the running code. The code higher up in the stack can then decide the best way to resume the process and can effectively restart the process from the lower level. Obviously, my description here can't do the idea justice - so watch the video. It's a fairly novel concept, and one that once I heard had me wondering why I hadn't thought of it.

It's interesting that Peter chose to use a mythical log processor to discuss his error strategy with, as I've faced the exact problem he mentioned while helping to write a complex log parsing system (LogLoading - ahhh, the good old days). His strategy sounds like it would have been an excellent way to deal with, and recover from, errors with individual lines of text.

Me being a Scheme guy, think that this could all be implemented fairly easily using continuations. But in Scheme, continuations are almost always the answer.

No comments:

Post a Comment