Skip to content

Allow "void" as a generic type parameter. #17518

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
lrhn opened this issue Mar 17, 2014 · 2 comments
Closed

Allow "void" as a generic type parameter. #17518

lrhn opened this issue Mar 17, 2014 · 2 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug

Comments

@lrhn
Copy link
Member

lrhn commented Mar 17, 2014

The void type is only allowed as a function return type. It is equivalent to "Null" except for documentation purposes (and allowing "return;" statements in the body).
The documentation meaning is that the function does not return a meaningful value, and its result shouldn't be used.

For Future, we have the same documentation need. Some Futures carry no meaningful value, they are effectively the delayed results of evaluating a void function.
It would improve documentation if these futures could be typed as "Future<void>". By duality, it would be equivalent to "Future<Null>", but documenting a different intent.

It's likely to also be useful in other places. Perhaps we should allow "void" everywhere we currently allow "dynamic".

@gbracha
Copy link
Contributor

gbracha commented Aug 23, 2014

I really don't see the point in letting void spread its malaise any further. As a type it means nothing - it has no values. Future is the only case here, and you can write Future<Null> if you want now, which accurately describes what the Future is carrying.


Set owner to @gbracha.
Added Accepted label.

@lrhn lrhn added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Aug 23, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Feb 29, 2016
@munificent
Copy link
Member

Duplicate of #27504. (Yes, this one is much older, but that one is linked to by more things.)

@munificent munificent added the closed-duplicate Closed in favor of an existing report label Dec 15, 2016
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). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants