-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Generics terminology #447
Generics terminology #447
Conversation
Proposal links (add links as proposal evolves):
|
docs/design/generics/terminology.md
Outdated
|
||
This parameter broadens the scope of the language construct on an axis defined | ||
by that parameter, effectively defining a family of functions (or whatever) | ||
instead of a single one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to consider only constructs with template parameters defining a family of functions. Since constructs with generic parameters support separate type checking and even separate compilation, they are better thought of as one entity. Generic parameters are much closer to regular (dynamic) parameters. Especially since Carbon aspires to model types as values, it is very interesting to compare the capabilities of generic parameters and dynamic parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still a family of functions with respect to the function signature, right? Otherwise how would you characterize what expressive power you are gaining by adding the generics feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be splitting hairs, but since you are asking... Feel free to resolve without any changes.
A generic function does represent a potentially infinite set of non-generic function signatures. Until monomorphization (which happens after type checking) we don't know the exact set of signatures that the program instantiates. Furthermore, when we call a generic function from another generic function, we can't be working with the family interpretation of the generic callee, we must be considering it as one entity with a "forall T" constraint, in order to type check the call.
What I'm saying is that generic parameters are closer to regular dynamic parameters. As long as the generic or dynamic parameter passes type checking according to the function signature, the single function definition must be able to process them.
Similarly, non-generic functions must process any input values of the correct type, but I don't think one would usually describe a non-generic function as a family of values with respect to function's arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I talked to a few others and we settled on some new words that weaken the connection to "family of functions".
Co-authored-by: Richard Smith <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me.
@gribozavr Can you take a pass over your comments and check to see if any represent blocking concerns?
No blocking concerns! |
To talk about generics as a programming language feature, you need a lot of specialized terminology. We need to agree on the words we are using and their meaning before we can meaningfully talk about the design of the feature itself. There a number of problems a glossary solves: Not everyone knows every term, so having a single place to look them up will improve the ease of understanding, ease of contributing, and accessibility of the project. There may not be widespread agreement on the meaning of some terms. In particular, individual programming languages tend to assign very specific meanings to terms used within their ecosystem. Some terms may be used in multiple ways, but we only use the term with one specific meaning. Some terms are our invention and we need to introduce them. Co-authored-by: Richard Smith <[email protected]>
To talk about generics as a programming language feature, you need a lot of
specialized terminology. We need to agree on the words we are using and their
meaning before we can meaningfully talk about the design of the feature itself.
There a number of problems a glossary solves:
improve the ease of understanding, ease of contributing, and accessibility
of the project.
particular, individual programming languages tend to assign very specific
meanings to terms used within their ecosystem.
specific meaning.