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

Clarify how types are constructed from function items #1419

Open
alexttx opened this issue Oct 26, 2023 · 0 comments
Open

Clarify how types are constructed from function items #1419

alexttx opened this issue Oct 26, 2023 · 0 comments

Comments

@alexttx
Copy link

alexttx commented Oct 26, 2023

The section on Function Item Types (section 10.1.11 in stable branch as of Oct 26 2023) states:

When referred to, a function item, or the constructor of a tuple-like struct or enum variant, yields a zero-sized value of its function item type. That type explicitly identifies the function - its name, its type arguments, and its early-bound lifetime arguments (but not its late-bound lifetime arguments, which are only assigned when the function is called)

IMO the wording could be more explicit (and should include the return type?). Perhaps something like this:

A function item's type is defined by the function's name, the type and order of the its arguments, its return type, and its early-bound lifetime arguments. Late-bound lifetime arguments are not part of a function item's type since they are assigned when the function is called.

I'm not an expert by any means, so I don't know if the above description is correct or omits additional helpful information. For example, a statement about generics might be helpful. I presume they're not part of the type -- in which case a statement such as "Generics are not part of a function item's type since a function declared with generics is a template and not a function item - it becomes a function item when instantiated with specific types".

@alexttx alexttx changed the title Clarify how a type is constructed from a function item Clarify how types are constructed from function items Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant