<?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: Named function expressions in incredible detail</title>
	<atom:link href="http://ajaxian.com/archives/named-function-expressions-in-incredible-detail/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/named-function-expressions-in-incredible-detail</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 09 Feb 2012 06:55:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: TNO</title>
		<link>http://ajaxian.com/archives/named-function-expressions-in-incredible-detail/comment-page-1#comment-274034</link>
		<dc:creator>TNO</dc:creator>
		<pubDate>Fri, 19 Jun 2009 14:29:55 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6966#comment-274034</guid>
		<description>@chiaroscuro:
http://wiki.ecmascript.org/doku.php?id=harmony:harmony
https://developer.mozilla.org/en/New_in_JavaScript_1.7#Block_scope_with_let

Also, named function expressions are necessary for recursion since arguments.callee is being removed.</description>
		<content:encoded><![CDATA[<p>@chiaroscuro:<br />
<a href="http://wiki.ecmascript.org/doku.php?id=harmony:harmony" rel="nofollow">http://wiki.ecmascript.org/doku.php?id=harmony:harmony</a><br />
<a href="https://developer.mozilla.org/en/New_in_JavaScript_1.7#Block_scope_with_let" rel="nofollow">https://developer.mozilla.org/en/New_in_JavaScript_1.7#Block_scope_with_let</a></p>
<p>Also, named function expressions are necessary for recursion since arguments.callee is being removed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zachleat</title>
		<link>http://ajaxian.com/archives/named-function-expressions-in-incredible-detail/comment-page-1#comment-274029</link>
		<dc:creator>zachleat</dc:creator>
		<pubDate>Fri, 19 Jun 2009 12:39:54 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6966#comment-274029</guid>
		<description>Thanks guys, glad I asked!</description>
		<content:encoded><![CDATA[<p>Thanks guys, glad I asked!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kangax</title>
		<link>http://ajaxian.com/archives/named-function-expressions-in-incredible-detail/comment-page-1#comment-274007</link>
		<dc:creator>kangax</dc:creator>
		<pubDate>Fri, 19 Jun 2009 04:13:11 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6966#comment-274007</guid>
		<description>@ywg
Thank you!

@zachleat
I think you&#039;re missing the difference between declaration and expression. What @jdalton said should pretty much answer your question.

@eyelidlessness
I don&#039;t see how two function declarations with same-named identifier is a syntax error in ES3. Could you point me to a particular section in the specs describing this?</description>
		<content:encoded><![CDATA[<p>@ywg<br />
Thank you!</p>
<p>@zachleat<br />
I think you&#8217;re missing the difference between declaration and expression. What @jdalton said should pretty much answer your question.</p>
<p>@eyelidlessness<br />
I don&#8217;t see how two function declarations with same-named identifier is a syntax error in ES3. Could you point me to a particular section in the specs describing this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chiaroscuro</title>
		<link>http://ajaxian.com/archives/named-function-expressions-in-incredible-detail/comment-page-1#comment-274006</link>
		<dc:creator>chiaroscuro</dc:creator>
		<pubDate>Fri, 19 Jun 2009 03:40:53 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6966#comment-274006</guid>
		<description>Why do JS language designers are so ignorant of the prior art?

JavaScript is ought to have a variable binding construct, &quot;let&quot; or something. Then you wouldn&#039;t need so much monkeying.

Actually, &quot;var I = function(x){return x}&quot; and &quot;function I(x){return x}&quot; have a subtle difference. The latter permits mutually recursive definitions, while the former is pretty limited in this respect.

Now, if we give people that &quot;let&quot; form (and also a &quot;let*&quot; in Scheme parlance), we don&#039;t need to &quot;mistify&quot; ourselves with nonsense like the &quot;named function expressions&quot;.</description>
		<content:encoded><![CDATA[<p>Why do JS language designers are so ignorant of the prior art?</p>
<p>JavaScript is ought to have a variable binding construct, &#8220;let&#8221; or something. Then you wouldn&#8217;t need so much monkeying.</p>
<p>Actually, &#8220;var I = function(x){return x}&#8221; and &#8220;function I(x){return x}&#8221; have a subtle difference. The latter permits mutually recursive definitions, while the former is pretty limited in this respect.</p>
<p>Now, if we give people that &#8220;let&#8221; form (and also a &#8220;let*&#8221; in Scheme parlance), we don&#8217;t need to &#8220;mistify&#8221; ourselves with nonsense like the &#8220;named function expressions&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jdalton</title>
		<link>http://ajaxian.com/archives/named-function-expressions-in-incredible-detail/comment-page-1#comment-274004</link>
		<dc:creator>jdalton</dc:creator>
		<pubDate>Thu, 18 Jun 2009 22:37:43 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6966#comment-274004</guid>
		<description>@eyelidlessness - I could be wrong, I have been known to mis-read spec on more than on occasion. But in ECMA 5 draft,
.
13	Function Declaration (see 10.6)
.
10.6 Declaration Binding Instantiation
.
funcAlreadyDeclared is the result of calling env’s HasBinding concrete method passing fn as the argument. If its not already declared it calls CreateMutableBinding(..). Then it calls SetMutableBinding(...)
.
It doesn&#039;t seem to call CreateImmutableBinding().
.
Which part of the spec are you referencing?</description>
		<content:encoded><![CDATA[<p>@eyelidlessness &#8211; I could be wrong, I have been known to mis-read spec on more than on occasion. But in ECMA 5 draft,<br />
.<br />
13	Function Declaration (see 10.6)<br />
.<br />
10.6 Declaration Binding Instantiation<br />
.<br />
funcAlreadyDeclared is the result of calling env’s HasBinding concrete method passing fn as the argument. If its not already declared it calls CreateMutableBinding(..). Then it calls SetMutableBinding(&#8230;)<br />
.<br />
It doesn&#8217;t seem to call CreateImmutableBinding().<br />
.<br />
Which part of the spec are you referencing?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eyelidlessness</title>
		<link>http://ajaxian.com/archives/named-function-expressions-in-incredible-detail/comment-page-1#comment-274002</link>
		<dc:creator>eyelidlessness</dc:creator>
		<pubDate>Thu, 18 Jun 2009 19:02:35 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6966#comment-274002</guid>
		<description>What zachleat says is true, if you&#039;re familiar with the ECMA standard. The example,

&lt;code&gt;function g() { return 1; }
if(false) {
    function g() { return 2; }
}&lt;/code&gt;

is technically a syntax error. Function declarations are evaluated prior to script execution, and multiple declarations of the same function in the same scope is invalid. Some engines favor the second declaration simply because handling of the error is not defined.</description>
		<content:encoded><![CDATA[<p>What zachleat says is true, if you&#8217;re familiar with the ECMA standard. The example,</p>
<p><code>function g() { return 1; }<br />
if(false) {<br />
    function g() { return 2; }<br />
}</code></p>
<p>is technically a syntax error. Function declarations are evaluated prior to script execution, and multiple declarations of the same function in the same scope is invalid. Some engines favor the second declaration simply because handling of the error is not defined.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jdalton</title>
		<link>http://ajaxian.com/archives/named-function-expressions-in-incredible-detail/comment-page-1#comment-273998</link>
		<dc:creator>jdalton</dc:creator>
		<pubDate>Thu, 18 Jun 2009 16:24:36 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6966#comment-273998</guid>
		<description>@zachleat I think you missed a lot. Try reading the post again.
function g() { ... } is a function declaration. While var g = function() { ... } is an unnamed function expression.
.
Quote from kangax&#039;s post:
&quot;Another important trait of function declarations is that declaring them conditionally is non-standardized and varies across different environments. You should never rely on functions being declared conditionally and use function expressions instead.&quot;
.
&quot;Never do this! Some browsers will declare `foo` as the one returning &#039;first&#039;,  while others - returning &#039;second&#039; &quot;</description>
		<content:encoded><![CDATA[<p>@zachleat I think you missed a lot. Try reading the post again.<br />
function g() { &#8230; } is a function declaration. While var g = function() { &#8230; } is an unnamed function expression.<br />
.<br />
Quote from kangax&#8217;s post:<br />
&#8220;Another important trait of function declarations is that declaring them conditionally is non-standardized and varies across different environments. You should never rely on functions being declared conditionally and use function expressions instead.&#8221;<br />
.<br />
&#8220;Never do this! Some browsers will declare `foo` as the one returning &#8216;first&#8217;,  while others &#8211; returning &#8216;second&#8217; &#8220;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zachleat</title>
		<link>http://ajaxian.com/archives/named-function-expressions-in-incredible-detail/comment-page-1#comment-273997</link>
		<dc:creator>zachleat</dc:creator>
		<pubDate>Thu, 18 Jun 2009 15:10:15 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6966#comment-273997</guid>
		<description>Perhaps I&#039;m misunderstanding, but why is example #1 unintuitive?

It seems to obey function level scoping.  If I have:

function g() { return 1; }
if(false) {
   function g() { return 2; }
}

Of course, you&#039;d expect g() to return 2, JS doesn&#039;t have a different scope for if statements.  It&#039;s identical to:

var g;
g = function() { return 1; }
g = function() { return 2; }

What am I missing?</description>
		<content:encoded><![CDATA[<p>Perhaps I&#8217;m misunderstanding, but why is example #1 unintuitive?</p>
<p>It seems to obey function level scoping.  If I have:</p>
<p>function g() { return 1; }<br />
if(false) {<br />
   function g() { return 2; }<br />
}</p>
<p>Of course, you&#8217;d expect g() to return 2, JS doesn&#8217;t have a different scope for if statements.  It&#8217;s identical to:</p>
<p>var g;<br />
g = function() { return 1; }<br />
g = function() { return 2; }</p>
<p>What am I missing?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jadet</title>
		<link>http://ajaxian.com/archives/named-function-expressions-in-incredible-detail/comment-page-1#comment-273996</link>
		<dc:creator>Jadet</dc:creator>
		<pubDate>Thu, 18 Jun 2009 14:05:40 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6966#comment-273996</guid>
		<description>It&#039;s too bad the nulling shown in step 4 actually frees up memory, looks like some serious overkill, garbage collectors that don&#039;t free up the memory shown in step 4 have room for improvement.</description>
		<content:encoded><![CDATA[<p>It&#8217;s too bad the nulling shown in step 4 actually frees up memory, looks like some serious overkill, garbage collectors that don&#8217;t free up the memory shown in step 4 have room for improvement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ywg</title>
		<link>http://ajaxian.com/archives/named-function-expressions-in-incredible-detail/comment-page-1#comment-273995</link>
		<dc:creator>ywg</dc:creator>
		<pubDate>Thu, 18 Jun 2009 11:45:31 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6966#comment-273995</guid>
		<description>Most interesting ressource I&#039;ve read this year.
Thanks kangax !</description>
		<content:encoded><![CDATA[<p>Most interesting ressource I&#8217;ve read this year.<br />
Thanks kangax !</p>
]]></content:encoded>
	</item>
</channel>
</rss>

