dart-lang / dart-lang/language

class tear-off with extra parameters

Open
#3,208 3 comments 0 reactions 0 assignees View on GitHub
request
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

While pattern matching has been implemented in the dart language what about using them for function and class tear-off

```dart
class DefaultError {
final Object error;
final StackTrace stackTrace;
final void Function() refresh;

const DefaultError(this.error, this.stackTrace, {required this.refresh});
}

void throwError(void Function(Object error, StackTrace stackTrace) callback) {}

void main(List args) {
// Current
throwError((error, stackTrace) {
DefaultError("error", StackTrace.current, refresh: () {});
});

// Suggestion
throwError(DefaultError.new(refresh: () {}));
}
```
### The idea here is that
```
throwError(DefaultError.new(refresh: () {}));
```
by Passing the extra parameters after the ".new" or after function tear-off

Contributor guide

Open the contributing guide

Research direction

Start with the proposal and its two Dart examples in issue #3208; compare the current callback form with the suggested tear-off syntax and identify the extra-parameter semantics that require specification. Done would require a decided language design and corresponding specification work, but the issue names no files or tests.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.