Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!xlned.com!feeder1.xlned.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <6874852.M4kG57y0yY@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Tue, 18 Oct 2011 19:48:36 +0200 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 8Bit Subject: Re: Objects comparaison ? Newsgroups: comp.lang.javascript References: <1k93ek2.1xghqcy1upjvv5N%unbewusst.sein@fai.invalid> <1783522.fYvYJRLvp5@PointedEars.de> <1411612.7OFYzboFZ6@PointedEars.de> <2326223.jLKWLtnpvF@PointedEars.de> <2065619.34vx2sxqLb@PointedEars.de> <2995463.SPkdTlGXAF@PointedEars.de> <2314707.NYtdq5378b@PointedEars.de> <5478003.ScrLVSd4Jv@PointedEars.de> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 60 NNTP-Posting-Date: 18 Oct 2011 19:48:36 CEST NNTP-Posting-Host: c9eedd44.newsspool1.arcor-online.net X-Trace: DXC=]fCJCk9dbo6Tia]Ho99G50ic==]BZ:af>4Fo<]lROoR1<`=YMgDjhg2jVQdlSRe[b?DZm8W4\YJNB4< X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:7545 John G Harris wrote: > Thomas 'PointedEars' Lahn wrote: >> Andreas Bergmaier wrote: >>> And what do you mean with "it has parameters"? Attaching a function >>> without parameters, or attaching a non-function property would be OK? >> He is confusing this with Object.prototype.equals(obj1, obj2), > > It's not me that's confused. You attached the function to Object, a > constructor. That is what I was commenting on. In order to save yourself from further embarassment, you really want to have at least a look at the ECMAScript Language Specification, Edition 5 Final, before further commenting on the programming that is on-topic here. >> which would be a rather bad idea indeed, for two reasons: >> >> First, it would show up in for-in iteration as it would be enumerable >> (and it remains to be seen how widely Object.defineProperty() is >> implemented, so that this can be prevented). >> >> Second, the conflict between the `this' value and one of the arguments >> needs to be resolved: Which value refers to the object being compared >> against? > > > There is no conflict. Which values are to be compared is resolved by the > function's specification. You do have one, don't you? From the displayed > code it appears to be obj1 and obj2; the this value is not used. I was talking about the other way to implement this, Object.prototype.equals(), in that paragraph, as can be seen further above. Assuming it would be implemented that way, Object.prototype.equals = function(obj1, obj2) { … }; then Object instances (and all objects that inherit from [the object referred to by] Object.prototype through their prototype chain) would inherit that method (which is part of why that is not a good idea at the moment). Then it would be possible to call ({}).equals(foo, bar); and one would need to decide in one's implementation what value acts as the `this' value in the equals() code, if any: either that of `foo', or that of `bar'. (My recommendation stands that it should be that of `bar'.) Such considerations do not have to be made if you have a "static" method that is not inherited by other objects implicitly, as in the first approach. Those methods are not supposed to be transferred to other objects. PointedEars -- Use any version of Microsoft Frontpage to create your site. (This won't prevent people from viewing your source, but no one will want to steal it.) -- from (404-comp.)