<?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: We don&#8217;t need anonymous inner classes? Bollocks to that.</title>
	<atom:link href="http://www.drmaciver.com/2009/03/we-dont-need-anonymous-inner-classes-bollocks-to-that/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.drmaciver.com/2009/03/we-dont-need-anonymous-inner-classes-bollocks-to-that/</link>
	<description></description>
	<lastBuildDate>Mon, 06 Feb 2012 22:56:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: david</title>
		<link>http://www.drmaciver.com/2009/03/we-dont-need-anonymous-inner-classes-bollocks-to-that/#comment-735</link>
		<dc:creator>david</dc:creator>
		<pubDate>Sun, 29 Mar 2009 00:27:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=437#comment-735</guid>
		<description>Also: I have gotten used to it, and I am happy to accept the misuse of people referring to anonymous functions as closures. It&#039;s a terminological abuse, but I can live with that.

But when you refer to other things which actually *are* closures in ways that suggests that they&#039;re not closures because they&#039;re not anonymous functions, you&#039;re simply wrong and I will correct you.</description>
		<content:encoded><![CDATA[<p>Also: I have gotten used to it, and I am happy to accept the misuse of people referring to anonymous functions as closures. It&#8217;s a terminological abuse, but I can live with that.</p>
<p>But when you refer to other things which actually *are* closures in ways that suggests that they&#8217;re not closures because they&#8217;re not anonymous functions, you&#8217;re simply wrong and I will correct you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://www.drmaciver.com/2009/03/we-dont-need-anonymous-inner-classes-bollocks-to-that/#comment-734</link>
		<dc:creator>david</dc:creator>
		<pubDate>Sun, 29 Mar 2009 00:24:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=437#comment-734</guid>
		<description>I&#039;m more than a little offended by the complete reality disconnect demonstrated by &quot;In fact, coming from Scala, it’s totally unsurprising to me that you don’t see value in a succinct syntax&quot;. The problem in fact seems to be that method declarations in groovy are needlessly verbose: The syntax you&#039;ve demonstrated is *not* substantially more succinct than Scala anonymous inner classes.</description>
		<content:encoded><![CDATA[<p>I&#8217;m more than a little offended by the complete reality disconnect demonstrated by &#8220;In fact, coming from Scala, it’s totally unsurprising to me that you don’t see value in a succinct syntax&#8221;. The problem in fact seems to be that method declarations in groovy are needlessly verbose: The syntax you&#8217;ve demonstrated is *not* substantially more succinct than Scala anonymous inner classes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Fischer</title>
		<link>http://www.drmaciver.com/2009/03/we-dont-need-anonymous-inner-classes-bollocks-to-that/#comment-733</link>
		<dc:creator>Robert Fischer</dc:creator>
		<pubDate>Sat, 28 Mar 2009 01:49:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=437#comment-733</guid>
		<description>To summarize your argument: you&#039;re not really with the Groovy syntax.  That&#039;s fine -- you don&#039;t write Groovy, so I wouldn&#039;t expect you to be.  In fact, coming from Scala, it&#039;s totally unsurprising to me that you don&#039;t see value in a succinct syntax.

There&#039;s a lot of places where Groovy does not use &quot;new Foo()&quot; to construct objects.  Inline lists, maps, anonymous function, and &quot;as&quot; coercions are far and away the most popular choices.  So it&#039;s kinda annoying to have to fall out of succinct code and back to something as chatty as:
new Foo() {
  void bar() { ... }
  void baz() { ... }
}

Plus, the @Newify AST transform pushes the distance between Groovy and Java&#039;s &quot;new Foo()&quot; syntax yet further.  The whole language is trending away from that stuff.

And yes, programmers conflate &quot;closure&quot; with &quot;anonymous function&quot;.  Get used to it -- the chance to stop that terminological issue has long past.  :P</description>
		<content:encoded><![CDATA[<p>To summarize your argument: you&#8217;re not really with the Groovy syntax.  That&#8217;s fine &#8212; you don&#8217;t write Groovy, so I wouldn&#8217;t expect you to be.  In fact, coming from Scala, it&#8217;s totally unsurprising to me that you don&#8217;t see value in a succinct syntax.</p>
<p>There&#8217;s a lot of places where Groovy does not use &#8220;new Foo()&#8221; to construct objects.  Inline lists, maps, anonymous function, and &#8220;as&#8221; coercions are far and away the most popular choices.  So it&#8217;s kinda annoying to have to fall out of succinct code and back to something as chatty as:<br />
new Foo() {<br />
  void bar() { &#8230; }<br />
  void baz() { &#8230; }<br />
}</p>
<p>Plus, the @Newify AST transform pushes the distance between Groovy and Java&#8217;s &#8220;new Foo()&#8221; syntax yet further.  The whole language is trending away from that stuff.</p>
<p>And yes, programmers conflate &#8220;closure&#8221; with &#8220;anonymous function&#8221;.  Get used to it &#8212; the chance to stop that terminological issue has long past.  :P</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://www.drmaciver.com/2009/03/we-dont-need-anonymous-inner-classes-bollocks-to-that/#comment-691</link>
		<dc:creator>david</dc:creator>
		<pubDate>Mon, 16 Mar 2009 00:16:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=437#comment-691</guid>
		<description>&quot;most anonymous inner classes are of the one-method-interface-impl variety or its sibling, the one-method-abstract-impl variety&quot; is only true in languages which don&#039;t support any sort of lambda construct. The whole point of the example I gave is that there are plenty of examples where anonymous inner classes continue to get used that *don&#039;t* fit this pattern.

As to the notion that one should use named classes, this seems... well, not so much an argument as an assertion. And it&#039;s one that doesn&#039;t make any sense to me at all.

Consider the options: I have a class that I want to instantiate exactly once. I can either a) Not name it, put it exactly where it is used and just let it capture the local scope or b) Assign it a meaningless name, figure out somewhere appropriate to put it and manually write code to transfer the state from the local scope over to it. (In the iterator case it doesn&#039;t matter that much because elements doesn&#039;t capture any arguments. But when you want to capture local variables or arguments it quickly gets out of hand).

So, I basically consider &quot;use a named class&quot; not a viable option. 

So it comes down to the question of coercing maps vs. instantiating classes. And I simply don&#039;t see the appeal of the map option. It seems unnecessarily magic. Further it doesn&#039;t transition smoothly to more general uses - you end up with a sharp discontinuity between the map of functions syntax and falling back to using a named class. The anonymous inner class plays well with the class and object system, so doesn&#039;t fall down when you hit areas which the magic doesn&#039;t support (I have no idea exactly what these are because I don&#039;t use Groovy. Does Groovy allow interfaces with implementations? Does it have an independent mixin mechanism? If not, can this trick work when returning a class?)

I also don&#039;t understand your point about syntax. I assume groovy writes constructors the Java way: new Foo( ). Thus it seems to make sense to construct other classes in exactly the same way. You could make a distinction for interfaces, but why bother? Doing things one way for classes and one for interfaces seems needlessly confusing. 

Finally, I want to take terminological issue with your &quot;Most anonymous inner classes are really closures at heart&quot;. I know what you really mean is &quot;functions&quot;, but actually *all* anonymous inner classes are closures, not at heart but in fact. They capture their defining scope in exactly the same way that a &quot;closure&quot; does, and are implemented the same way.</description>
		<content:encoded><![CDATA[<p>&#8220;most anonymous inner classes are of the one-method-interface-impl variety or its sibling, the one-method-abstract-impl variety&#8221; is only true in languages which don&#8217;t support any sort of lambda construct. The whole point of the example I gave is that there are plenty of examples where anonymous inner classes continue to get used that *don&#8217;t* fit this pattern.</p>
<p>As to the notion that one should use named classes, this seems&#8230; well, not so much an argument as an assertion. And it&#8217;s one that doesn&#8217;t make any sense to me at all.</p>
<p>Consider the options: I have a class that I want to instantiate exactly once. I can either a) Not name it, put it exactly where it is used and just let it capture the local scope or b) Assign it a meaningless name, figure out somewhere appropriate to put it and manually write code to transfer the state from the local scope over to it. (In the iterator case it doesn&#8217;t matter that much because elements doesn&#8217;t capture any arguments. But when you want to capture local variables or arguments it quickly gets out of hand).</p>
<p>So, I basically consider &#8220;use a named class&#8221; not a viable option. </p>
<p>So it comes down to the question of coercing maps vs. instantiating classes. And I simply don&#8217;t see the appeal of the map option. It seems unnecessarily magic. Further it doesn&#8217;t transition smoothly to more general uses &#8211; you end up with a sharp discontinuity between the map of functions syntax and falling back to using a named class. The anonymous inner class plays well with the class and object system, so doesn&#8217;t fall down when you hit areas which the magic doesn&#8217;t support (I have no idea exactly what these are because I don&#8217;t use Groovy. Does Groovy allow interfaces with implementations? Does it have an independent mixin mechanism? If not, can this trick work when returning a class?)</p>
<p>I also don&#8217;t understand your point about syntax. I assume groovy writes constructors the Java way: new Foo( ). Thus it seems to make sense to construct other classes in exactly the same way. You could make a distinction for interfaces, but why bother? Doing things one way for classes and one for interfaces seems needlessly confusing. </p>
<p>Finally, I want to take terminological issue with your &#8220;Most anonymous inner classes are really closures at heart&#8221;. I know what you really mean is &#8220;functions&#8221;, but actually *all* anonymous inner classes are closures, not at heart but in fact. They capture their defining scope in exactly the same way that a &#8220;closure&#8221; does, and are implemented the same way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Fischer</title>
		<link>http://www.drmaciver.com/2009/03/we-dont-need-anonymous-inner-classes-bollocks-to-that/#comment-690</link>
		<dc:creator>Robert Fischer</dc:creator>
		<pubDate>Sun, 15 Mar 2009 23:51:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=437#comment-690</guid>
		<description>Nice.  Your blog ate my formatting, which really shoots my &quot;looks nicer than&quot; arguments in the foot.  :P</description>
		<content:encoded><![CDATA[<p>Nice.  Your blog ate my formatting, which really shoots my &#8220;looks nicer than&#8221; arguments in the foot.  :P</p>
]]></content:encoded>
	</item>
</channel>
</rss>

