<?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: ECMA-262-3 in detail. Chapter 8. Evaluation strategy.</title>
	<atom:link href="http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/feed/" rel="self" type="application/rss+xml" />
	<link>http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/</link>
	<description>by Dmitry Soshnikov</description>
	<lastBuildDate>Sat, 04 Feb 2012 03:57:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: eric</title>
		<link>http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/comment-page-1/#comment-7399</link>
		<dc:creator>eric</dc:creator>
		<pubDate>Sun, 25 Sep 2011 04:50:30 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=864#comment-7399</guid>
		<description>Thanks for your reply. I&#039;m not read very careful, get mixed up &quot;call by reference&quot; and &quot;call by sharing&quot;. In your article, &quot;call by reference&quot; means pass the real object to method, and &quot;call by sharing&quot; ,means pass origin object address copy to method. really need more carefully.</description>
		<content:encoded><![CDATA[<p>Thanks for your reply. I&#8217;m not read very careful, get mixed up &#8220;call by reference&#8221; and &#8220;call by sharing&#8221;. In your article, &#8220;call by reference&#8221; means pass the real object to method, and &#8220;call by sharing&#8221; ,means pass origin object address copy to method. really need more carefully.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitry A. Soshnikov</title>
		<link>http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/comment-page-1/#comment-7391</link>
		<dc:creator>Dmitry A. Soshnikov</dc:creator>
		<pubDate>Sat, 24 Sep 2011 13:51:01 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=864#comment-7391</guid>
		<description>@&lt;b&gt;eric&lt;/b&gt;

&lt;blockquote&gt;in the java world, pass value to method ... (this strategy more like your article &quot;call by reference&quot;, but it is called pass by value)&lt;/blockquote&gt;

Yes, in Java the terminology &quot;by-value&quot; is used. But the semantics is what is described in this article as &quot;by-sharing&quot;. As noticed above in the last paragraph &lt;a href=&quot;http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/#terminology-versions&quot; rel=&quot;nofollow&quot;&gt;terminology versions&lt;/a&gt;, both terminologies can be used: either &quot;by-sharing&quot; or &quot;by-value when the value is the reference&quot;.</description>
		<content:encoded><![CDATA[<p>@<b>eric</b></p>
<blockquote><p>in the java world, pass value to method &#8230; (this strategy more like your article &#8220;call by reference&#8221;, but it is called pass by value)</p></blockquote>
<p>Yes, in Java the terminology &#8220;by-value&#8221; is used. But the semantics is what is described in this article as &#8220;by-sharing&#8221;. As noticed above in the last paragraph <a href="http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/#terminology-versions" rel="nofollow">terminology versions</a>, both terminologies can be used: either &#8220;by-sharing&#8221; or &#8220;by-value when the value is the reference&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eric</title>
		<link>http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/comment-page-1/#comment-7374</link>
		<dc:creator>eric</dc:creator>
		<pubDate>Fri, 23 Sep 2011 08:44:50 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=864#comment-7374</guid>
		<description>&lt;blockquote&gt;Hi Dmitry

Yes, but do you know a language where all function arguments are by reference. So for example,

[js]
function f(x) {
  x = 5
};
 
a = 10;
f(a);
and now a = 5.
[/js]

It would be a weird language to work with.

Morten.&lt;/blockquote&gt;

C# can do this

[js]
 function f(ref x) {
    x = 5;
 }
 a = 10;
 f(a); [/js]
 &lt;code&gt;a&lt;/code&gt; will be the 5

</description>
		<content:encoded><![CDATA[<blockquote><p>Hi Dmitry</p>
<p>Yes, but do you know a language where all function arguments are by reference. So for example,</p>
<pre class="brush: jscript; title: ;">
function f(x) {
  x = 5
};

a = 10;
f(a);
and now a = 5.
</pre>
<p>It would be a weird language to work with.</p>
<p>Morten.</p></blockquote>
<p>C# can do this</p>
<pre class="brush: jscript; title: ;">
 function f(ref x) {
    x = 5;
 }
 a = 10;
 f(a); </pre>
<p> <code>a</code> will be the 5</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eric</title>
		<link>http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/comment-page-1/#comment-7372</link>
		<dc:creator>eric</dc:creator>
		<pubDate>Fri, 23 Sep 2011 08:14:58 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=864#comment-7372</guid>
		<description>Strategy by sharing is used in many languages: Java, ECMAScript, Python, Ruby, Visual Basic, etc.

Java can call by sharing?I doubt...

http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html</description>
		<content:encoded><![CDATA[<p>Strategy by sharing is used in many languages: Java, ECMAScript, Python, Ruby, Visual Basic, etc.</p>
<p>Java can call by sharing?I doubt&#8230;</p>
<p><a href="http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html" rel="nofollow">http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eric</title>
		<link>http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/comment-page-1/#comment-7371</link>
		<dc:creator>eric</dc:creator>
		<pubDate>Fri, 23 Sep 2011 08:09:29 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=864#comment-7371</guid>
		<description>And i know in the C# there has two keyword--&quot;ref&quot;&#124;&quot;out&quot;, this can do like you said &quot;call by share&quot;</description>
		<content:encoded><![CDATA[<p>And i know in the C# there has two keyword&#8211;&#8221;ref&#8221;|&#8221;out&#8221;, this can do like you said &#8220;call by share&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eric</title>
		<link>http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/comment-page-1/#comment-7370</link>
		<dc:creator>eric</dc:creator>
		<pubDate>Fri, 23 Sep 2011 08:04:53 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=864#comment-7370</guid>
		<description>I&#039;m not completed assent this article. since in the java world, pass value to method. and if do like you said, pass value will not affect outside object. But its definite will change the properties of outside object, because the parameter variable hold the reference of the original object, if don&#039;t change the reference, change any properties will affect outside original object(this strategy more like your article &quot;call by reference&quot;, but it is called pass by value).</description>
		<content:encoded><![CDATA[<p>I&#8217;m not completed assent this article. since in the java world, pass value to method. and if do like you said, pass value will not affect outside object. But its definite will change the properties of outside object, because the parameter variable hold the reference of the original object, if don&#8217;t change the reference, change any properties will affect outside original object(this strategy more like your article &#8220;call by reference&#8221;, but it is called pass by value).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitry A. Soshnikov</title>
		<link>http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/comment-page-1/#comment-5327</link>
		<dc:creator>Dmitry A. Soshnikov</dc:creator>
		<pubDate>Tue, 25 Jan 2011 13:56:56 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=864#comment-5327</guid>
		<description>@&lt;b&gt;Morten Krogh&lt;/b&gt;

Nope, I&#039;m not aware about such a language. Seems, it wouldn&#039;t be very useful ;)

Dmitry.</description>
		<content:encoded><![CDATA[<p>@<b>Morten Krogh</b></p>
<p>Nope, I&#8217;m not aware about such a language. Seems, it wouldn&#8217;t be very useful <img src='http://dmitrysoshnikov.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Dmitry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Morten Krogh</title>
		<link>http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/comment-page-1/#comment-5326</link>
		<dc:creator>Morten Krogh</dc:creator>
		<pubDate>Tue, 25 Jan 2011 13:19:25 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=864#comment-5326</guid>
		<description>Hi Dmitry

Yes, but do you know a language where all function arguments are by reference. So for example,

[js]function f(x) {
  x = 5
};

a = 10;
f(a);[/js]

and now &lt;code&gt;a = 5&lt;/code&gt;.

It would be a weird language to work with.

Morten.</description>
		<content:encoded><![CDATA[<p>Hi Dmitry</p>
<p>Yes, but do you know a language where all function arguments are by reference. So for example,</p>
<pre class="brush: jscript; title: ;">function f(x) {
  x = 5
};

a = 10;
f(a);</pre>
<p>and now <code>a = 5</code>.</p>
<p>It would be a weird language to work with.</p>
<p>Morten.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitry A. Soshnikov</title>
		<link>http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/comment-page-1/#comment-5291</link>
		<dc:creator>Dmitry A. Soshnikov</dc:creator>
		<pubDate>Mon, 24 Jan 2011 10:10:45 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=864#comment-5291</guid>
		<description>@&lt;b&gt;Morten Krogh&lt;/b&gt;

&lt;blockquote&gt;Are there languages that use call by reference?&lt;/blockquote&gt;

First, we should understand that mentioned strategies are just &lt;em&gt;abstract&lt;/em&gt; descriptions.

However, in some languages, the concept and the exact meaning of a &lt;em&gt;reference&lt;/em&gt; can vary. The nearest example of &lt;em&gt;by-reference&lt;/em&gt; strategy can be shown with C++ and its reference sugar:

[c]// C++

void call_by_reference(int&amp; x)
{
  x = 20; // external *mutation*
}

void call_by_pointer(int* x)
{
  *x = 20; // also external *mutation*
  x = new int; // and this is already *rebinding*
  *x = 30; // mutation of the other memory block
}

void call_by_value(int x)
{
  x = 20; // just local mutation
}

int _tmain(int argc, _TCHAR* argv[])
{
  int y = 0;

  call_by_reference(y);
  call_by_pointer(&amp;y);
  call_by_value(y);

  return 0;
}[/c]

Thus, as said, this &lt;em&gt;by-reference&lt;/em&gt; of C++ is just a syntactic sugar (in general, and if to see the &lt;a href=&quot;https://gist.github.com/380515&quot; rel=&quot;nofollow&quot;&gt;assembly generated code&lt;/a&gt;) for the &lt;em&gt;by-pointer&lt;/em&gt; (which is described above &lt;em&gt;by-sharing&lt;/em&gt;) strategy -- i.e. for not to dereference a pointer every time.

The main point is in the operation of &lt;em&gt;assignment&lt;/em&gt;. Because often enough there are questions on JS such as &quot;Why if an object is passed by reference I can&#039;t replace it via assignment?&quot;. The answer is -- it&#039;s not by-reference (from C++ viewpoint), but &quot;by-pointer&quot; (or &quot;by-value, where value is an address&quot;), where assignment (without dereferencing) just changes the pointer&#039;s address.

Also take a look on this explanation of a &lt;a href=&quot;http://dmitrysoshnikov.com/ecmascript/es5-chapter-3-1-lexical-environments-common-theory/#name-binding&quot; rel=&quot;nofollow&quot;&gt;name binding&lt;/a&gt; concept, which also accurately explains the difference. Thus, the assignment means a &lt;a href=&quot;http://dmitrysoshnikov.com/ecmascript/es5-chapter-3-1-lexical-environments-common-theory/#rebinding&quot; rel=&quot;nofollow&quot;&gt;rebinding&lt;/a&gt;. And changing of a properties means &lt;a href=&quot;http://dmitrysoshnikov.com/ecmascript/es5-chapter-3-1-lexical-environments-common-theory/#mutation&quot; rel=&quot;nofollow&quot;&gt;mutation&lt;/a&gt;.

Dmitry.</description>
		<content:encoded><![CDATA[<p>@<b>Morten Krogh</b></p>
<blockquote><p>Are there languages that use call by reference?</p></blockquote>
<p>First, we should understand that mentioned strategies are just <em>abstract</em> descriptions.</p>
<p>However, in some languages, the concept and the exact meaning of a <em>reference</em> can vary. The nearest example of <em>by-reference</em> strategy can be shown with C++ and its reference sugar:</p>
<pre class="brush: cpp; title: ;">// C++

void call_by_reference(int&amp; x)
{
  x = 20; // external *mutation*
}

void call_by_pointer(int* x)
{
  *x = 20; // also external *mutation*
  x = new int; // and this is already *rebinding*
  *x = 30; // mutation of the other memory block
}

void call_by_value(int x)
{
  x = 20; // just local mutation
}

int _tmain(int argc, _TCHAR* argv[])
{
  int y = 0;

  call_by_reference(y);
  call_by_pointer(&amp;y);
  call_by_value(y);

  return 0;
}</pre>
<p>Thus, as said, this <em>by-reference</em> of C++ is just a syntactic sugar (in general, and if to see the <a href="https://gist.github.com/380515" rel="nofollow">assembly generated code</a>) for the <em>by-pointer</em> (which is described above <em>by-sharing</em>) strategy &#8212; i.e. for not to dereference a pointer every time.</p>
<p>The main point is in the operation of <em>assignment</em>. Because often enough there are questions on JS such as &#8220;Why if an object is passed by reference I can&#8217;t replace it via assignment?&#8221;. The answer is &#8212; it&#8217;s not by-reference (from C++ viewpoint), but &#8220;by-pointer&#8221; (or &#8220;by-value, where value is an address&#8221;), where assignment (without dereferencing) just changes the pointer&#8217;s address.</p>
<p>Also take a look on this explanation of a <a href="http://dmitrysoshnikov.com/ecmascript/es5-chapter-3-1-lexical-environments-common-theory/#name-binding" rel="nofollow">name binding</a> concept, which also accurately explains the difference. Thus, the assignment means a <a href="http://dmitrysoshnikov.com/ecmascript/es5-chapter-3-1-lexical-environments-common-theory/#rebinding" rel="nofollow">rebinding</a>. And changing of a properties means <a href="http://dmitrysoshnikov.com/ecmascript/es5-chapter-3-1-lexical-environments-common-theory/#mutation" rel="nofollow">mutation</a>.</p>
<p>Dmitry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Morten Krogh</title>
		<link>http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/comment-page-1/#comment-5272</link>
		<dc:creator>Morten Krogh</dc:creator>
		<pubDate>Sun, 23 Jan 2011 20:31:28 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=864#comment-5272</guid>
		<description>Hi Dmitry

Very good Javascript series. Excellent. I have read several of 
your articles, and they are really good.

One question about this article. Are there languages that use 
call by reference? You don&#039;t give any examples. The closest I 
could think of is in C by using pointers to pointers. 

[c]int f(struct example **x) 
{
  *x = malloc(sizeof **x);
  ......
}[/c]

or you could wrap a struct inside a struct.

But are there languages with more direct examples, where f(x) would really be by reference? 

Morten.</description>
		<content:encoded><![CDATA[<p>Hi Dmitry</p>
<p>Very good Javascript series. Excellent. I have read several of<br />
your articles, and they are really good.</p>
<p>One question about this article. Are there languages that use<br />
call by reference? You don&#8217;t give any examples. The closest I<br />
could think of is in C by using pointers to pointers. </p>
<pre class="brush: cpp; title: ;">int f(struct example **x)
{
  *x = malloc(sizeof **x);
  ......
}</pre>
<p>or you could wrap a struct inside a struct.</p>
<p>But are there languages with more direct examples, where f(x) would really be by reference? </p>
<p>Morten.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

