This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-06
Channels
- # babashka-sci-dev (56)
- # beginners (13)
- # biff (3)
- # calva (24)
- # cider (2)
- # cljtogether (2)
- # clojure (38)
- # clojure-europe (6)
- # clojure-norway (2)
- # clojurescript (1)
- # cursive (5)
- # introduce-yourself (3)
- # pedestal (4)
- # polylith (5)
- # portal (11)
- # re-frame (7)
- # reitit (6)
- # shadow-cljs (12)
- # spacemacs (5)
- # sql (7)
- # tools-deps (1)
can sci take some code, expand all the macros in it, but not "run" it? As in only the evaluations needed to expand the macros are done, and then you have access to the AST before execution...
@retrogradeorbit I guess you could do something like this:
user=> (sci/eval-string "(defmacro dude [x] `[~x ~x]) (clojure.walk/macroexpand-all '(dude 1))")
[1 1]
and theres this: https://github.com/helins/wasm.cljc
is this madness? https://gist.github.com/retrogradeorbit/063f2874eb6155dfe781db9acf1cecad
@retrogradeorbit What problem are you trying to solve?
It reminds me of this: https://github.com/dundalek/liz It parses Clojure (using edamame) and generates zig code
Last time I was making wasm I was using C++ and then I got to the point where I wanted to implement something like this
and my C++ friend when I asked him just said, "nah you're stuffed. write it all out by hand"
why not generate the code once using a macro or whatever templating thing and then inline that code
Maybe using Common Lisp for this would also make sense, given that you can get quite close performance to C using it and there may be WASM bindings for it
one approach is to build up wasm from the ground up. wasm has a format wast that is s-expr. It's spec is very lispy already. You would deal directly in the wasm types and map clj straight to wasm ast. This is somewhat like helins/wasm.cljc does
the other is to transpile to another supported lang, and then compile that down to wasm
the first is probably more elegant, but the advantage of the second is the existing toolchains (like emscripten) work magic on the C code
you've got your advanced optimiser already done, and whats really great is you can bring across your stdlib malloc/free heap allocator into the wasm code to manage the wasm "linear memory"
ie, you can malloc and free in your wasm code, then access that data from the JS side. Its shared.