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

Feature name poll #20

Open
tclune opened this issue Oct 23, 2020 · 9 comments
Open

Feature name poll #20

tclune opened this issue Oct 23, 2020 · 9 comments
Labels
question Further information is requested

Comments

@tclune
Copy link
Member

tclune commented Oct 23, 2020

Yesterday there was a virtual meeting in which different languages with template capabilities use different terminologies. C++ has the term 'concept', which is a 'trait' in rust, and 'constraint' in yet other languages.

Ultimately J3/WG5 will have to agree on a term, but the generics subgroup needs a term that we can agree upon for preliminary discussions and prototyping. I really dislike the word 'concept' in this context. I'm strongly in favor of 'constraint' but am also happy with 'trait' and could possibly come around to others. (In the discussion yesterday, I think that 'trait' was the most popular, but we did not take a poll.)

This issue is to solicit opinions from the community. Ultimately the generics subgroup of J3 will decide, but we'd likely go with majority opinion. Please only vote if you have a strong opinion. (Bonus points if you articulate your reasoning.)

@tclune tclune added the question Further information is requested label Oct 23, 2020
@arjenmarkus
Copy link
Collaborator

arjenmarkus commented Oct 23, 2020 via email

@tclune
Copy link
Member Author

tclune commented Oct 23, 2020

Hmm. I see traits (by whatever means) as a mechanism to essentially express the sentiment: "Allow any type here, so long as the specified interfaces exist for that type." That is exactly what a constraint is. Anything that satisfies a constraint is allowed, and anything that does not satisfy a constraint is disallowed.

I agree that the term "trait" suggests that it is shared by multiple entities. But is that an important property here? Traits that can be reused are of course useful, but so are constraints that are reusable

I suppose I might feel differently if we were to actually specify traits when the types themselves are defined. But the existing examples from other languages, and my poor understanding of same, suggest that traits are typically (always?) expressed in templates and the compiler is the one that checks to see if the trait applies to any given type. I.e., the compiler checks to see if the type has the trait. Sounds like a constraint to me. If traits instead were a property declared in the definition of a type, then word would be closer to the conventional meaning.

For fun I googled 'trait' in the context of biology. The first example that came up was eye color. Here, trait is not a specific color (which would be the phenotype: blue, brown, hazel, ...), but the generic class of eye colors. From that perspective, "trait" seems just a bit off to me. Phenotype would be more precise for our use, but I'm not going to propose that alternative. To be fair, we may be only interested in "traits" that have a single phenotype and the distinction is unwarranted.

Again - not strongly opposed to using 'trait'. It at least has the right connotations in my mind.

While English is my native language, I feel that I've still expressed myself poorly here. I may come back with more refined arguments. But only if we have a healthy debate going.

Cheers.

@mleair
Copy link

mleair commented Oct 23, 2020

@tclune, since you asked "But is that an important property here?" I will suggest the term "Property" as a possible keyword too. :)

@klausler
Copy link

The general idea is that of a requirement or prerequisite or expectation or "job qualification" or skill that must be satisfied by an actual type parameter. I don't think any of the terms that are currently in use by other languages are terribly intuitive for this purpose. I am a native English speaker, if that matters.

I find the terms "concept" and "trait" to be so vague as to be meaningless until you learn their special definitions in the languages that use them -- one might as well use "idea" or "aspect" instead, and I hope that they seem as bad to you as they do to me. Please avoid all of these.

I don't mind Haskell's "constraint" as much as I do "concept" & "trait", but I don't think that it conveys its meaning of "must be a member of a particular typeclass" very well either. Similarly, ML's use of the word "signature" isn't terribly intuitive, and it seems to mean "function prototype" to many (younger) programmers.

So I encourage you to find a new term in the absence of a compelling precedent. There's lots of great alternatives.

@wclodius2
Copy link
Contributor

Myself I am partial to "requirement", but don't mind "trait". I think "concept" is terrible.

@tclune
Copy link
Member Author

tclune commented Oct 24, 2020

Not terribly opposed to "property". It points in the right direction but is a bit of an all purpose word. Similar to "attribute" in that sense. Seems safe in the Fortran context though.

@wclodius2 Thanks for the suggestion. I like "requirement" as well. I consider it roughly equivalent to "constraint" in my mental map, and has the extra advantage that it is not a meta-term in the standard. And if we end up needing a verb, saying that X requires Y reads very clearly.

@rouson
Copy link
Contributor

rouson commented Oct 24, 2020 via email

@everythingfunctional
Copy link
Member

Taking a look at this again, I wonder if we aren't trying to give one name to what are effectively 3 separate aspects of the generics facility we are trying to implement. Those 3 things being:

  1. Definition of an "interface" or "typeclass"
  2. "Constrain"ing a template parameter to ensure it "satisfies" an "interface" or is a "member" of a "typeclass"
  3. Declaring that a (derived) type "satisfies" an "interface" or is a "member" of a "typeclass"

@FortranFan 's work towards the KART approach has given us a good idea for the requirements of part 1. So far we have assumed that part 2 is sufficiently by specifying the name of a specific 1 for a template parameter, but we could of course expand that and give part 2 it's own name in the syntax. We have discussed allowing part 3, and I believe have mostly agreed it should be optional, but if allowed would also need it's own syntax and/or keyword.

Based on the above partitioning, I would propose we vote on each aspect, with my suggested options for each listed below. I think I would lean towards 1. typeclass, 2. restriction, 3. membership, but I think there are other combinations that would be acceptable too.

  1. property, typeclass, requirement, concept
  2. constraint, restriction
  3. trait, membership, satisfaction

@klausler
Copy link

Please don't use the word "typeclass". That term refers today only to a specific and distinct feature in another language. And it limits your abstractions to types. Consider following the classic model of Standard ML's signatures and structures and functors instead; modules correspond nicely to ML's structures, and I think you need to be working at the level of modules anyway if you want type-bound procedures to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants