Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/website: Add section to generics docs about common type properties that can't be captured with constraints #52497

Open
bbkane opened this issue Apr 22, 2022 · 0 comments
Labels
Documentation NeedsInvestigation website
Milestone

Comments

@bbkane
Copy link

@bbkane bbkane commented Apr 22, 2022

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.

image

@bbkane bbkane added the pkgsite label Apr 22, 2022
@gopherbot gopherbot added this to the Unreleased milestone Apr 22, 2022
@jamalc jamalc added website and removed pkgsite labels Apr 22, 2022
@thanm thanm added the NeedsInvestigation label Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsInvestigation website
Projects
None yet
Development

No branches or pull requests

4 participants