On 2008-Dec-4, at 4:41 pm, Leon Timmermans wrote:
On Thu, Dec 4, 2008 at 6:34 PM, TSa <[EMAIL PROTECTED]>
wrote:
And how about 'Num 1.0 === Complex(1,0) === Int 1'?
IMHO the spec on === is quite clear: "two values are never
equivalent unless they are of exactly the same type."
I guess the question is what kind of similarity is the most useful?
On the one hand, we have values that happen to have the same
*representation* but different *meaning* (e.g. Weekday::Sun and
Star::Sun); on the other hand, we have values with a different
representation but the same meaning (e.g. Int 29 and int8 29).
Usually the reason for comparing both value and type is to check for
the same meaning, rather than accidentally equal representations.
So let's imagine a "syn" operator that checks for the same value and
the same "family":
1 syn 1.0 syn Complex(1,0)
Date '2008-1-2' syn Datetime '2008-1-2 0:00:00'
We can't simply rely on == because my Date and Datetime objects can be
coerced to numeric values, but they don't mean the same thing as a
plain Num or Int. Presumably classes need to indicate their family
resemblances somehow.
Now, which is more useful? Is it worth having "===" and "syn"?
-David