<?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: JavaScript tips for rookies and gurus</title>
	<atom:link href="http://ajaxian.com/archives/javascript-tips-for-rookies-and-gurus/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/javascript-tips-for-rookies-and-gurus</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 17 May 2012 07:43:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Tim Cooijmans</title>
		<link>http://ajaxian.com/archives/javascript-tips-for-rookies-and-gurus/comment-page-1#comment-254772</link>
		<dc:creator>Tim Cooijmans</dc:creator>
		<pubDate>Fri, 31 Aug 2007 11:52:57 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2716#comment-254772</guid>
		<description>(Obviously, &quot;this.callOverload = f&quot; should have been &quot;this.callOverload = this.f&quot;.)</description>
		<content:encoded><![CDATA[<p>(Obviously, &#8220;this.callOverload = f&#8221; should have been &#8220;this.callOverload = this.f&#8221;.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Cooijmans</title>
		<link>http://ajaxian.com/archives/javascript-tips-for-rookies-and-gurus/comment-page-1#comment-254770</link>
		<dc:creator>Tim Cooijmans</dc:creator>
		<pubDate>Fri, 31 Aug 2007 11:49:46 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2716#comment-254770</guid>
		<description>So if I understand correctly, the &quot;callable instance&quot; crud is merely to facilitate shallow syntactic sugar, e.g.:

&lt;code&gt;// regular object constructor
var SomeType = function () {
  this.f = function () {
    return 123;
  };
  this.callOverload = f;
}
// special constructor that makes the object &quot;callable&quot;
var SomeCallableType = callableType(SomeType);

var x = new SomeType();
var y = SomeCallableType();

alert(x.f() === y());&lt;/code&gt;

So the result is that you can pick one &quot;default method&quot; to call when the object is called as if it were a function.  As you can see, in the example above I chose to pick f as the &quot;default method&quot;, and the &quot;callable instance&quot; crud saved from having to type &quot;.f&quot;.

I agree that function juggling can be fun, but I honestly don&#039;t think this is worth the effort.</description>
		<content:encoded><![CDATA[<p>So if I understand correctly, the &#8220;callable instance&#8221; crud is merely to facilitate shallow syntactic sugar, e.g.:</p>
<p><code>// regular object constructor<br />
var SomeType = function () {<br />
  this.f = function () {<br />
    return 123;<br />
  };<br />
  this.callOverload = f;<br />
}<br />
// special constructor that makes the object "callable"<br />
var SomeCallableType = callableType(SomeType);</p>
<p>var x = new SomeType();<br />
var y = SomeCallableType();</p>
<p>alert(x.f() === y());</code></p>
<p>So the result is that you can pick one &#8220;default method&#8221; to call when the object is called as if it were a function.  As you can see, in the example above I chose to pick f as the &#8220;default method&#8221;, and the &#8220;callable instance&#8221; crud saved from having to type &#8220;.f&#8221;.</p>
<p>I agree that function juggling can be fun, but I honestly don&#8217;t think this is worth the effort.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pyrolupus</title>
		<link>http://ajaxian.com/archives/javascript-tips-for-rookies-and-gurus/comment-page-1#comment-254726</link>
		<dc:creator>Pyrolupus</dc:creator>
		<pubDate>Thu, 30 Aug 2007 16:27:03 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2716#comment-254726</guid>
		<description>Small clarification:  JavaScript functions are not just *like* objects, they *are* objects.  typeof (function () {}).prototype === &#039;object&#039;.  You can use functions in JavaScript just like any other value (strings, integers, etc.).  It&#039;s an extremely powerful feature of the language.

Pyro</description>
		<content:encoded><![CDATA[<p>Small clarification:  JavaScript functions are not just *like* objects, they *are* objects.  typeof (function () {}).prototype === &#8216;object&#8217;.  You can use functions in JavaScript just like any other value (strings, integers, etc.).  It&#8217;s an extremely powerful feature of the language.</p>
<p>Pyro</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris Kowal</title>
		<link>http://ajaxian.com/archives/javascript-tips-for-rookies-and-gurus/comment-page-1#comment-254694</link>
		<dc:creator>Kris Kowal</dc:creator>
		<pubDate>Wed, 29 Aug 2007 23:43:41 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2716#comment-254694</guid>
		<description>The idea is that user defined types could add a this.callOverload function to their instances from within their constructor.  Function objects can be used as &quot;dictionary&quot; objects just like normal Objects.

&lt;code&gt;
this.MyType = callableType(function () {
    /* herein, &quot;this&quot; is your callableInstance */
    this.callOverload = function (...) {
       return ...;
    };
    ...
});
var callableInstance = MyType(); /* instantiates a callable instance */
callableInstance(); /* would implicitly call your user defined callOverload */
&lt;/code&gt;

I&#039;ll have to blog a more thorough explanation.</description>
		<content:encoded><![CDATA[<p>The idea is that user defined types could add a this.callOverload function to their instances from within their constructor.  Function objects can be used as &#8220;dictionary&#8221; objects just like normal Objects.</p>
<p><code><br />
this.MyType = callableType(function () {<br />
    /* herein, "this" is your callableInstance */<br />
    this.callOverload = function (...) {<br />
       return ...;<br />
    };<br />
    ...<br />
});<br />
var callableInstance = MyType(); /* instantiates a callable instance */<br />
callableInstance(); /* would implicitly call your user defined callOverload */<br />
</code></p>
<p>I&#8217;ll have to blog a more thorough explanation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles</title>
		<link>http://ajaxian.com/archives/javascript-tips-for-rookies-and-gurus/comment-page-1#comment-254690</link>
		<dc:creator>Charles</dc:creator>
		<pubDate>Wed, 29 Aug 2007 22:10:13 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2716#comment-254690</guid>
		<description>I think the secret is in the callOverload function, which has not been explained/defined.  I guess it works because functions have properties, similar to Objects?? I would love to see it explained in more detail.</description>
		<content:encoded><![CDATA[<p>I think the secret is in the callOverload function, which has not been explained/defined.  I guess it works because functions have properties, similar to Objects?? I would love to see it explained in more detail.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joshua Emmons</title>
		<link>http://ajaxian.com/archives/javascript-tips-for-rookies-and-gurus/comment-page-1#comment-254665</link>
		<dc:creator>Joshua Emmons</dc:creator>
		<pubDate>Wed, 29 Aug 2007 15:10:20 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2716#comment-254665</guid>
		<description>I&#039;ll just come out and say it. I read TFA and I still have no idea what this &quot;polymorphic callable objects&quot; code is actually doing. Can anyone else unravel the mystery for me? Is it good enough to make its indecipherable code worth while?</description>
		<content:encoded><![CDATA[<p>I&#8217;ll just come out and say it. I read TFA and I still have no idea what this &#8220;polymorphic callable objects&#8221; code is actually doing. Can anyone else unravel the mystery for me? Is it good enough to make its indecipherable code worth while?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

