From: Marcin 'Qrczak' Kowalczyk Date: 2003-10-02T03:56:09+09:00 Subject: Re: Making == symmetric? W li�cie z �ro, 01-10-2003, godz. 20:34, Mark Wilson pisze: > I think Ruby does allow one to define a symmetric ==. Only if you agree to limit cases of "different class but equal" to those where both classes know each other. Because otherwise you would have to change the implementation of == in other classes which were already written elsewhere. For example there doesn't seem to be a way to add a numeric type which plays well with other numeric types wrt. ==, including numeric types you don't know about. > As a general > matter, I think a language is only required to enforce a symmetric == > for objects of the same class (or values of the same type) in order to > have algebraic closure. I prefer to trust the programmer in this case. The only sensible way I imagine in which the language could enforce a symmetric == is to execute the programmer-provided equality in both directions and throw error if they disagree, and this is too little benefit (catching rare bugs) for too much cost (performance of a common operation). Turning the disagreement into false or true would mask an error, so it only discovers bugs - it doesn't add functionality. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/