[Grace-core] Built-in egality

Andrew P Black black at cs.pdx.edu
Thu Dec 12 21:09:25 PST 2013


What should Grace's built-in egality method do when asked to compare two objects of different classes?

The current implementation seems to try to examine the fields in the other object, which fails if they are confidential (e.g., if they are defs).  Even if this worked, it would be wrong, because the two classes might use the fields in quite different ways.  The motivating example is range.from()to() and range.from()downTo(), which obviously do different things with the fields start and stop.  

The == method has to exist, because it's not until the method starts execution that it can look at the argument and notice that it's a different class.  The right answer would seem to be "return false"; the programmer can always override the inherited method with a custom method that does something different in this case.

	Andrew




More information about the Grace-core mailing list