When creating a generic data structure such as a Set[T comparable], it's also important to think about such properties as:
- zero values of T (such as
nil interface values)
- invalid values
- edge cases of comparability, such as "is
== reflexive?" - for example float64 NaN values need special handling
These properties (and there are probably more) must be handled to avoid subtle errors in generic code, yet are also easy to overlook for beginners to generic programming like myself.
Would you consider adding a list of these properties to https://go.dev/doc/tutorial/generics or maybe https://go.dev/blog/when-generics (the two posts that have helped me the most with generics) or accepting a CL to add it?
Special thanks to @bcmills who brought this list up to me in the #generics Slack channel . I'm attaching a screenshot of our Slack conversation so it doesn't get lost in Slack history.

When creating a generic data structure such as a
Set[T comparable], it's also important to think about such properties as:nilinterface values)==reflexive?" - for example float64NaNvalues need special handlingThese properties (and there are probably more) must be handled to avoid subtle errors in generic code, yet are also easy to overlook for beginners to generic programming like myself.
Would you consider adding a list of these properties to https://go.dev/doc/tutorial/generics or maybe https://go.dev/blog/when-generics (the two posts that have helped me the most with generics) or accepting a CL to add it?
Special thanks to @bcmills who brought this list up to me in the #generics Slack channel . I'm attaching a screenshot of our Slack conversation so it doesn't get lost in Slack history.