<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/2.1.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Lisp conditions - more powerful than exceptions</title>
	<link>http://phildawes.net/blog/2006/06/26/lisp-conditions-more-powerful-than-exceptions/</link>
	<description>Mostly programming with a few bits of other stuff</description>
	<pubDate>Fri, 21 Nov 2008 00:25:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.1</generator>

	<item>
		<title>By: James Langley</title>
		<link>http://phildawes.net/blog/2006/06/26/lisp-conditions-more-powerful-than-exceptions/#comment-8674</link>
		<author>James Langley</author>
		<pubDate>Tue, 27 Jun 2006 10:07:53 +0000</pubDate>
		<guid>http://phildawes.net/blog/2006/06/26/lisp-conditions-more-powerful-than-exceptions/#comment-8674</guid>
					<description>Hmm.  It seems as though there's a danger here of leaking information outside the called method.  If I call the parse file method, how do I as the caller know what to do if there's a problem parsing the document?  If I'm expected to know that, then you can just make that feature part of the API - "I'll call you back when there's a problem parsing the file".  Perhaps I'm missing something but I'm not sure that this doesn't solve a problem that soluble in other ways.</description>
		<content:encoded><![CDATA[<p>Hmm.  It seems as though there&#8217;s a danger here of leaking information outside the called method.  If I call the parse file method, how do I as the caller know what to do if there&#8217;s a problem parsing the document?  If I&#8217;m expected to know that, then you can just make that feature part of the API - &#8220;I&#8217;ll call you back when there&#8217;s a problem parsing the file&#8221;.  Perhaps I&#8217;m missing something but I&#8217;m not sure that this doesn&#8217;t solve a problem that soluble in other ways.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Phil Dawes</title>
		<link>http://phildawes.net/blog/2006/06/26/lisp-conditions-more-powerful-than-exceptions/#comment-8684</link>
		<author>Phil Dawes</author>
		<pubDate>Tue, 27 Jun 2006 13:41:55 +0000</pubDate>
		<guid>http://phildawes.net/blog/2006/06/26/lisp-conditions-more-powerful-than-exceptions/#comment-8684</guid>
					<description>Hi James,

The caller knows what to do because it has requirements it wants to fulfill. If you want a parser that silently ignores the errors you write an exception handler that invokes the 'skip-line' restart. If you want to log you do that etc..

This problem is certainly solvable in other ways - you could implement an error callback, or maybe an abstract base class or strategy pattern or something. AFAICS the benefit of the condition system is that it's quick and easy to do the right thing upfront - you defer the error conditions to the caller, who is more likely to know what it wants to do and can change later.

E.g. If I'm writing a parse function in python/java I don't think 'this should be an abstract base class because I might want to reuse it in other circumstances later' - I just write and test the function (simplest thing).
Then when the program wants to ignore unparseable lines I might add a flag-argument to the function. Finally I might refactor it into a class structure later when I need to use it in other systems. 
With conditions I just add the resume points to the function - the refactoring is small and idiomatic.

(btw, it's early days for me and common lisp, so I don't have any practical experience of how well this works)</description>
		<content:encoded><![CDATA[<p>Hi James,</p>
<p>The caller knows what to do because it has requirements it wants to fulfill. If you want a parser that silently ignores the errors you write an exception handler that invokes the &#8217;skip-line&#8217; restart. If you want to log you do that etc..</p>
<p>This problem is certainly solvable in other ways - you could implement an error callback, or maybe an abstract base class or strategy pattern or something. AFAICS the benefit of the condition system is that it&#8217;s quick and easy to do the right thing upfront - you defer the error conditions to the caller, who is more likely to know what it wants to do and can change later.</p>
<p>E.g. If I&#8217;m writing a parse function in python/java I don&#8217;t think &#8216;this should be an abstract base class because I might want to reuse it in other circumstances later&#8217; - I just write and test the function (simplest thing).<br />
Then when the program wants to ignore unparseable lines I might add a flag-argument to the function. Finally I might refactor it into a class structure later when I need to use it in other systems.<br />
With conditions I just add the resume points to the function - the refactoring is small and idiomatic.</p>
<p>(btw, it&#8217;s early days for me and common lisp, so I don&#8217;t have any practical experience of how well this works)</p>
]]></content:encoded>
				</item>
</channel>
</rss>
