News for hackers. Stuff that matters.
Re:Timsort, the Python sorting algorithm by chc on Tuesday October 08, 2019 @07:35PM (#21198455)
Ideally I'd like a compile-time error — but that's beyond the current level of technology, so the next best thing is a crash. Having code that does unintended things is the worst-case scenario IMO. (Obviously it's the programmer's fault for providing buggy code, but that's a fault that every programmer shares. Personally, I appreciate any help in guarding against it.)
Re:Timsort, the Python sorting algorithm by jiofih on Wednesday October 09, 2019 @02:51AM (#21200722)
> beyond the current level of technology

I’m sure there quite a few languages that will catch that at compile time.

Re:Timsort, the Python sorting algorithm by earenndil on Wednesday October 09, 2019 @03:33AM (#21200920)
It is possible for a compiler to catch that particular mistake at compile-time. It's also possible for the user to provide a proof to a given compiler that a comparison function is well-formed. But I think that the parent was referring to a function that would check arbitrary comparison functions in java for correctness, without a proof, which is afaik provable impossible.
Re:Timsort, the Python sorting algorithm by estebank on Wednesday October 09, 2019 @03:37PM (#21207078)
> but that's beyond the current level of technology

Is it? In Rust and other languages you would use trait bounds to restrict the input types to be comparable with each other, which would make this a compile time error.

Re:Timsort, the Python sorting algorithm by Dylan16807 on Wednesday October 09, 2019 @05:08PM (#21208091)
How does that prevent you from accidentally making a.compare(b) and b.compare(a) inconsistent on some values?

Making sure you can compare the types is already happening in the compiler, and doesn't find the bug.