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

Specify primary constructors #3023

Merged
merged 42 commits into from Aug 23, 2023
Merged

Specify primary constructors #3023

merged 42 commits into from Aug 23, 2023

Conversation

eernstg
Copy link
Member

@eernstg eernstg commented Apr 27, 2023

This PR adds a proposed feature specification for primary constructors, applicable to normal classes as well as inline classes.

This PR has been merged. It added this feature specification.

@eernstg
Copy link
Member Author

eernstg commented Apr 27, 2023

A bunch of different declarations can be explored by means of scripts/show_primary_constructors.dart. Try

> cd scripts
> dart show_primary_constructors.dart --help
...
> dart show_primary_constructors.dart --show-normal --show-struct class.json
...

to see some help and a single example. Try using --show-keyword to show examples in the style where the primary constructor uses new, const, new.named, const.named and occurs after superinterfaces. E.g., to compare the class const Point._(...) implements C; and the class Point implements C const._(...); style with named constructors:

> dart show_primary_constructors.dart -sk *named*.json

Copy link
Member Author

@eernstg eernstg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review response.

Copy link
Member

@mit-mit mit-mit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very excited about this potential feature!

@eernstg
Copy link
Member Author

eernstg commented May 15, 2023

Thanks, @lrhn, very useful feedback! I've closed a bunch of threads that I thought were uncontroversial, and left others open.

It is indeed tricky to specify anything in terms of a desugaring step. Thinking about it. ;-)

@eernstg
Copy link
Member Author

eernstg commented May 17, 2023

Many smaller improvements introduced in response to review comments, PTAL.

@eernstg eernstg force-pushed the spec_primary_constructors_apr23 branch from a4af6e8 to 66692e7 Compare August 23, 2023 15:45
@eernstg
Copy link
Member Author

eernstg commented Aug 23, 2023

The language team agreed to land this proposal at this time. It is in the 'working' directory, which implies that it is a proposal, not a design which has received a final acceptance.

@eernstg eernstg merged commit 6091eef into main Aug 23, 2023
3 checks passed
@eernstg eernstg deleted the spec_primary_constructors_apr23 branch August 23, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants