ClojureDart
ClojureDart copied to clipboard
platform conditionals
Dart has conditional importing to deal with web vs native.
Clojure has conditional readers.
How do we expose Dart affordances and can we do it with conditional reading?
We can't use conditional reading because conditional reading will only pick one feature (out of web and native) while we must compile both to a single codebase.
Then it's going to be a special form.
(dart/sniff
dart:io (some native code)
dart:html (some web code))
could we lift these expressions to distinct files and emit conditional imports automatically?
We should also modify ns
to allow to specify :when
in a require.
See #128
Let's ponder about
(dart/sniff
dart:io (some native code)
dart:html (some web code))
My original idea was to have it replaced by some function call and the function being defined in a conditionally imported lib. However this approach is going to create weird cases when for example you have an await or a recur inside the expressions (because then they would apply to the extracted function).
My new idea is to have a new special in "dart sexp" (our representation of the subset of dart code we produce) too. Then we would just walk the top-level code in search of a dart/platform-case
and if found we would produce dart/platform-case
-free variants that we would dump in conditionally imported helper libs.