dart-lang / dart-lang/language
Abbreviated formal parameter lists
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
Setting out from the discussion 'Constructor inheritance and named arguments' (started by Mouad Debbar) on dart-language-discuss@google.com, there is a need for abbreviation of formal parameter lists in the cases where they are determined by the context. In particular, there is a lot of redundancy in the case where a long list of parameters with verbose types are just passed on from a constructor to another constructor in a superinitialization, and similar situations arise with forwarding functions:
```dart
// Example from Mouad Debbar.
class Base {
final int foo;
final String bar;
final bool baz;
Base({this.foo, this.bar, this.baz});
}
class Sub1 extends Base {
final List myFoo;
Sub1({this.myFoo, int foo, String bar, bool baz}): super(foo: foo, bar: bar, baz: baz);
}
class Sub2 extends Sub1 {
final Map myBar;
Sub2({this.myBar, List myFoo, int foo, String bar, bool baz}):
super(myFoo: myFoo, foo: foo, bar: bar, baz: baz);
}
```
Samual Rawlins added the following concerns: It is at times necessary to import additional libraries, just so we can talk about the redundant elements in such formal parameter lists and in their use for a forwarding call, and we may also have to repeat some default values (and get them right).
Contributor guide
Assessment
This issue has not been assessed yet.