No safe efficient ways to do three-way string comparisons in Go
> Basically no one should use strings.Compare<p>Others have already talked about the performance aspect but I'm just baffled at the comment basically saying nobody should use this function anyway.<p>I expect the need for 3-way compares isn't that uncommon, why tell people not to use it?<p>It's great to have this idea that the compiler should optimize all comparison situations but a) it doesn't yet and b) people still want a 3-way compare function anyway.<p>Basically it's saying "don't use a function at all", or even "write your own copies of this function". Even <i>if</i> the compiler one day becomes smart enough to optimize you <i>still</i> end up with tons of code duplication if people followed the advice.<p>And for people who care about performance it means they'll use a 3rd party library or implement their own "optimizations" that might not be effective or even buggy.<p>Literally nobody is benefiting from this.<p>What's the point of providing this function but actually thinking nobody should use it, in a comment no less instead of documentation?<p>Now, there may be other reasons, e.g. the author thinking 3-way compare is a bad pattern in the first place. If argued well, maybe I could agree. But that argument isn't made here.<p>I'm also not saying they needed to optimize this off the bat. A comment saying "we don't think there is a big demand yet, will optimize when we see the demand" would've been acceptable.