4 ms·
> so the documentation is trying to talk them out of... What documentation though? There's an internal comment but it's not documentation and it's not really a
by quelltext 4y ago
> so the documentation is trying to talk them out of...
What documentation though? There's an internal comment but it's not documentation and it's not really arguing against the use of this type of comparison (just against use of the implemented function).
If the documentation for this function went on along the lines of "we discourage the use of 3 way compares as we consider it an antipattern, do X instead, there's literally no reason to ever use 3 way compares, we know it, here's why..." maybe, but it doesn't.
Now, maybe 3 way comparison is not common but it is a distinct operation with known optimization opportunities. I wouldn't readily claim that the operation is not needed by anyone.
- jrockway 4y ago> What documentation though? Yeah, sorry about that. I read the actual documentation and nothing is mentioned. I realized later on in my comment though ;)
- kubanczyk 4y ago> If the documentation for this function went on along the lines of "we discourage the use of 3 way compares as we consider it an antipattern, do X instead, there's literally no reason to ever use 3 way compares, we know it, here's why..." maybe, but it doesn't. But it does. It literally says "It is usually clearer and always faster to use the built-in string comparison" and it always said that. https://pkg.go.dev/strings@go1.5#Compare https://pkg.go.dev/strings@go1.5#Compare https://pkg.go.dev/strings@go1.19.2#Compare https://pkg.go.dev/strings@go1.19.2#Compare The entire documentation for this function is four short sentences. If my code editor didn't make it easy and natural to see them, I'd rethink my shit right now.
- quelltext 4y agoIt doesn't go into why, it's just a statement.