Hi all,

I have been working with Rhino a bit lately, and I have a couple of questions:

1) When a Java object is used in an equality expression, I expected the JavaScript == operator to invoke the object's equals() method, and === to use Java's reference equality operator (==). However, it appears that both == and === translate to reference equality; equals() is only called if I invoke it explicitly. Is this the expected behavior, or am I missing something?

2) If == does not currently delegate to equals(), should it? Taking this one step further, would it be possible to support additional operator overloads as well, a la Groovy?

http://groovy.codehaus.org/Operator+Overloading

For example, "a + b" translates to "a.plus(b)", "a - b" translates to "a.minus(b)", etc.

Operator overloading is a feature that I have missed in Java (coming from C++, way back) and many of the newer JVM scripting languages support it (Groovy, Scala, JRuby (I think), and possibly others). It would be really cool if Rhino supported it as well.

Greg

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to