Every book on C, C++, or Java style warns programmers about the danger of confusing "=" (assignment) with "==" (equality). Python made assignment a statement, rather than an operator, in part to prevent mistakes of the form:
while (something = someCall()) // should be "=="
{
}
Right now, Groovy makes matters worse by:
- changing the meaning of "==" (to mean data equality intsead of object identity), and
- introducing "===" for object identity.
Given that "===" is harder to distinguish from "==" than "==" is from "=", we should introduce a new keyword is for object identity, and remove "===" from the language. (In fact, we should probably go back to using "==" for identity, so as not to confuse programmers who are moving back and forth between Java and Groovy...)
Labels

2 Comments
Hide/Show CommentsJun 18, 2004
Stepan Koltsov
But.. ee.. I don't understand, what this page is? It is placed under "specification" ("contains the current version of the specification (things we've agreed on)"), but it contains phrases "we should probably" or "right now".
My opinion is "===" is fine. Identity test is rarely used, but "is" as idendifier – often, as name of variable for InputStream, for example.
Jun 22, 2004
James Strachan
FWIW the reason we use == for .equals() in Groovy is because
we can in Groovy just do
which handles nulls for you
which if == means identity would often fail - which is why we changed == to mean equals for any type of object in Groovy