dart-lang / dart-lang/language

`final` local variables and static immutability are related via closures

Open
#160 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

I'm not sure what's the best place to record this is, so just opening an issue to point it out.

**tl;dr** `final` local variables and static immutability are related concerns via closures

The [static immutability proposal](https://github.com/dart-lang/language/blob/master/working/0125-static-immutability/feature-specification.md) introduces objects that are deeply immutable and can be shared across isolates. Top-level and static function tear-offs should be shareable too as they have no internal shared mutable state. In fact, you can already spawn an isolate from a top-level function reference today. The static immutability provides an opportunity to expand this capability by allowing _closures_ to be passed to other isolates along with immutable objects, perhaps as fields of those objects. In fact, a lot of Flutter widgets take closures as arguments, such as `onTap`. However, such closures must only close over deeply immutable `final` local variables.

It would make the developer experience of using shared closures more pleasant if the ergonomics of `final` variable was better. This is discussed in https://github.com/dart-lang/language/issues/136.

Contributor guide

Open the contributing guide

Research direction

Start with the static immutability proposal in working/0125-static-immutability/feature-specification.md, then read issue #136 about final-variable ergonomics. Trace how the proposal relates immutable closures, isolate sharing, and final locals; the issue does not define a concrete implementation or acceptance test, so done would require an agreed language-design scope.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.