News for hackers. Stuff that matters.
Re:Operator constraints in Go by avgcorrection on Monday May 23, 2022 @03:12PM (#31483656)
I don't program in Go. But I could imagine that I might at some point want to sort a list of a custom struct by one of its members. And that's probably as advanced as it would get for my purposes.
Re:Operator constraints in Go by Merovius on Monday May 23, 2022 @03:40PM (#31483960)
Note that the article targets people writing generic code, not consuming it. So it's not really about what you want to sort. It's about what (and how) you want to support with your sorting algorithm.

As for that use-case: Go generics currently don't have a way to constrain on struct fields. So that will always have to be done with some sort of custom comparison function written by the user of your code, which returns the appropriate field.