Object.eq is ready for discussion

Brendan Eich brendan at mozilla.com
Mon Sep 6 18:01:14 PDT 2010

On Sep 6, 2010, at 4:01 PM, Jürg Lehni wrote:

> I agree it's a good name, but how about Object.isIdentical? Wouldn't that follow existing naming conventions more closely?

It would following the verg-object-noun-phrase convention, but we have more than one convention.

Note how isNaN(x) and isFinite(x) are functions taking one parameter. Whereas Object.identical(a, b) tests whether two values *are* identical. Does "is" work still? Could we dodge the issue (as well as the implied preposition "to": isIdenticalTo) by using Jeff's "identical" suggestion?

A pure OOP (single receiver) naming convention as in Smalltalk might favor a isIdenticalTo: b (if it didn't use an operator symbol, as IIRC Smalltalk did: ==), but Object.identical is really a function (static method of Object, simply to avoid name pollution in any other object). Object.identical(a, b) seems better to me than any longer name involving "is" and/or "To".

For single-parameter tests, "is" or "has" followed by a NounPhrase is indeed the dominant naming convention. For a dyadic function to pair with Object.hashcode, Object.identical still seems best to me. The only other verb-free thought is to use the language in the ES5 spec (9.12) and call it Object.sameValue.


> Juerg
> On 6 Sep 2010, at 22:45, Maciej Stachowiak wrote:
>> On Sep 6, 2010, at 9:30 AM, Jeff Walden wrote:
>>> On 09/05/2010 08:31 PM, Maciej Stachowiak wrote:
>>>>> The strawman has a note where I suggested matching "hashcode" with "identity" as the method name. If nothing else, the name length and lack of hackerly abbreviation recommend it. Comments?
>>>> I would expect a function named "identity" to be a function of one argument that returns it unmodified, rather than a two-argument predicate that implements an equivalence relation. "eq" seems like an ok name. "egal" will probably seem more mysterious than "eq".
>>> Object.identical seems to imply the right things, certainly better than Object.identity.  To the extent I want to get involved in this paint job, I think this is the best shade I've considered.
>> Object.identical is a good name.
>> - Maciej
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

More information about the es-discuss mailing list