ClojureDart
ClojureDart copied to clipboard
Top level variables are not emitted as `const`/`final`
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