<?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: Pimp my Foreach Loop</title>
	<atom:link href="http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/</link>
	<description>Random notes on software, programming and languages.</description>
	<pubDate>Thu, 24 May 2012 10:28:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: akuhn</title>
		<link>http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/comment-page-1/#comment-2319</link>
		<dc:creator>akuhn</dc:creator>
		<pubDate>Fri, 27 Feb 2009 02:35:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.iam.unibe.ch/~akuhn/blog/?p=42#comment-2319</guid>
		<description>@Eugene &#8211; I agree, idiomatic java does a good job for simple queries. It is when queries get complex that the DSL starts to pay off. That is, either for queries such as GroupedBy and PiecesCut with a complex internal logic, or for query whose loop body is more than a few lines long. 

A main strength of the DSL is that it is intention revealing. "Say what you do, not how you do it." Scanning code for uses of Select is much faster then deciphering an idiomatic construct. Even worse, any slight variation in the combination of for's and if's might turn your select idiom into a reject, or select or detect instead. Thus, I personally prefer the DSL for trivial cases even.

And now, installing &lt;a href="http://lambda4jdt.googlecode.com/" rel="nofollow"&gt;lambda4jdt&lt;/a&gt; ... looks wow!</description>
		<content:encoded><![CDATA[<p>@Eugene &ndash; I agree, idiomatic java does a good job for simple queries. It is when queries get complex that the DSL starts to pay off. That is, either for queries such as GroupedBy and PiecesCut with a complex internal logic, or for query whose loop body is more than a few lines long. </p>
<p>A main strength of the DSL is that it is intention revealing. &#8220;Say what you do, not how you do it.&#8221; Scanning code for uses of Select is much faster then deciphering an idiomatic construct. Even worse, any slight variation in the combination of for&#8217;s and if&#8217;s might turn your select idiom into a reject, or select or detect instead. Thus, I personally prefer the DSL for trivial cases even.</p>
<p>And now, installing <a href="http://lambda4jdt.googlecode.com/" rel="nofollow">lambda4jdt</a> &#8230; looks wow!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eugene Lucash</title>
		<link>http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/comment-page-1/#comment-2307</link>
		<dc:creator>Eugene Lucash</dc:creator>
		<pubDate>Fri, 20 Feb 2009 18:16:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.iam.unibe.ch/~akuhn/blog/?p=42#comment-2307</guid>
		<description>I definitely support such kind of experiments!
But just compare

&lt;pre&gt;
Select selection = Select.from( words );
for (Select each: selection) {
    each.yield = each.element.charAt(0).isUppercase();
}
Collection names = selection.result();
&lt;/pre&gt;

Vs

&lt;pre&gt;
Collection names = new ArrayList();
for (String word : words) {
    if (Character.isUpperCase(word.charAt(0)))
        names.add(word);
}
&lt;/pre&gt;

Idiomatic java looks not that bad in comparison</description>
		<content:encoded><![CDATA[<p>I definitely support such kind of experiments!<br />
But just compare</p>
<pre>
Select selection = Select.from( words );
for (Select each: selection) {
    each.yield = each.element.charAt(0).isUppercase();
}
Collection names = selection.result();
</pre>
<p>Vs</p>
<pre>
Collection names = new ArrayList();
for (String word : words) {
    if (Character.isUpperCase(word.charAt(0)))
        names.add(word);
}
</pre>
<p>Idiomatic java looks not that bad in comparison</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: akuhn</title>
		<link>http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/comment-page-1/#comment-2296</link>
		<dc:creator>akuhn</dc:creator>
		<pubDate>Wed, 11 Feb 2009 21:20:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.iam.unibe.ch/~akuhn/blog/?p=42#comment-2296</guid>
		<description>@henk &#8211; now it can be done, checkout the latest revision.

&lt;pre&gt;
Select&#60;String&#62; selection = Select.from( words );
for (Select&#60;String&#62; each: selection) {
    each.yield = each.element.charAt(0).isUppercase();
}
Collection&#60;String&#62; names = selection.result();
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>@henk &ndash; now it can be done, checkout the latest revision.</p>
<pre>
Select&lt;String&gt; selection = Select.from( words );
for (Select&lt;String&gt; each: selection) {
    each.yield = each.element.charAt(0).isUppercase();
}
Collection&lt;String&gt; names = selection.result();
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Wash</title>
		<link>http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/comment-page-1/#comment-623</link>
		<dc:creator>Chris Wash</dc:creator>
		<pubDate>Wed, 17 Dec 2008 22:37:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.iam.unibe.ch/~akuhn/blog/?p=42#comment-623</guid>
		<description>Awesome idea - Impressive enough to warrant an RSS and Follow on Twitter.

I saw this attempted here as well, but you're limited to using the Hamcrest matchers: http://code.google.com/p/hamcrest-collections/wiki/GettingStarted</description>
		<content:encoded><![CDATA[<p>Awesome idea - Impressive enough to warrant an RSS and Follow on Twitter.</p>
<p>I saw this attempted here as well, but you&#8217;re limited to using the Hamcrest matchers: <a href="http://code.google.com/p/hamcrest-collections/wiki/GettingStarted" rel="nofollow">http://code.google.com/p/hamcrest-collections/wiki/GettingStarted</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mircea</title>
		<link>http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/comment-page-1/#comment-466</link>
		<dc:creator>Mircea</dc:creator>
		<pubDate>Tue, 09 Dec 2008 16:14:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.iam.unibe.ch/~akuhn/blog/?p=42#comment-466</guid>
		<description>hehe, nice idea :)</description>
		<content:encoded><![CDATA[<p>hehe, nice idea :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Itay Maman</title>
		<link>http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/comment-page-1/#comment-457</link>
		<dc:creator>Itay Maman</dc:creator>
		<pubDate>Sat, 06 Dec 2008 09:35:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.iam.unibe.ch/~akuhn/blog/?p=42#comment-457</guid>
		<description>Adrian, 

I think it is a clever approach to a thorny issue. Like it a lot. I bet you will get criticism from FP/Rub/Smalltalk people saying that Java sucks and that it should have supported this and that. This may be true, but still you managed to find a good practical solution to a real problem.</description>
		<content:encoded><![CDATA[<p>Adrian, </p>
<p>I think it is a clever approach to a thorny issue. Like it a lot. I bet you will get criticism from FP/Rub/Smalltalk people saying that Java sucks and that it should have supported this and that. This may be true, but still you managed to find a good practical solution to a real problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: henk</title>
		<link>http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/comment-page-1/#comment-455</link>
		<dc:creator>henk</dc:creator>
		<pubDate>Fri, 05 Dec 2008 21:53:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.iam.unibe.ch/~akuhn/blog/?p=42#comment-455</guid>
		<description>Pretty nice. The trick with $result(); and TLS is pretty clever, although purely syntax wise I like this the least. It feels a lot like these old C functions for getting an error code.

Although the trick is really clever, perhaps something like the fragment below would be more closer to what Java developers expect?

&lt;pre&gt;Select select = select(words);
for (Select each: select) {
  each.yield = each.value.charAt(0).isUppercase();
}
Collection names = select.result;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Pretty nice. The trick with $result(); and TLS is pretty clever, although purely syntax wise I like this the least. It feels a lot like these old C functions for getting an error code.</p>
<p>Although the trick is really clever, perhaps something like the fragment below would be more closer to what Java developers expect?</p>
<pre>Select select = select(words);
for (Select each: select) {
  each.yield = each.value.charAt(0).isUppercase();
}
Collection names = select.result;</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Casper Bang</title>
		<link>http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/comment-page-1/#comment-454</link>
		<dc:creator>Casper Bang</dc:creator>
		<pubDate>Fri, 05 Dec 2008 21:27:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.iam.unibe.ch/~akuhn/blog/?p=42#comment-454</guid>
		<description>@Adrian: Way to emulate yield in Java. ;) It's a little silly we need to mess with ThreadLocal for something that should be in the language but I guess that is the Java way of things.

@Bruno: Are you doing Wicket development? Looks like it. Indeed you can use Enum's, but not in place of an Class. Imagine you could, what would the difference be between MyRoles.USER.name() and MyRoles.ADMIN.name()? None, both resolve to the same Enum class. Why don't you just retrofit/overload it so that you can use Enum instead?</description>
		<content:encoded><![CDATA[<p>@Adrian: Way to emulate yield in Java. ;) It&#8217;s a little silly we need to mess with ThreadLocal for something that should be in the language but I guess that is the Java way of things.</p>
<p>@Bruno: Are you doing Wicket development? Looks like it. Indeed you can use Enum&#8217;s, but not in place of an Class. Imagine you could, what would the difference be between MyRoles.USER.name() and MyRoles.ADMIN.name()? None, both resolve to the same Enum class. Why don&#8217;t you just retrofit/overload it so that you can use Enum instead?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Caligula</title>
		<link>http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/comment-page-1/#comment-453</link>
		<dc:creator>Caligula</dc:creator>
		<pubDate>Fri, 05 Dec 2008 21:24:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.iam.unibe.ch/~akuhn/blog/?p=42#comment-453</guid>
		<description>@SJS:

A missed apostrophe, in a non-native language, is hardly worthy of a snarky proofreading comment.

Are you truly *astonished* at the characterization? Did you gasp out loud? At *best* I was mildly intrigued at the characterization, although I do feel they're at least *a* pretty basic technique.

I think, perhaps, you're too comfortable with hyperbole and nit-picking.</description>
		<content:encoded><![CDATA[<p>@SJS:</p>
<p>A missed apostrophe, in a non-native language, is hardly worthy of a snarky proofreading comment.</p>
<p>Are you truly *astonished* at the characterization? Did you gasp out loud? At *best* I was mildly intrigued at the characterization, although I do feel they&#8217;re at least *a* pretty basic technique.</p>
<p>I think, perhaps, you&#8217;re too comfortable with hyperbole and nit-picking.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anonymous</title>
		<link>http://www.iam.unibe.ch/~akuhn/blog/2008/pimp-my-foreach-loop/comment-page-1/#comment-452</link>
		<dc:creator>anonymous</dc:creator>
		<pubDate>Fri, 05 Dec 2008 20:58:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.iam.unibe.ch/~akuhn/blog/?p=42#comment-452</guid>
		<description>SJS,
For your information, "FYI" is not a word - you might want to hire a proofreader.

Missing apostrophes are an abbreviation (as are three letter acronyms). In the same way, "don't" is not a word either, but an abbreviation no doubt frowned upon by the slaves to language past who insisted instead on the correct usage of full "do not".</description>
		<content:encoded><![CDATA[<p>SJS,<br />
For your information, &#8220;FYI&#8221; is not a word - you might want to hire a proofreader.</p>
<p>Missing apostrophes are an abbreviation (as are three letter acronyms). In the same way, &#8220;don&#8217;t&#8221; is not a word either, but an abbreviation no doubt frowned upon by the slaves to language past who insisted instead on the correct usage of full &#8220;do not&#8221;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

