Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Asen Bozhilov Newsgroups: comp.lang.javascript Subject: Re: call by reference Date: Tue, 27 Mar 2012 05:15:35 -0700 (PDT) Organization: http://groups.google.com Lines: 55 Message-ID: <16809571.1415.1332850535967.JavaMail.geo-discussion-forums@vbex14> References: NNTP-Posting-Host: 84.40.76.49 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1332851347 18095 127.0.0.1 (27 Mar 2012 12:29:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 27 Mar 2012 12:29:07 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=84.40.76.49; posting-account=7Fm93QoAAADJLfahesQYQvMxF-JssE8W User-Agent: G2/1.0 X-Received-Bytes: 2716 Xref: csiph.com comp.lang.javascript:13083 Evertjan: > JavaScript DOES support call-by-reference. >=20 > All objects are called by reference: This is long discussed topic. Your terminology even and it is not correct s= eems more closer to the point. JavaScript uses the evaluation strategy call= ed "Call by sharing".=20 =20 It is often mistaken with "Call by reference", but it slightly differ:=20 "The semantics of call-by-sharing differ from call-by-reference in that ass= ignments to function arguments within the function aren't visible to the ca= ller (unlike by-reference semantics)[citation needed], so e.g. if a variabl= e was passed, it is not possible to simulate an assignment on that variable= in the caller's scope. However since the function has access to the same o= bject as the caller (no copy is made), mutations to those objects, if the o= bjects are mutable, within the function are visible to the caller, which ma= y appear to differ from call-by-value semantics." =20 =20 > It does not prove your point.=20 function f(o) { o.foo =3D 10; o =3D {foo : 0}; } var obj =3D {foo : 5}; f(obj); print(obj.foo); //10 This example shows that JavaScript does not use "Call by reference" if it u= sed the value of `foo` would be 0 instead. The example shows "Call by shari= ng" strategy.=20