<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Blocks &#8211; an alternative for Closures ?</title>
	<atom:link href="http://gleichmann.wordpress.com/2008/02/10/blocks-an-alternative-for-closures/feed/" rel="self" type="application/rss+xml" />
	<link>http://gleichmann.wordpress.com/2008/02/10/blocks-an-alternative-for-closures/</link>
	<description>a development driven blog</description>
	<lastBuildDate>Sat, 24 Oct 2009 00:16:00 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Real State Agent</title>
		<link>http://gleichmann.wordpress.com/2008/02/10/blocks-an-alternative-for-closures/#comment-146</link>
		<dc:creator>Real State Agent</dc:creator>
		<pubDate>Tue, 11 Mar 2008 13:54:55 +0000</pubDate>
		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=30#comment-146</guid>
		<description>I did the same as suggested here for implementing a presentation framework, so that you could pass Runnables as parameters to methods.

This Runnables would be executed when the paint, load, etc. events were triggered.

The result was that none of the shortcomings that you mention were real problems.

The only annoying problem was having to write the whole Runnable. It would be easier if you only had to write something like f.onPaint( #{ object.doSomething(); } ).

The other problems I find in Java and that C++ already had solved were:

1. Destructors. In C++ you declare the destructor and you forget about it. Not so in Java, you have to use finally everywhere. It is not pretty.

2. The lack of operators. Syntactic sugar, yes. But necessary sugar.</description>
		<content:encoded><![CDATA[<p>I did the same as suggested here for implementing a presentation framework, so that you could pass Runnables as parameters to methods.</p>
<p>This Runnables would be executed when the paint, load, etc. events were triggered.</p>
<p>The result was that none of the shortcomings that you mention were real problems.</p>
<p>The only annoying problem was having to write the whole Runnable. It would be easier if you only had to write something like f.onPaint( #{ object.doSomething(); } ).</p>
<p>The other problems I find in Java and that C++ already had solved were:</p>
<p>1. Destructors. In C++ you declare the destructor and you forget about it. Not so in Java, you have to use finally everywhere. It is not pretty.</p>
<p>2. The lack of operators. Syntactic sugar, yes. But necessary sugar.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blocks - an alternative for Closures ? &#171; Java Net</title>
		<link>http://gleichmann.wordpress.com/2008/02/10/blocks-an-alternative-for-closures/#comment-137</link>
		<dc:creator>Blocks - an alternative for Closures ? &#171; Java Net</dc:creator>
		<pubDate>Tue, 12 Feb 2008 20:42:16 +0000</pubDate>
		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=30#comment-137</guid>
		<description>[...] - an alternative for Closures ?  This entry was written by Mario Gleichmann. Bookmark the permalink. Follow any comments here with the RSS feed for this post.Content related [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8211; an alternative for Closures ?  This entry was written by Mario Gleichmann. Bookmark the permalink. Follow any comments here with the RSS feed for this post.Content related [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Gleichmann</title>
		<link>http://gleichmann.wordpress.com/2008/02/10/blocks-an-alternative-for-closures/#comment-136</link>
		<dc:creator>Mario Gleichmann</dc:creator>
		<pubDate>Mon, 11 Feb 2008 18:57:47 +0000</pubDate>
		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=30#comment-136</guid>
		<description>Nick,

thank you very much for your critical comments!

&gt;&gt; ... anonymous methods require variables to be made final as its probably the easiest problem to get around.

First of all, the post is mainly about an experiment about how &#039;concise&#039; and &#039;readable&#039; you can get with the given language features. It&#039;s a fact, that you only can refer to final variables, since they end up on the Heap - nothing more, nothing less (if it seems that i was mainly complaining about this fact, it&#039;s rather my fault not to make things clear enough). 

&gt;&gt; ... does nothing to reduce the clutter that defining an anonymous class requires (compare your definition with the BGGA equivalent, {int a, int b =&gt; a*b}

Yes, as said in the post - it&#039;s at least an experiment to become as concise as possible with the given features. It&#039;s of course much more bloated compared to BGGA, but in my opinion more concise (i&#039;m not saying by a huge amount) than implementing an Interface while repeating the whole signature of a method all over again.

Of course (again mentioned twice in the post), it&#039;s by far not as powerfull as Closures (i.e. the post doesn&#039;t mention issues with stateful classes and concurrency, exceptionally escaping from Closures, ... ), however could it serve for a good part of problems that are now tried to be clobbered by Closures.

&gt;&gt; And I’m not too happy with the practice of defining an entirely new package for every conceivable number of argument parameters (exactly how high are you planning to go?)

As explained in the post - for providing Block classes for a maximum number of say five arguments (seriously, did you use more than three or four arguments in practice?) - exactly five classes. Nothing more, since they are Generic, so you can use every combination of types with the given classes!

&gt;&gt; thats what arrays are for (if you don’t like the syntax of defining an array, use the Java 5 var args to do it)

I don&#039;t get your point about this part. If you want to forgo a type safe way of using arguments of potentially different types (since you can&#039;t declare an array of different types you have to use the most abstract type of Object), go on. But than the resulting block definition is again bloated by some casts. Nothing about that - personally, i prefer a type safe way with the advantage to directly calling the given methods on that type within the blocks definition.

Greetings

Mario</description>
		<content:encoded><![CDATA[<p>Nick,</p>
<p>thank you very much for your critical comments!</p>
<p>&gt;&gt; &#8230; anonymous methods require variables to be made final as its probably the easiest problem to get around.</p>
<p>First of all, the post is mainly about an experiment about how &#8216;concise&#8217; and &#8216;readable&#8217; you can get with the given language features. It&#8217;s a fact, that you only can refer to final variables, since they end up on the Heap &#8211; nothing more, nothing less (if it seems that i was mainly complaining about this fact, it&#8217;s rather my fault not to make things clear enough). </p>
<p>&gt;&gt; &#8230; does nothing to reduce the clutter that defining an anonymous class requires (compare your definition with the BGGA equivalent, {int a, int b =&gt; a*b}</p>
<p>Yes, as said in the post &#8211; it&#8217;s at least an experiment to become as concise as possible with the given features. It&#8217;s of course much more bloated compared to BGGA, but in my opinion more concise (i&#8217;m not saying by a huge amount) than implementing an Interface while repeating the whole signature of a method all over again.</p>
<p>Of course (again mentioned twice in the post), it&#8217;s by far not as powerfull as Closures (i.e. the post doesn&#8217;t mention issues with stateful classes and concurrency, exceptionally escaping from Closures, &#8230; ), however could it serve for a good part of problems that are now tried to be clobbered by Closures.</p>
<p>&gt;&gt; And I’m not too happy with the practice of defining an entirely new package for every conceivable number of argument parameters (exactly how high are you planning to go?)</p>
<p>As explained in the post &#8211; for providing Block classes for a maximum number of say five arguments (seriously, did you use more than three or four arguments in practice?) &#8211; exactly five classes. Nothing more, since they are Generic, so you can use every combination of types with the given classes!</p>
<p>&gt;&gt; thats what arrays are for (if you don’t like the syntax of defining an array, use the Java 5 var args to do it)</p>
<p>I don&#8217;t get your point about this part. If you want to forgo a type safe way of using arguments of potentially different types (since you can&#8217;t declare an array of different types you have to use the most abstract type of Object), go on. But than the resulting block definition is again bloated by some casts. Nothing about that &#8211; personally, i prefer a type safe way with the advantage to directly calling the given methods on that type within the blocks definition.</p>
<p>Greetings</p>
<p>Mario</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Gleichmann</title>
		<link>http://gleichmann.wordpress.com/2008/02/10/blocks-an-alternative-for-closures/#comment-135</link>
		<dc:creator>Mario Gleichmann</dc:creator>
		<pubDate>Mon, 11 Feb 2008 18:16:07 +0000</pubDate>
		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=30#comment-135</guid>
		<description>Andrew, 

thanks for your feedback. As pointet out in the post, the presented experiment is by far not comparable with the full power of Closures.
One thing, just indicated in the post, is the ability to access the lexical scope within the Closure was defined, even if that scope doesn&#039;t &#039;exist&#039; any longer when the Closure gets executed (as mentioned, only possible with final variables in Java).
Another essential function is the possibility to curry a given Closure (you may want to search for that idea, since it would take a little bit longer to explain). 
That said, the demonstrated thoughts are by far not comparable with full featured Lambda calculus nor with Closures inherently. 

Greetings

Mario</description>
		<content:encoded><![CDATA[<p>Andrew, </p>
<p>thanks for your feedback. As pointet out in the post, the presented experiment is by far not comparable with the full power of Closures.<br />
One thing, just indicated in the post, is the ability to access the lexical scope within the Closure was defined, even if that scope doesn&#8217;t &#8216;exist&#8217; any longer when the Closure gets executed (as mentioned, only possible with final variables in Java).<br />
Another essential function is the possibility to curry a given Closure (you may want to search for that idea, since it would take a little bit longer to explain).<br />
That said, the demonstrated thoughts are by far not comparable with full featured Lambda calculus nor with Closures inherently. </p>
<p>Greetings</p>
<p>Mario</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Brown</title>
		<link>http://gleichmann.wordpress.com/2008/02/10/blocks-an-alternative-for-closures/#comment-134</link>
		<dc:creator>Nick Brown</dc:creator>
		<pubDate>Mon, 11 Feb 2008 17:16:19 +0000</pubDate>
		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=30#comment-134</guid>
		<description>One more thing, your complaint that parameters have to be declared as final isn&#039;t really valid either, as in functional programming you typically want everything to be stateless.  Introducing variables that have a state is just asking for a host of problems for anything more complex than a counter (and even that would be prone to CMEs).</description>
		<content:encoded><![CDATA[<p>One more thing, your complaint that parameters have to be declared as final isn&#8217;t really valid either, as in functional programming you typically want everything to be stateless.  Introducing variables that have a state is just asking for a host of problems for anything more complex than a counter (and even that would be prone to CMEs).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Brown</title>
		<link>http://gleichmann.wordpress.com/2008/02/10/blocks-an-alternative-for-closures/#comment-133</link>
		<dc:creator>Nick Brown</dc:creator>
		<pubDate>Mon, 11 Feb 2008 15:25:59 +0000</pubDate>
		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=30#comment-133</guid>
		<description>Correct me f I am missing something, but this seems to solve only one of the problems of anonymous classes (and not a particularly big one, I haven&#039;t seen too many people using the complaint that anonymous methods require variables to be made final as its probably the easiest problem to get around).  It does nothing to reduce the clutter that defining an anonymous class requires (compare your definition with the BGGA equivalent, {int a, int b =&gt; a*b}) and does nothing to allow control structures such as resource management blocks.

Yes, we get that closures technically can be done with the current Java spec.  But it requires so much work to make it happen and is so ugly and unmaintainable that it is rarely used, which is going to be problematic as new structures such as the Java 7 fork join get added.  

And I&#039;m not too happy with the practice of defining an entirely new package for every conceivable number of argument parameters (exactly how high are you planning to go?), thats what arrays are for (if you don&#039;t like the syntax of defining an array, use the Java 5 var args to do it).  And the practice of naming a class with a lower case letter isn&#039;t much better.</description>
		<content:encoded><![CDATA[<p>Correct me f I am missing something, but this seems to solve only one of the problems of anonymous classes (and not a particularly big one, I haven&#8217;t seen too many people using the complaint that anonymous methods require variables to be made final as its probably the easiest problem to get around).  It does nothing to reduce the clutter that defining an anonymous class requires (compare your definition with the BGGA equivalent, {int a, int b =&gt; a*b}) and does nothing to allow control structures such as resource management blocks.</p>
<p>Yes, we get that closures technically can be done with the current Java spec.  But it requires so much work to make it happen and is so ugly and unmaintainable that it is rarely used, which is going to be problematic as new structures such as the Java 7 fork join get added.  </p>
<p>And I&#8217;m not too happy with the practice of defining an entirely new package for every conceivable number of argument parameters (exactly how high are you planning to go?), thats what arrays are for (if you don&#8217;t like the syntax of defining an array, use the Java 5 var args to do it).  And the practice of naming a class with a lower case letter isn&#8217;t much better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://gleichmann.wordpress.com/2008/02/10/blocks-an-alternative-for-closures/#comment-132</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Mon, 11 Feb 2008 09:45:54 +0000</pubDate>
		<guid isPermaLink="false">http://gleichmann.wordpress.com/?p=30#comment-132</guid>
		<description>So far I&#039;ve got only one question:

If we can do something like this in Java already, why do we need closures? Just to make it look better?</description>
		<content:encoded><![CDATA[<p>So far I&#8217;ve got only one question:</p>
<p>If we can do something like this in Java already, why do we need closures? Just to make it look better?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
