dart-lang / dart-lang/language
Perform async constructor arguments in parallel
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
Currently async constructor arguments are evaluated sequentially. Since constructors arguments are not sequential by nature, it could be ideal if they were evaluated in parallel. This would also provide a type safe alternative to `Future.wait()` which returns type `Iterable>`
https://dartpad.dev/f1e86c048a939d0264929c3380430c2f
```dart
main() async {
print("Start");
var s = Stopwatch()..start();
/// It would be nice if getFoo() and getBar() were evaluated in parallel,
/// as if they were performed with Future.wait()
///
/// This takes 2 seconds
final result = Foo(await getFoo(), await getBar());
print("Stop: ${s.elapsed}");
}
class Foo {
final String foo;
final String bar;
Foo(this.foo, this.bar);
}
Future getFoo() => Future.delayed(Duration(seconds: 1), () => "foo");
Future getBar() => Future.delayed(Duration(seconds: 1), () => "bar");
```
Contributor guide
Research direction
Start with the DartPad example in the issue and read the 15-comment design discussion to understand the proposed constructor-argument evaluation semantics. Identify the language-specification entry point affected; done means the behavior and its type-safe result are defined consistently, with agreement on the design and corresponding specification coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100