Skip to content

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

Closed as not planned
@bbkane

Description

@bbkane

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.website

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions