News for hackers. Stuff that matters.
Re:Perl6: Unary Sort by colomon on Monday December 23, 2013 @11:03AM (#6954900)
I should have also said that a great deal of thought went into making the default behaviors for "cmp" robust. But if (as in the article's example) you're producing numbers in the transformation code, "cmp" is guaranteed to do the right thing for you. Likewise if you produce strings in the transformation.
Re:Perl6: Unary Sort by adrianmsmith on Monday December 23, 2013 @12:57PM (#6955521)
"Likewise if you produce strings in the transformation" What if you produce strings that look like numbers? Where, for example, extra leading zeros differ in significance between string and numeric comparison? Surely trying to use heuristics for this stuff is always a recipe for disaster, as with the == operator in PHP?
Re:Perl6: Unary Sort by colomon on Tuesday December 24, 2013 @07:59AM (#6959221)
Perl 6 has proper types. If you produce a string, you are producing a Str object (well, technically it could be an object that does the Stringy role, but I don't think there are any other Stringy types implemented yet) and it will compare as a string, not a number, no matter what it looks like.

Likewise, if you produce a number, you have an object which does the Numeric role, and it will compare as a number.

Re:Perl6: Unary Sort by perlgeek on Monday December 23, 2013 @02:25PM (#6956031)
If you produce strings, they are compared as strings, even if they look like numbers.