Bug 3830 – opCmp among variant arrays

Status
RESOLVED
Resolution
WORKSFORME
Severity
minor
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-02-18T12:48:00Z
Last change time
2014-02-22T05:13:00Z
Assigned to
andrei
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-02-18T12:48:52Z
opCmp among box arrays seems wrong, this asserts: import std.boxer; void main() { auto a1 = boxArray(10, 45.4); auto a2 = boxArray(10, 45.2); assert(a1 > a2); }
Comment #1 by andrej.mitrovich — 2013-02-01T17:05:27Z
std.boxer is gone, however Variant has the same problems: import std.variant; void main() { auto a1 = variantArray(10, 45.4); auto a2 = variantArray(10, 45.2); assert(a1 > a2); // fails }
Comment #2 by andrei — 2013-02-26T09:17:00Z
I'm unclear whether ordering on Variant arrays is meaningful. One approach is lexicographical compare, but it's not the only one.
Comment #3 by peter.alexander.au — 2014-02-15T13:01:25Z
What should this do? auto a1 = variantArray("foo"); auto a2 = variantArray(10); assert(a1 > a2); Throw a type mismatch exception?
Comment #4 by andrei — 2014-02-16T07:14:11Z
Scripting languages almost always have rich rules for comparison across unequal types, so I suppose that's an important convenience they offer. On the other hand, they're also widely criticized for the complexity and arbitraryness of these rules. I'm not sure where that leaves us. I think we should just make Andrej's code work, because it works with regular arrays.
Comment #5 by bearophile_hugs — 2014-02-16T07:43:20Z
(In reply to comment #4) > Scripting languages almost always have rich rules for comparison across unequal > types, so I suppose that's an important convenience they offer. In Python2.x you can compare and sort lists of anything, but in Python3 they have made the type system more tight, and now you have to compare only compatible types (so comparing an int and a string throws an exception).
Comment #6 by peter.alexander.au — 2014-02-16T08:50:47Z
And for some reason I thought variantArray was a separate type... It's just a Variant[], and the code works for me. http://dpaste.dzfl.pl/617841e1b8ff I believe this can be closed as FIXED.
Comment #7 by peter.alexander.au — 2014-02-22T05:13:00Z
Was fixed in 2.064