Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Identity of values in Javascript Date: Tue, 26 May 2015 00:10:54 +0100 Organization: A noiseless patient Spider Lines: 52 Message-ID: <87pp5ofe2p.fsf@bsb.me.uk> References: <555f256b$0$12988$c3e8da3$5496439d@news.astraweb.com> <87r3q8h3yf.fsf@bsb.me.uk> <555f7d3b$0$13002$c3e8da3$5496439d@news.astraweb.com> <87d21sgpqy.fsf@bsb.me.uk> <5561f871$0$13006$c3e8da3$5496439d@news.astraweb.com> <874mn1ehbk.fsf@bsb.me.uk> <55630be0$0$13000$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="28341"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+F+83HpMIUZ1KBgine7LoHyTAlaR2mxbU=" Cancel-Lock: sha1:yMbj2aiOlVI5jfM1JpR+9KA3COo= sha1:r+/Ht43uO5JES47IpwNVF8d2D88= X-BSB-Auth: 1.e0007c8b073a54038f8c.20150526001054BST.87pp5ofe2p.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:27877 Steven D'Aprano writes: > On Mon, 25 May 2015 08:33 am, Ben Bacarisse wrote: > >> The >> language specification is the way to tell what the semantics of argument >> passing are.  That's a lot simpler than looking at an implementation. > > Assuming that there is a language specification, that it states what the > semantics are in unambiguous detail (specs can be buggy too), that you can > understand the specification (often the specs are more complicated and less > understandable than the code that meets those specs), and that the > implementations actually meet the specification. Of course. These are all potential problems. But the code for an implementation might also have some or all of these problems as well. In general, the language's reference document (or if they are opaque and mysterious some reliable digest of is like a textbook) is going to be a better option. > I appreciate you guys taking the time to discuss interesting areas of > compiler optimizations and so forth, and I'm not being sarcastic, but I > wrote here with some concrete questions about Javascript. If they have been > answered, I missed them, sorry. That's a shame; you could try again. If the post has only concrete questions there may be less chance of replies getting tied up in more speculative matters. > Is there any analogue to Python's "is" operator, Ruby's "equal?" method, or > Lua's "rawequal" function, in Javascript? I think the answer is No, > although === (strict equality) comes closest, at least for objects. No, there is nothing that really matches those identity tests. === tests object identity, but because ECMAScript's object model is so different from those other languages, it's not analogous to them in the general case. > When it comes to passing non-objects, is there any way to tell what calling > convention a specific implementation is using other than reading the source > code? Again, I think the answer is No. Am I right? This seems to be a new question. The semantics of function calls are best understood from the specification (it's defined in terms of environments and bindings) but the phrase "calling convention" usually refers to something more low-level and implementation-specific. If that's what you mean, yes, you are right. To find out how an implementation implements calls, you pretty much have to read the code (unless someone has written about the code of course). -- Ben.