Skip to content

Meta-issue for discussion of the proposal to allow generic constructors #30355

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
leafpetersen opened this issue Aug 7, 2017 · 3 comments
Closed
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). language-discussion

Comments

@leafpetersen
Copy link
Member

leafpetersen commented Aug 7, 2017

This issue is to provide a forum for community discussion and feedback related to the proposal to allow constructors for classes to take additional generic arguments independent of the generic arguments of their class.

Currently strong mode allows generic functions and methods with a syntax like int foo<T>(List <T> l) ..., but constructors are not generic - they can only get the type parameters of the class.
An example case could be List.mapped<S>(Iterable<S> source, E map(S value)) ... where the type of the source doesn't depend on the type of the created list List<E>.

This entry will be updated when a proposal is available.

cc @munificent @eernstg @floitschG @lrhn

@leafpetersen leafpetersen added area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). language-discussion labels Aug 7, 2017
@brianegan
Copy link

brianegan commented Aug 8, 2017

I wrote in an issue for this, and I'm fully in favor of supporting generics in constructors! #30041

The status quo creates a weird dichotomy between factory constructors and static constructors, because I sometimes need constructors with generics. It's confusing for library consumers (e.g. is this a factory or static constructor? Autocompletion is affected within your IDE). It also adds complexity for folks learning the language: Why isn't there one true way for class construction?

Thanks for opening up the discussion and hearing our thoughts :)

@eernstg
Copy link
Member

eernstg commented Nov 13, 2017

This feature was also requested in #31360.

@natebosch
Copy link
Member

Closing in favor of https://github.com/dart-lang/sdk/issues/26391 since it's older.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). language-discussion
Projects
None yet
Development

No branches or pull requests

4 participants