Skip to content

Meta Issue for Optional New and Const #32798

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

Closed
8 tasks done
JekCharlsonYu opened this issue Apr 5, 2018 · 6 comments
Closed
8 tasks done

Meta Issue for Optional New and Const #32798

JekCharlsonYu opened this issue Apr 5, 2018 · 6 comments
Assignees
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@JekCharlsonYu
Copy link
Contributor

JekCharlsonYu commented Apr 5, 2018

This is just a meta issue to track overall progress and bugs tied to pushing optional new and const in Dart & Flutter.

@JekCharlsonYu JekCharlsonYu added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Apr 5, 2018
@JekCharlsonYu JekCharlsonYu added this to the Dart2 Beta 3 milestone Apr 5, 2018
@JekCharlsonYu JekCharlsonYu self-assigned this Apr 5, 2018
@mit-mit mit-mit added the area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). label Apr 5, 2018
@Hixie
Copy link
Contributor

Hixie commented Apr 10, 2018

We should probably also track the long-term work regarding what people are calling "magic const", which is to say, automatically implying "const" instead of "new" where possible.

@Hixie
Copy link
Contributor

Hixie commented Apr 10, 2018

Also, will the analyzer have a lint that recommends removing new and const where they would be implied?

@eernstg
Copy link
Member

eernstg commented Apr 10, 2018

Drive-by comment: A lint that recommends omitting a const which occurs in a constant context is completely safe (presumably, nobody would have a good reason to have it there), but insisting that you omit all new keywords just because you can may be overly strict: During discussions in the language team about this feature it was noted several times, by several parties, that a well-placed new may serve to document that a particular object is fresh, and that this could improve the readability of the code.

With a possibly upcoming generalization that reintroduces "magic" const, it would again serve to insist that a given object is created at run time, which might otherwise not be expressible. E.g., when new Object() is used to obtain an object reference which is different from all other object references (e.g., to be used as a key in a map), it cannot be left as a plain Object() because that would mean const Object() (at least at some point in the future).

@a14n
Copy link
Contributor

a14n commented Apr 10, 2018

@Hixie do you mean something like dart-archive/linter#936 ?

@Hixie
Copy link
Contributor

Hixie commented Apr 11, 2018

@eernstg In all likelihood for Flutter at least we'd probably just create special non-const constructors for those rare cases where calling "new" instead of "const" makes sense.

@a14n Yeah that seems good.

@JekCharlsonYu
Copy link
Contributor Author

@Hixie will create a separate issue for the long term "magic const"

For now, I'll close this as this was a meta issue to track to work that we need to get all the issues for our next flutter roll.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

6 participants