Skip to content

spec: provide some way to refer to a generic function without instantiation #52654

@josharian

Description

@josharian

The motivation behind type aliases was the ability to refer under a new name to a thing that exists elsewhere. Prior to generics, functions can be easily re-referred to using assignment:

var Cut = strings.Cut

However, doing the same thing with a generic function fails with error message "cannot use generic function F without instantiation". It is possible to define a wrapper function, but that requires copy/pasting the entire function signature.

It'd be nice if the plain assignment worked.

I understand that this probably raises non-trivial spec difficulties. I just wanted to flag it as a useful thing.

I imagine this is a dupe, but I couldn't find it.

cc @ianlancetaylor @dsnet

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.genericsIssue is related to generics

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions