- Notifications
You must be signed in to change notification settings - Fork7.9k
[draft] short constructor#19133
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Variations of this have discussed during the constructor property promotion RFC, and more recently in the records RFC.1 As with previous changes, this needs a discussion on the internals mailing list. My expectation is that you'll likely face significant resistance to this change. Footnotes |
@iluuu1994 thanks for the answer. Records RFC pushed me to implement such feature for classes as well, making "records" look similar to classes to prove that it could be done "with classes" classUUID(privatereadonly string$value); This is what you need to create a data transfer object Btw, I'd like to discuss implementation. Theoretically, will it be enough to push the RFC further? |
Generally, I don't spend too much time on implementation before knowing that the RFC actually progresses. Most RFCs die before they make it to the vote.
Yes, RFCs are the only way to land language changes. |
Uh oh!
There was an error while loading.Please reload this page.
There is PoC of short constructor syntax (inspired by Kotlin).
I'd like to discuss the possibilities to move it further and the implementation.
key points:
regular
class A;
becomes
class A {}
how to express constructor with params?
becomes
ok, what about inheritance?
becomes
how to call parent constructor?
becomes