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

Make void optional #2465

Open
cedvdb opened this issue Sep 4, 2022 · 2 comments
Open

Make void optional #2465

cedvdb opened this issue Sep 4, 2022 · 2 comments
Labels
feature Proposed language feature that solves one or more problems

Comments

@cedvdb
Copy link

cedvdb commented Sep 4, 2022

Originally in sdk repository dart-lang/sdk#34176

abstract class Executor<I,O> {
   O execute(I input);
}

void main() {
  final exe = SomeExecutor<void, int>();
  final result = someExecutor.execute(null);
}

It is much clearer that the task above does not take an input, instead of a nullable input when doing someExecutor.execute(); So it'd be nice to have it optional for the times where you call execute explicitely and statically know the type.

@cedvdb cedvdb added the feature Proposed language feature that solves one or more problems label Sep 4, 2022
@lrhn
Copy link
Member

lrhn commented Sep 5, 2022

The idea is that a void-typed parameter is implicitly optional (if named or trailing positional, I assume).

This is close to #2232 (nullable means optional) in that it makes the optionality of an argument at the call-point depend on the type of the argument. That feature request makes any nullable type optional, which would include void.

@ykmnkmi
Copy link

ykmnkmi commented Sep 5, 2022

Also #1590.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Proposed language feature that solves one or more problems
Projects
None yet
Development

No branches or pull requests

3 participants