On Tuesday, April 1, 2003, at 02:22 AM, Luke Palmer wrote:
To outline the problem again, even disregarding user-defined objects:
Generic containers need a way to compare nums to nums and strings to
strings and only get true when they actually are equal.  The kind that
the user overloads with his own user-defined type to say what it means
to be equal.  No magic.

I would suggest that probably ~~ would be the thing most objects overload to determine equality. Since == means numeric, and eq means string, that pretty much leaves ~~ as our beast-to-work-with. Which is fine, because I can certainly see two things being equal numerically without being "Equal" like-wise. And I can certainly see two things as being similar (like-wise), without being identical (identity-wise).


For example, two arrays may contain the name number of elements, but the actual elements in each may be totally different. One possibility.

   my @a1 = (1,2,3);
   my @a2 = ('a','b','c');

   @a1 == @a2;   # true  -- same number of elements
   @a1 eq @a2;   # false -- stringifications aren't the same
   @a1 ~~ @a2;   # false -- elements contained don't ~~ match
   @a1 =:= @a2;  # false -- aren't bound to the same exact array

So I like your idea a lot, personally.

MikeL



Reply via email to