dart-lang / dart-lang/language
[Feature Request] Add "placeholders"
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
## Use case
I found out that I'm often creating a variable for clarification instead of writing it in one line.
Example (pseudo code):
**Optimal code for humans**
```flutter
Location location = await Getter.getLocation();
Speed speed = await Getter.getSpeed();
Resul result = await Result(
location: location.
speed: speed,
);
```
**Optimal code for efficiency**
```flutter
Result result = await Result(
location: await Getter.getLocation(),
speed: await Getter.getSpeed(),
);
```
While the given example is admittedly quite readable, there are often cases where it's easier to create a variable for clarification.
## Proposal
It would be quite nice if you could use named "placeholders" that replace code parts during compilation.
Example:
```flutter
location: await Getter.getLocation();
speed: await Getter.getSpeed();
Resul result = await Result(
location: location.
speed: speed,
);
```
After compilation this code will result in:
```flutter
Result result = await Result(
location: await Getter.getLocation(),
speed: await Getter.getSpeed(),
);
```
## Advantages to the current Flutter version
You don't have to create variables just for better DX (Developer Experience). This will primarily lead to less memory usage, which means there will be more memory available, which means faster, better and more efficient apps! 😆
Contributor guide
Research direction
No files, tests, or entry points are named. Start by reviewing the proposed placeholder syntax and its compilation behavior, then determine the language semantics and implementation scope needed to make the examples valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100