<?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 (Java) methods</title>
	<atom:link href="http://adams.id.au/blog/2008/04/pimp-my-java-methods/feed/" rel="self" type="application/rss+xml" />
	<link>http://adams.id.au/blog/2008/04/pimp-my-java-methods/</link>
	<description>Technology, mountain biking, politics &#38; music.</description>
	<pubDate>Thu, 11 Mar 2010 09:56:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Min Huang</title>
		<link>http://adams.id.au/blog/2008/04/pimp-my-java-methods/comment-page-1/#comment-138</link>
		<dc:creator>Min Huang</dc:creator>
		<pubDate>Wed, 11 Jun 2008 08:32:54 +0000</pubDate>
		<guid isPermaLink="false">http://adams.id.au/blog/?p=124#comment-138</guid>
		<description>You can add a "methods" method to Any to achieve pretty much the same thing in Scala.  You can format it however you like, but I like seeing each method on a new line as it helps me read the arguments:

http://minformix.org/blog/index.php?/archives/91-Scala-Querying-an-objects-fields-and-methods-with-reflection.html</description>
		<content:encoded><![CDATA[<p>You can add a &#8220;methods&#8221; method to Any to achieve pretty much the same thing in Scala.  You can format it however you like, but I like seeing each method on a new line as it helps me read the arguments:</p>
<p><a href="http://minformix.org/blog/index.php?/archives/91-Scala-Querying-an-objects-fields-and-methods-with-reflection.html" rel="nofollow" onclick="javascript:urchinTracker ('/outbound/comment/minformix.org');">http://minformix.org/blog/index.php?/archives/91-Scala-Querying-an-objects-fields-and-methods-with-reflection.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony Morris</title>
		<link>http://adams.id.au/blog/2008/04/pimp-my-java-methods/comment-page-1/#comment-137</link>
		<dc:creator>Tony Morris</dc:creator>
		<pubDate>Mon, 05 May 2008 06:58:13 +0000</pubDate>
		<guid isPermaLink="false">http://adams.id.au/blog/?p=124#comment-137</guid>
		<description>The Ruby version is less typing, because it is less elegant. That is, it's not the same thing; it's a weaker, less useful and less practical representation as per the universal type system.

You can't have something for nothing.</description>
		<content:encoded><![CDATA[<p>The Ruby version is less typing, because it is less elegant. That is, it&#8217;s not the same thing; it&#8217;s a weaker, less useful and less practical representation as per the universal type system.</p>
<p>You can&#8217;t have something for nothing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abdul Habra</title>
		<link>http://adams.id.au/blog/2008/04/pimp-my-java-methods/comment-page-1/#comment-133</link>
		<dc:creator>Abdul Habra</dc:creator>
		<pubDate>Wed, 23 Apr 2008 13:56:23 +0000</pubDate>
		<guid isPermaLink="false">http://adams.id.au/blog/?p=124#comment-133</guid>
		<description>Still, the Ruby version is less verbose to type, and imho is more elegant. This is not to say that we cannot have a library in Scala/Java that is just as elegant to use.</description>
		<content:encoded><![CDATA[<p>Still, the Ruby version is less verbose to type, and imho is more elegant. This is not to say that we cannot have a library in Scala/Java that is just as elegant to use.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Adams</title>
		<link>http://adams.id.au/blog/2008/04/pimp-my-java-methods/comment-page-1/#comment-132</link>
		<dc:creator>Tom Adams</dc:creator>
		<pubDate>Tue, 22 Apr 2008 22:20:56 +0000</pubDate>
		<guid isPermaLink="false">http://adams.id.au/blog/?p=124#comment-132</guid>
		<description>Not as such, however Scala has something called implicit defs (used in the post above) that achieve the same effect, but in a safe manner, i.e. you can more easily reason about the effects an implicit will have, vs. not knowing what does what in Ruby/Groovy.

So when you call a function on a type that doesn't have that particular method defined, the compiler looks to see if there are any implicits in scope that can convert from the type in question, to a type that has the method defined.

This is why &lt;code&gt;classOf[Integer].methods&lt;/code&gt; works, there is no &lt;code&gt;methods&lt;/code&gt; function on the &lt;code&gt;Class[T]&lt;/code&gt; type, however there is one on the &lt;code&gt;Classs[T]&lt;/code&gt; type, and an implicit exists to get between the two types.</description>
		<content:encoded><![CDATA[<p>Not as such, however Scala has something called implicit defs (used in the post above) that achieve the same effect, but in a safe manner, i.e. you can more easily reason about the effects an implicit will have, vs. not knowing what does what in Ruby/Groovy.</p>
<p>So when you call a function on a type that doesn&#8217;t have that particular method defined, the compiler looks to see if there are any implicits in scope that can convert from the type in question, to a type that has the method defined.</p>
<p>This is why <code>classOf[Integer].methods</code> works, there is no <code>methods</code> function on the <code>Class[T]</code> type, however there is one on the <code>Classs[T]</code> type, and an implicit exists to get between the two types.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: karthik</title>
		<link>http://adams.id.au/blog/2008/04/pimp-my-java-methods/comment-page-1/#comment-134</link>
		<dc:creator>karthik</dc:creator>
		<pubDate>Tue, 22 Apr 2008 16:49:15 +0000</pubDate>
		<guid isPermaLink="false">http://adams.id.au/blog/?p=124#comment-134</guid>
		<description>Does scala support dynamically adding methods to a class ? (static / instance) methods the way Groovy does.
I want to be able to add methods to a class without extending it - the way prototype library adds methods to built-in javascript implicit objects. Ofcourse groovy and ruby allows that too?</description>
		<content:encoded><![CDATA[<p>Does scala support dynamically adding methods to a class ? (static / instance) methods the way Groovy does.<br />
I want to be able to add methods to a class without extending it - the way prototype library adds methods to built-in javascript implicit objects. Ofcourse groovy and ruby allows that too?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Adams</title>
		<link>http://adams.id.au/blog/2008/04/pimp-my-java-methods/comment-page-1/#comment-136</link>
		<dc:creator>Tom Adams</dc:creator>
		<pubDate>Mon, 21 Apr 2008 23:02:02 +0000</pubDate>
		<guid isPermaLink="false">http://adams.id.au/blog/?p=124#comment-136</guid>
		<description>The ordering is not guaranteed by the reflection APIs, to quote from &lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getDeclaredMethods()" rel="nofollow"&gt;&lt;code&gt;Class.getDeclaredMethods&lt;/code&gt;&lt;/a&gt;:

&lt;blockquote&gt;
Returns an array of Method objects reflecting all the methods declared by the class or interface represented by this Class object. This includes public, protected, default (package) access, and private methods, but excludes inherited methods. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no methods, or if this Class object represents a primitive type, an array class, or void. The class initialization method &lt;clinit&gt; is not included in the returned array. If the class declares multiple public member methods with the same parameter types, they are all included in the returned array.&lt;/clinit&gt;&lt;/blockquote&gt;

But yeah, I agree that ordering would be nice if we could get it.

On a side note, I really don't want to be writing this stuff, it should be part of the standard APIs.</description>
		<content:encoded><![CDATA[<p>The ordering is not guaranteed by the reflection APIs, to quote from <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getDeclaredMethods()" rel="nofollow" onclick="javascript:urchinTracker ('/outbound/comment/java.sun.com');"><code>Class.getDeclaredMethods</code></a>:</p>
<blockquote><p>
Returns an array of Method objects reflecting all the methods declared by the class or interface represented by this Class object. This includes public, protected, default (package) access, and private methods, but excludes inherited methods. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no methods, or if this Class object represents a primitive type, an array class, or void. The class initialization method <clinit> is not included in the returned array. If the class declares multiple public member methods with the same parameter types, they are all included in the returned array.</clinit></p></blockquote>
<p>But yeah, I agree that ordering would be nice if we could get it.</p>
<p>On a side note, I really don&#8217;t want to be writing this stuff, it should be part of the standard APIs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://adams.id.au/blog/2008/04/pimp-my-java-methods/comment-page-1/#comment-135</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Mon, 21 Apr 2008 17:32:56 +0000</pubDate>
		<guid isPermaLink="false">http://adams.id.au/blog/?p=124#comment-135</guid>
		<description>The problem is that you've now lost the method ordering, which is often useful.  Instead of HashSet, you should probably use a List of some kind.</description>
		<content:encoded><![CDATA[<p>The problem is that you&#8217;ve now lost the method ordering, which is often useful.  Instead of HashSet, you should probably use a List of some kind.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
