Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform conditionals #286

Open
cgrand opened this issue Nov 16, 2023 · 3 comments
Open

platform conditionals #286

cgrand opened this issue Nov 16, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@cgrand
Copy link
Contributor

cgrand commented Nov 16, 2023

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?

@cgrand cgrand added the enhancement New feature or request label Nov 16, 2023
@cgrand
Copy link
Contributor Author

cgrand commented Nov 16, 2023

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.

@cgrand cgrand changed the title platforms platforms conditionals Nov 16, 2023
@cgrand
Copy link
Contributor Author

cgrand commented Nov 16, 2023

See #128

@cgrand cgrand changed the title platforms conditionals platform conditionals Nov 16, 2023
@cgrand
Copy link
Contributor Author

cgrand commented Nov 16, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant