dart-lang / dart-lang/language

Partial evaluation in Dart

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

Description

`const` in Dart is only a halfway step to partial evaluation. There are a lot of things I have to compute in my Flutter app on startup that are not `const` according to Dart, but they will deterministically always return exactly the same result (e.g. a color table that is generated from some fixed number of entries in a `const` array that is provided in the source code). Having to pre-generate this sort of thing using a separate program, then incorporating it as a `const` table, is a pain.

Partial evaluation is complex, but Dart would benefit greatly from it. The user could indicate a CPU budget to the compiler for how much time to spend in partial evaluation, and/or parts of the program that should or should not be partially evaluated could be marked by the user using an annotation.

A major benefit of adding proper partial evaluation to the language is that type resolution becomes just another computation that is partially evaluated by the compiler. `dynamic` is the type of anything that cannot be partially evaluated, because the type quite literally depends upon some input, dynamically.

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Start by reviewing Dart's existing const evaluation and language-change process, then determine the scope and design needed for partial evaluation, including compiler budget controls and annotations; done would require an agreed language proposal rather than a localized code change.

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
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.