<?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: Visitor pattern with closures</title>
	<atom:link href="http://tech.puredanger.com/index.php/2008/03/13/visitor-pattern-with-closures/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.puredanger.com/2008/03/13/visitor-pattern-with-closures/</link>
	<description>Alex Miller&#039;s technical blog</description>
	<lastBuildDate>Mon, 06 Feb 2012 19:39:50 -0800</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
	<item>
		<title>By: Alex Miller - Dynamic visitor builder with closures</title>
		<link>http://tech.puredanger.com/2008/03/13/visitor-pattern-with-closures/comment-page-1/#comment-32863</link>
		<dc:creator>Alex Miller - Dynamic visitor builder with closures</dc:creator>
		<pubDate>Sun, 16 Mar 2008 08:05:27 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2008/03/13/visitor-pattern-with-closures/#comment-32863</guid>
		<description>[...] &#171; Visitor pattern with closures &#124; Home &#124; [...]</description>
		<content:encoded><![CDATA[<p>[...] &laquo; Visitor pattern with closures | Home | [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Howard Lovatt</title>
		<link>http://tech.puredanger.com/2008/03/13/visitor-pattern-with-closures/comment-page-1/#comment-32617</link>
		<dc:creator>Howard Lovatt</dc:creator>
		<pubDate>Fri, 14 Mar 2008 21:16:48 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2008/03/13/visitor-pattern-with-closures/#comment-32617</guid>
		<description>In my own pet project, Pattern Enforcing Compiler (PEC):

&lt;blockquote&gt; &lt;a href=&quot;http://pec.dev.java.net/nonav/compile/index.html&quot; rel=&quot;nofollow&quot;&gt; http://pec.dev.java.net/nonav/compile/index.html &lt;/a&gt; &lt;/blockquote&gt;

You can use multiple dispatch instead of visitor:

&lt;blockquote&gt; &lt;a href=&quot;http://pec.dev.java.net/nonav/compile/javadoc/pec/compile/multipledispatch/package-summary.html#WalkingAnExpressionTree&quot; rel=&quot;nofollow&quot;&gt; http://pec.dev.java.net/nonav/compile/javadoc/pec/compile/multipledispatch/package-summary.html#WalkingAnExpressionTree &lt;/a&gt; &lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<p>In my own pet project, Pattern Enforcing Compiler (PEC):</p>
<blockquote><p> <a href="http://pec.dev.java.net/nonav/compile/index.html" rel="nofollow"> </a><a href="http://pec.dev.java.net/nonav/compile/index.html" rel="nofollow">http://pec.dev.java.net/nonav/compile/index.html</a>  </p></blockquote>
<p>You can use multiple dispatch instead of visitor:</p>
<blockquote><p> <a href="http://pec.dev.java.net/nonav/compile/javadoc/pec/compile/multipledispatch/package-summary.html#WalkingAnExpressionTree" rel="nofollow"> </a><a href="http://pec.dev.java.net/nonav/compile/javadoc/pec/compile/multipledispatch/package-summary.html#WalkingAnExpressionTree" rel="nofollow">http://pec.dev.java.net/nonav/compile/javadoc/pec/compile/multipledispatch/package-summary.html#WalkingAnExpressionTree</a>  </p></blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Mahieu</title>
		<link>http://tech.puredanger.com/2008/03/13/visitor-pattern-with-closures/comment-page-1/#comment-32552</link>
		<dc:creator>Mark Mahieu</dc:creator>
		<pubDate>Fri, 14 Mar 2008 14:13:36 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2008/03/13/visitor-pattern-with-closures/#comment-32552</guid>
		<description>I&#039;ll be curious to see what you come up with as a &#039;Visitor Builder&#039; - I was planning to write a short blog entry on that subject myself.  The ability to modify local variables and (in BGGA) use non-local returns would make some of my existing uses of the Visitor pattern much simpler...</description>
		<content:encoded><![CDATA[<p>I&#8217;ll be curious to see what you come up with as a &#8216;Visitor Builder&#8217; &#8211; I was planning to write a short blog entry on that subject myself.  The ability to modify local variables and (in BGGA) use non-local returns would make some of my existing uses of the Visitor pattern much simpler&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://tech.puredanger.com/2008/03/13/visitor-pattern-with-closures/comment-page-1/#comment-32535</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 14 Mar 2008 13:11:45 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2008/03/13/visitor-pattern-with-closures/#comment-32535</guid>
		<description>@Neal - gotcha, I&#039;ll give that a shot and you can tell me how I did.  :)

@Peter - yeah, I know.  If you take a look at my older visitor article (linked above), you&#039;ll see a full treatment of the navigation issue.</description>
		<content:encoded><![CDATA[<p>@Neal &#8211; gotcha, I&#8217;ll give that a shot and you can tell me how I did.  :)</p>
<p>@Peter &#8211; yeah, I know.  If you take a look at my older visitor article (linked above), you&#8217;ll see a full treatment of the navigation issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Veentjer</title>
		<link>http://tech.puredanger.com/2008/03/13/visitor-pattern-with-closures/comment-page-1/#comment-32534</link>
		<dc:creator>Peter Veentjer</dc:creator>
		<pubDate>Fri, 14 Mar 2008 13:01:11 +0000</pubDate>
		<guid isPermaLink="false">http://tech.puredanger.com/2008/03/13/visitor-pattern-with-closures/#comment-32534</guid>
		<description>@Alex.
One of the things I do when writing visitors is to make the accept method really stupid:
all implementation just have visitor.visit(this). The traversal should be task of the visitor. If I need reusable traversals, I create visitor guides:

class DepthFirstNodeVisitorGuide implements NodeVisitor{
	private final NodeVisitor guest;

	public DepthFirstNodeVisitorGuide(NodeVisitor guest){
		this.guest = guest;
	}

	public void visit(ConcreteNode node){
		node.accept(guest);
	}

	public void visit(ConcreteNode node){
		for(Node child: node.getChildren()){
			node.accept(this);
		}

		node.accept(guest);
	}
}

If you want to apply it, you can say something like this:

node.accept(new DepthFirstNodeVisitorGuide(new PrintNodeVisitor());

@back on subject.
The last example you gave (with the &#039;if(v instanceof ConcreteNode)&#039;) typically is something you would not see with a visitor. The question is: it is possible to lift on a different dynamic dispatching mechanism other than the polymorphic dispatch, or to use that polymorphic dispatch for closures.

It is a shame that Java has so many features but not something &#039;simple&#039; as multi-dispatch.</description>
		<content:encoded><![CDATA[<p>@Alex.<br />
One of the things I do when writing visitors is to make the accept method really stupid:<br />
all implementation just have visitor.visit(this). The traversal should be task of the visitor. If I need reusable traversals, I create visitor guides:</p>
<p>class DepthFirstNodeVisitorGuide implements NodeVisitor{<br />
	private final NodeVisitor guest;</p>
<p>	public DepthFirstNodeVisitorGuide(NodeVisitor guest){<br />
		this.guest = guest;<br />
	}</p>
<p>	public void visit(ConcreteNode node){<br />
		node.accept(guest);<br />
	}</p>
<p>	public void visit(ConcreteNode node){<br />
		for(Node child: node.getChildren()){<br />
			node.accept(this);<br />
		}</p>
<p>		node.accept(guest);<br />
	}<br />
}</p>
<p>If you want to apply it, you can say something like this:</p>
<p>node.accept(new DepthFirstNodeVisitorGuide(new PrintNodeVisitor());</p>
<p>@back on subject.<br />
The last example you gave (with the &#8216;if(v instanceof ConcreteNode)&#8217;) typically is something you would not see with a visitor. The question is: it is possible to lift on a different dynamic dispatching mechanism other than the polymorphic dispatch, or to use that polymorphic dispatch for closures.</p>
<p>It is a shame that Java has so many features but not something &#8216;simple&#8217; as multi-dispatch.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

