-
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
Proposal: Replace the extends
keyword with just :
#2072
Comments
Hey @CXCubeHD! While the idea of using a colon seems to adhere to the C++ syntax and can be a good choice for people who would transition to carbon from C++ in the long run, I think we should avoid inheriting from more than one parent class. Remember that Java eliminated the concept of multiple inheritances to avoid conflicts between members of different parent classes should there exist any common attributes or functions. However, implementing interfaces doesn't seem to cause such an issue. So to summarize, the idea has merit if not for that one drawback. |
|
Elsewhere in Carbon's syntax, we use Another consideration is that using a keyword like
... and in so doing, we can give the developer control over where in the class layout the base class is positioned. Such syntax might also be useful for mixins. This syntactic freedom is already used to some extent in On the other hand, using a |
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 |
Proposal
extends
looks and is boilerplate, replace it with:
instead.Additonal inheritance (sometimes in the future) or implementation statememts (of interfaces) are seperated using
,
Thanks for reading, change it while you still can!!!!
Edit
I cannot answer to any comments because I was blocked for NO REASON in #2071
Thank you jonmeow 👏👏👏, very good job, I hope they pay you good money for your good work 👏
Response to Comments
@vinsdragonis I can speak for many people when I say that the
:
syntax is a much nicer and less verbose. Other languages like C# or Kotlin have this syntax as well and they also don't have multi inheritance.Edit: Also, you need to look it in this way: Why do you write
fn
instead offunction
in function declaration statements? Why do you writevar
instead ofvariable
? Simple: less verbosity.@zygoloid Kotlin also has a
var name: type
and aclass Class : Base
syntax and it works very well so why also not implement that less verbose syntax.The text was updated successfully, but these errors were encountered: