Directly Overloading ==
hancock at earthlink.net
Wed Sep 13 02:41:52 CEST 2000
Can you do it?
Yes I know you can use __cmp__(), but that's
not the same thing (yes, I did look it up in
the language reference).
IMHO, it would be extremely convenient to overload
the "==" operator directly, to change it to
return a fuzzy logic value indicating the
*degree* of equality rather than absolute
equality (which as with float values is pretty
pointless with fuzzy logic).
This would make it possible to write an expression
c = (a == b)
where c acquires a fuzzy value indicate the correlation
of a and b. This will actually be equivalent to
c = not (a xor b)
(after properly overloading not and xor with their fuzzy
logic counterparts) but be a lot easier to understand.
It's particularly sensible when used with the defuzzifying
operations in an expression:
if perchance( a == b ) : ...
where "perchance()", along with "absolutely()" is one
of several ways to convert a fuzzy expression to crisp
logic, using in this case a weighted random number method.
It might find similar uses in scientific programming,
where it could be used to replace the obnoxious
comparisons that usually have to be used in iteration
if target - TOLERANCE < value < target + TOLERANCE : ...
So, back to the question:
1) Can you do it?
2) If not, will you ever be able to? (Or, put another
way, could I find out how to implement it and submit
3) If it's really impossible, what's the most sensible
Please CC me as I'm not yet on the list (I tried, but
the server seems to be pretty busy right now).
More information about the Python-list