carbon-language / carbon-lang

Carbon Language's main repository: documents, design, implementation, and related tools. (NOTE: Carbon Language is experimental; see README)
http://docs.carbon-lang.dev/
Other
32.25k stars 1.47k forks source link

Proposal: Rename interfaces to traits #2095

Open nacaclanga opened 2 years ago

nacaclanga commented 2 years ago

In C++ the term "interface" is often used as a synonym for "abstract classes". A similar definition is used in Java, where interfaces have special meaning, as the can circumwent the limitation of having only one base class. In Carbon however the current proposal describes "interfaces" to be more akin to the concept known as "traits" in Rust (the only difference being that there are also structural "traits"/"interfaces")

I therefore propose to rename "interfaces" into "traits" and replace the "interface" keyword by a new "trait" keyword. This will avoid false connotations for people from a C++ background and make the concept more easily understandable for people familiar with Rust.

geoffromer commented 2 years ago

The word "trait" also has a pre-existing meaning in C++, and it's much more well-established than "interface" (for example, it's used pervasively in the standard library). So at least in terms of consistency with C++ this seems like it would be a regression.

I also don't think the existing Java/C++ meaning of "interface" will cause that much confusion, because even though Carbon interfaces have somewhat different mechanics, they represent very similar concepts, and play very similar roles in the language. In particular, Carbon interfaces seem much more similar to Java/C++ interfaces than to C++ traits.

github-actions[bot] commented 1 year ago

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please comment or remove the inactive label. The long term label can also be added for issues which are expected to take time. This issue is labeled inactive because the last activity was over 90 days ago.