On Sat, Jul 27, 2002 at 08:07:50PM -0700, Sean O'Rourke wrote: > Whether plain cmp (as a vtable function or an op on PMCs) should be kept > at all is questionable -- there's no way to get at it syntactically from > Perl or any other language that has separate numeric and string > comparisons. It might be useful for languages with a single set of > comparisons that "do the right thing". While presumably Perl 6 will have > "object comparisons", they'll happen by overloading either the numeric or > the stringific operators, and therefore should be handled in the type's > cmp_{string,num} method.
I think it was being suggested that =~ could actually "do the right thing" in a very general case - ie (in perl5 terms) $a = 4; 3 =~ $a; would be numeric comparison $a = "four"; 3 =~ $a; would fall back to string comparison (because perl6 would decide that the string "four" can't be converted to a number) $a = qr/1234/; 3 =~ $a would be a regexp match. In effect =~ would be a builtin cmp with dispatch based on the types of both sides, preferring to compare as integers, then floating point, then strings, then regexps, then ... But even if perl6 wants this (and I can't remember if it's been officially suggested that it might), I'm not convinced that it's something that needs a vtable entry in the low level types of every PMC. Nicholas Clark -- Even better than the real thing: http://nms-cgi.sourceforge.net/