<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Clojure&#8217;s :pre and :post</title>
	<atom:link href="http://blog.fogus.me/2009/12/21/clojures-pre-and-post/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fogus.me/2009/12/21/clojures-pre-and-post/</link>
	<description>λ λ λ</description>
	<lastBuildDate>Sun, 29 Jan 2012 10:17:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: fogus</title>
		<link>http://blog.fogus.me/2009/12/21/clojures-pre-and-post/comment-page-1/#comment-13224</link>
		<dc:creator>fogus</dc:creator>
		<pubDate>Thu, 31 Dec 2009 02:29:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fogus.me/?p=2008#comment-13224</guid>
		<description>&lt;p&gt;@ Alexander&lt;/p&gt;

&lt;p&gt;Thanks for the great comment.  There is much to ponder and there no longer and excuse for me to avoid Eifel.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

&lt;p&gt;-m&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@ Alexander</p>

<p>Thanks for the great comment.  There is much to ponder and there no longer and excuse for me to avoid Eifel.</p>

<p>Thanks for reading.</p>

<p>-m</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://blog.fogus.me/2009/12/21/clojures-pre-and-post/comment-page-1/#comment-13192</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Tue, 29 Dec 2009 09:20:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fogus.me/?p=2008#comment-13192</guid>
		<description>&lt;p&gt;One thing that is always missed when people try to re-implement Eiffel&#039;s design by contract is that the real strength of design by contract is how it interacts with polymorphism.&lt;/p&gt;

&lt;p&gt;In Clojure, :pre and :post should have been defined on generic functions where they shine.&lt;/p&gt;

&lt;p&gt;You don&#039;t want simple :pre and :post, you want abstractions such as constrained-fn in the example above.&lt;/p&gt;

&lt;p&gt;In design by contract, constrained-fn should be a multi-method.  The contract for constrained-fn should be that:&lt;/p&gt;

&lt;p&gt;Precondition:  The argument should be positive, &lt;em&gt;BUT CAN BE RELAXED&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Postcondition: The result should be doubled, &lt;em&gt;BUT CAN BE STRENGTHENED&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Thus, preconditions should be combined by disjunction.
Postconditions should be combined by conjunction.&lt;/p&gt;

&lt;p&gt;This should be done by the multi-method dispatch system.  All preconditions for applicable functions should be ORed together and evaluated.  The postconditions for all applicable functions should be ANDed together and evaluated.&lt;/p&gt;

&lt;p&gt;Why is this essential feature missed by everyone?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>One thing that is always missed when people try to re-implement Eiffel&#8217;s design by contract is that the real strength of design by contract is how it interacts with polymorphism.</p>

<p>In Clojure, :pre and :post should have been defined on generic functions where they shine.</p>

<p>You don&#8217;t want simple :pre and :post, you want abstractions such as constrained-fn in the example above.</p>

<p>In design by contract, constrained-fn should be a multi-method.  The contract for constrained-fn should be that:</p>

<p>Precondition:  The argument should be positive, <em>BUT CAN BE RELAXED</em>.</p>

<p>Postcondition: The result should be doubled, <em>BUT CAN BE STRENGTHENED</em>.</p>

<p>Thus, preconditions should be combined by disjunction.
Postconditions should be combined by conjunction.</p>

<p>This should be done by the multi-method dispatch system.  All preconditions for applicable functions should be ORed together and evaluated.  The postconditions for all applicable functions should be ANDed together and evaluated.</p>

<p>Why is this essential feature missed by everyone?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: fogus</title>
		<link>http://blog.fogus.me/2009/12/21/clojures-pre-and-post/comment-page-1/#comment-13105</link>
		<dc:creator>fogus</dc:creator>
		<pubDate>Wed, 23 Dec 2009 20:51:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fogus.me/?p=2008#comment-13105</guid>
		<description>&lt;p&gt;@Toshkov&lt;/p&gt;

&lt;p&gt;One advantage that :pre and :post have over assert is that the former allows the &quot;assertions&quot; to potentially come from a different source than the body of the function.  This is what my example implies, even if I didn&#039;t elucidate that exact point.  :pre and :post also make it relatively easy to do some fancy automatic test generate and as a bonus provide a form of documentation for the function.  Chris Houser added another interesting point that I was not aware of, &quot;using assert instead of :pre is usually pretty straightforward, if you had to do it. Using assert instead of :post is a pain.&quot;  Sounds reasonable.  Along that point, Chas Emerick&#039;s assessment that :pre and :post cover 99.5% of assert uses, plus provide simple, and consistent hooks.&lt;/p&gt;

&lt;p&gt;Hope that helps.  Thanks for reading.&lt;/p&gt;

&lt;p&gt;-m&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Toshkov</p>

<p>One advantage that :pre and :post have over assert is that the former allows the &#8220;assertions&#8221; to potentially come from a different source than the body of the function.  This is what my example implies, even if I didn&#8217;t elucidate that exact point.  :pre and :post also make it relatively easy to do some fancy automatic test generate and as a bonus provide a form of documentation for the function.  Chris Houser added another interesting point that I was not aware of, &#8220;using assert instead of :pre is usually pretty straightforward, if you had to do it. Using assert instead of :post is a pain.&#8221;  Sounds reasonable.  Along that point, Chas Emerick&#8217;s assessment that :pre and :post cover 99.5% of assert uses, plus provide simple, and consistent hooks.</p>

<p>Hope that helps.  Thanks for reading.</p>

<p>-m</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Toshkov</title>
		<link>http://blog.fogus.me/2009/12/21/clojures-pre-and-post/comment-page-1/#comment-13099</link>
		<dc:creator>Ivan Toshkov</dc:creator>
		<pubDate>Wed, 23 Dec 2009 08:51:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fogus.me/?p=2008#comment-13099</guid>
		<description>&lt;p&gt;How is that better than what we have today?&lt;/p&gt;

&lt;p&gt;(defn constrained-fn [f x]
  (assert (pos? x))
  (let [r (f x)]
    (assert (= r (* 2 x)))
    r))&lt;/p&gt;

&lt;p&gt;One can easily write a simple macro to handle the boilerplate.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>How is that better than what we have today?</p>

<p>(defn constrained-fn [f x]
  (assert (pos? x))
  (let [r (f x)]
    (assert (= r (* 2 x)))
    r))</p>

<p>One can easily write a simple macro to handle the boilerplate.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: fogus</title>
		<link>http://blog.fogus.me/2009/12/21/clojures-pre-and-post/comment-page-1/#comment-13093</link>
		<dc:creator>fogus</dc:creator>
		<pubDate>Tue, 22 Dec 2009 14:06:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.fogus.me/?p=2008#comment-13093</guid>
		<description>&lt;p&gt;@Rettke,&lt;/p&gt;

&lt;p&gt;Have I ever mentioned that PLT Scheme never ceases to amaze me?  Well, I am now.&lt;/p&gt;

&lt;p&gt;-m&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Rettke,</p>

<p>Have I ever mentioned that PLT Scheme never ceases to amaze me?  Well, I am now.</p>

<p>-m</p>]]></content:encoded>
	</item>
</channel>
</rss>

