|
|
|
|
|
by prosqlinjector
985 days ago
|
|
> that argues it's the users responsibility to be careful, If you try to sort with a function that's not a valid comparison operator, I don't know what to tell you. What should it do? Semantics cannot be validated at compile time. The best that can be done is to annotate the function as "yes this should have the right semantics" as is done in Rust and C++ concepts, but that's still not a guarantee. |
|
If I'm reading the article correctly, the user can be informed at runtime with little to no performance impact. That certainly sounds preferable to returning an unsorted list (that may not even match the input).
Almost every Rust sort does this, but no C/C++ sorts do. That appears to support that author's conclusion that this is a cultural thing.