<?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"
	>
<channel>
	<title>Comments on: A Fling with Lazy Evaluation</title>
	<atom:link href="http://blog.tmorris.net/a-fling-with-lazy-evaluation/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tmorris.net/a-fling-with-lazy-evaluation/</link>
	<description>The weblog of Tony Morris</description>
	<pubDate>Fri, 05 Dec 2008 09:48:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Tony Morris</title>
		<link>http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1692</link>
		<dc:creator>Tony Morris</dc:creator>
		<pubDate>Sun, 21 Oct 2007 08:59:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1692</guid>
		<description>Hi Anonymous Coward,
I know what Dynamic Programming means. I'd just *love* to see your Levenshtein Distance written in Java :)

Here's mine in Scala:
http://tinyurl.com/ywuk86

You will note that its essence is 5 lines of code. Again, I await your Java solution :)

You think this is nitpicking? First, it has *nothing* at all to do with OOA/OOD and neither does Java for that matter. I only just had a whinge recently about passing under-qualified comment and the topic was "OO" (how about that?), so I best refrain for now for my own sanity. Interestingly, Wadler's type-classes came up in that discussion; have you heard of them before? I find that they are a good place to start a discussion and meaningful critique of OO. Certainly, Java and its offensive type system isn't.

Good luck with that Levenshtein Distance without laziness!!</description>
		<content:encoded><![CDATA[<p>Hi Anonymous Coward,<br />
I know what Dynamic Programming means. I&#8217;d just *love* to see your Levenshtein Distance written in Java <img src='http://blog.tmorris.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Here&#8217;s mine in Scala:<br />
<a href="http://tinyurl.com/ywuk86" onclick="javascript:pageTracker._trackPageview('/outbound/comment/tinyurl.com');" rel="nofollow">http://tinyurl.com/ywuk86</a></p>
<p>You will note that its essence is 5 lines of code. Again, I await your Java solution <img src='http://blog.tmorris.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
You think this is nitpicking? First, it has *nothing* at all to do with OOA/OOD and neither does Java for that matter. I only just had a whinge recently about passing under-qualified comment and the topic was &#8220;OO&#8221; (how about that?), so I best refrain for now for my own sanity. Interestingly, Wadler&#8217;s type-classes came up in that discussion; have you heard of them before? I find that they are a good place to start a discussion and meaningful critique of OO. Certainly, Java and its offensive type system isn&#8217;t.</p>
<p>Good luck with that Levenshtein Distance without laziness!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous Coward</title>
		<link>http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1691</link>
		<dc:creator>Anonymous Coward</dc:creator>
		<pubDate>Sun, 21 Oct 2007 04:01:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1691</guid>
		<description>I'm not sure "Dynamic Programming" means what you think it means.  I've implemented a great many DP algorithms.  Can you tell me exactly what problem Java poses to implement the DP 0-1 Knapsack.  The "0-1 Knapsack" is one of the ultimate DP algo.  Another famous DP algo is, say, the "Levenhstein edit distance"...  And I happen to &lt;i&gt;also&lt;/i&gt; have implemented this one perfectly fine in Java.

I think you want to open Wikipedia at "dynamic programming".

"dynamic programming algorithm" != "an algorithm written in a dynamic programming language"

If you're really talking about dynamic programming algorithms, then I'd like you to cite at least of the famous DP algo that would be problematic to write in Java...

DP algorithms like 0-1 Knapsack and Levenhstein have been known as "dynamic programming" since decades.  So I think "dynamic programming algorithm" doesn't mean what you think it means.

Besides that your blog is interesting but it's all hair-splitting at the 3GL level.  Anyone at least half interested in OOA/OOD can only but laugh at all this nitpicking.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure &#8220;Dynamic Programming&#8221; means what you think it means.  I&#8217;ve implemented a great many DP algorithms.  Can you tell me exactly what problem Java poses to implement the DP 0-1 Knapsack.  The &#8220;0-1 Knapsack&#8221; is one of the ultimate DP algo.  Another famous DP algo is, say, the &#8220;Levenhstein edit distance&#8221;&#8230;  And I happen to <i>also</i> have implemented this one perfectly fine in Java.</p>
<p>I think you want to open Wikipedia at &#8220;dynamic programming&#8221;.</p>
<p>&#8220;dynamic programming algorithm&#8221; != &#8220;an algorithm written in a dynamic programming language&#8221;</p>
<p>If you&#8217;re really talking about dynamic programming algorithms, then I&#8217;d like you to cite at least of the famous DP algo that would be problematic to write in Java&#8230;</p>
<p>DP algorithms like 0-1 Knapsack and Levenhstein have been known as &#8220;dynamic programming&#8221; since decades.  So I think &#8220;dynamic programming algorithm&#8221; doesn&#8217;t mean what you think it means.</p>
<p>Besides that your blog is interesting but it&#8217;s all hair-splitting at the 3GL level.  Anyone at least half interested in OOA/OOD can only but laugh at all this nitpicking.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad Clow</title>
		<link>http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1690</link>
		<dc:creator>Brad Clow</dc:creator>
		<pubDate>Thu, 20 Sep 2007 03:44:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1690</guid>
		<description>It can be done by introducing your own Boolean type:

&lt;pre&gt;
public final class Test {
    private static final MyBool TRUE;
    private static final MyBool FALSE;
    private static final MyBool BOTTOM;

    static {
        TRUE = new MyBool() {
            public boolean myBool() {
                return true;
            }
        };

        FALSE = new MyBool() {
            public boolean myBool() {
                return false;
            }
        };

        BOTTOM = new MyBool() {
            public boolean myBool() {
                throw new Error();
            }
        };
    }

    public static void main(String[] args) {
        System.out.println(and(TRUE, TRUE));
        System.out.println(and(FALSE, TRUE));
        System.out.println(and(FALSE, BOTTOM));
    }

    static boolean and(MyBool b, MyBool c) {
        if (b.myBool()) {
            return c.myBool() ? true : false;
        } else {
            return false;
        }
    }

    private interface MyBool {
        boolean myBool();
    }
}
&lt;/pre&gt;

As Tony pointed out to me, you can rename MyBool to Thunk and add a type parameter (which in this case would be Boolean).</description>
		<content:encoded><![CDATA[<p>It can be done by introducing your own Boolean type:</p>
<pre>
public final class Test {
    private static final MyBool TRUE;
    private static final MyBool FALSE;
    private static final MyBool BOTTOM;

    static {
        TRUE = new MyBool() {
            public boolean myBool() {
                return true;
            }
        };

        FALSE = new MyBool() {
            public boolean myBool() {
                return false;
            }
        };

        BOTTOM = new MyBool() {
            public boolean myBool() {
                throw new Error();
            }
        };
    }

    public static void main(String[] args) {
        System.out.println(and(TRUE, TRUE));
        System.out.println(and(FALSE, TRUE));
        System.out.println(and(FALSE, BOTTOM));
    }

    static boolean and(MyBool b, MyBool c) {
        if (b.myBool()) {
            return c.myBool() ? true : false;
        } else {
            return false;
        }
    }

    private interface MyBool {
        boolean myBool();
    }
}
</pre>
<p>As Tony pointed out to me, you can rename MyBool to Thunk and add a type parameter (which in this case would be Boolean).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ricky Clarkson</title>
		<link>http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1689</link>
		<dc:creator>Ricky Clarkson</dc:creator>
		<pubDate>Fri, 07 Sep 2007 12:47:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1689</guid>
		<description>Another way of thinking about it is that lazy languages make each expression (and each part of each expression) like a lambda expression in a strict language.  More accurately a memoised lambda expression, like Common Lisp's force and delay.

You could write your own &#38;#38;&#38;#38; in Java, but it would be called with lambdas rather than the same way &#38;#38;&#38;#38; is.  Here's a sample call:

boolean b=myAnd(new Lazyb()
{
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;public boolean invoke()
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;{
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;return false;
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;}
},new Lazyb()
{
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;public boolean invoke()
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;{
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;throw new Error();
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;}
});

or, in the hypothetical Java 7:

boolean b=myAnd({=&#38;gt;false},{=&#38;gt;throw new Error()});</description>
		<content:encoded><![CDATA[<p>Another way of thinking about it is that lazy languages make each expression (and each part of each expression) like a lambda expression in a strict language.  More accurately a memoised lambda expression, like Common Lisp&#8217;s force and delay.</p>
<p>You could write your own &#38;#38;&#38;#38; in Java, but it would be called with lambdas rather than the same way &#38;#38;&#38;#38; is.  Here&#8217;s a sample call:</p>
<p>boolean b=myAnd(new Lazyb()<br />
{<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;public boolean invoke()<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;{<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;return false;<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;}<br />
},new Lazyb()<br />
{<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;public boolean invoke()<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;{<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;throw new Error();<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;}<br />
});</p>
<p>or, in the hypothetical Java 7:</p>
<p>boolean b=myAnd({=&#38;gt;false},{=&#38;gt;throw new Error()});</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FeepingCreature</title>
		<link>http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1688</link>
		<dc:creator>FeepingCreature</dc:creator>
		<pubDate>Tue, 04 Sep 2007 22:22:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1688</guid>
		<description>D supports lazy evaluation of function parameters.
Just sayin' :)

The Java example expressed in D with lazy eval would be

__bool and(lazy bool b, lazy bool c) { return b &#38;#38;&#38;#38; c; }

Or a slightly more powerful version

__// takes an arbitrary number of lazy arguments
__bool and(bool delegate()[] dgs...) {
____assert(dgs.length);
____foreach (dg; dgs) if (!dg()) return false;
____return true;
__}
(The underscores are just indentation)

We can demonstrate that it works by means of the following example:

__import std.stdio;
__bool bottom() {
____throw new Exception("You hit rock bottom");
__}
__void main() { writefln(and(false, bottom)); }

which, correctly, outputs "false".</description>
		<content:encoded><![CDATA[<p>D supports lazy evaluation of function parameters.<br />
Just sayin&#8217; <img src='http://blog.tmorris.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
The Java example expressed in D with lazy eval would be</p>
<p>__bool and(lazy bool b, lazy bool c) { return b &#38;#38;&#38;#38; c; }</p>
<p>Or a slightly more powerful version</p>
<p>__// takes an arbitrary number of lazy arguments<br />
__bool and(bool delegate()[] dgs&#8230;) {<br />
____assert(dgs.length);<br />
____foreach (dg; dgs) if (!dg()) return false;<br />
____return true;<br />
__}<br />
(The underscores are just indentation)</p>
<p>We can demonstrate that it works by means of the following example:</p>
<p>__import std.stdio;<br />
__bool bottom() {<br />
____throw new Exception(&#8221;You hit rock bottom&#8221;);<br />
__}<br />
__void main() { writefln(and(false, bottom)); }</p>
<p>which, correctly, outputs &#8220;false&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John "Z-Bo" Zabroski</title>
		<link>http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1687</link>
		<dc:creator>John "Z-Bo" Zabroski</dc:creator>
		<pubDate>Tue, 04 Sep 2007 21:41:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1687</guid>
		<description>I agree with Lionel Barret about the + equivalence.  That was the only weak point of an otherwise excellent post.

I'd like to see you expand this further by mentioning imperative programming and how this can be used to describe more precise or perhaps more intricate imperative knowledge.  Doing so would tie up the last discussion we had nicely and also be a good way to introduce really powerful control structures like continuations - think about it.</description>
		<content:encoded><![CDATA[<p>I agree with Lionel Barret about the + equivalence.  That was the only weak point of an otherwise excellent post.</p>
<p>I&#8217;d like to see you expand this further by mentioning imperative programming and how this can be used to describe more precise or perhaps more intricate imperative knowledge.  Doing so would tie up the last discussion we had nicely and also be a good way to introduce really powerful control structures like continuations - think about it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lionel Barret</title>
		<link>http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1686</link>
		<dc:creator>Lionel Barret</dc:creator>
		<pubDate>Tue, 04 Sep 2007 19:18:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1686</guid>
		<description>Good point, but you could use a more complex example like Simon Peyton-Jones did in his video. I think it was a best move algo for a chess program : the possible position tree is too big to be completely evaluated before applying the scoring function for each position, so the tree is a lazy iterator.
Hey! by the way, (python) iterators are another good example !
Anyway, excellent introduction to a important topic.

( note you could have explained the + equivalence with a nice recursion.)</description>
		<content:encoded><![CDATA[<p>Good point, but you could use a more complex example like Simon Peyton-Jones did in his video. I think it was a best move algo for a chess program : the possible position tree is too big to be completely evaluated before applying the scoring function for each position, so the tree is a lazy iterator.<br />
Hey! by the way, (python) iterators are another good example !<br />
Anyway, excellent introduction to a important topic.</p>
<p>( note you could have explained the + equivalence with a nice recursion.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sohail</title>
		<link>http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1685</link>
		<dc:creator>Sohail</dc:creator>
		<pubDate>Tue, 04 Sep 2007 15:33:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1685</guid>
		<description>Awesome. That is just plain awesome.</description>
		<content:encoded><![CDATA[<p>Awesome. That is just plain awesome.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josef Svenningsson</title>
		<link>http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1684</link>
		<dc:creator>Josef Svenningsson</dc:creator>
		<pubDate>Tue, 04 Sep 2007 10:40:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/a-fling-with-lazy-evaluation/#comment-1684</guid>
		<description>While and for loops are also lazy constructs.

Apart from that, thanks for bringing up an important point.</description>
		<content:encoded><![CDATA[<p>While and for loops are also lazy constructs.</p>
<p>Apart from that, thanks for bringing up an important point.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
