Tensegritics / Tensegritics/ClojureDart

Top level variables are not emitted as `const`/`final`

Open
#347 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
1.6k
Forks
119
PR merge metrics
No merged PRs in 30d

Description

The ClojureDart documentation Consts and const opt-out section states that "ClojureDart maximally infers const expressions."

However, this is currently not the case for top level variables.

Current

ClojureDart
(ns const.example)

(def a 1)

(def b [1 2 3])
Dart
// BEGIN a
dc.dynamic a$v35=1;

// END a

// BEGIN b
dc.dynamic b$v35=(){
final lcoc_core.VectorNode arg$1=lcoc_core.$_EMPTY_VECTOR.root;
final dc.List<dc.dynamic> fl$1=(dc.List<dc.dynamic>.filled(3, 1, ));
(fl$1[1]=2);
(fl$1[2]=3);
return lcoc_core.PersistentVector(null, 3, 5, arg$1, fl$1, -1, );
}();

// END b

Expected

Dart
// BEGIN a
const dc.dynamic a$v35=1;

// END a

// BEGIN b
final dc.dynamic b$v35=(){
final lcoc_core.VectorNode arg$1=lcoc_core.$_EMPTY_VECTOR.root;
final dc.List<dc.dynamic> fl$1=(dc.List<dc.dynamic>.filled(3, 1, ));
(fl$1[1]=2);
(fl$1[2]=3);
return lcoc_core.PersistentVector(null, 3, 5, arg$1, fl$1, -1, );
}();

// END b

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Consts and const opt-out section in doc/README.md, then trace how top-level def forms are emitted into Dart. Compare the generated output for the examples with the expected const and final declarations; done means constant values use const and non-constant values use final.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure, dart
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.