sci

borkdude 2022-03-03T17:04:25.087159Z

@baibhavbista I'm adding ready to be used configs to this repo: https://github.com/babashka/sci-configs#funcoolpromesa So all you have to do is include that project and then use the config.

❤️ 1
borkdude 2022-03-04T10:27:43.211239Z

Thanks, fixed

baibhavbista 2022-03-04T02:47:21.444469Z

thenks @borkdude 😄

baibhavbista 2022-03-04T02:47:58.015899Z

btw there seems to be a typo.. the namespace is reagent for the js-interop one too 😅

baibhavbista 2022-03-04T02:48:21.827169Z

borkdude 2022-03-03T17:48:06.144099Z

baibhavbista 2022-03-03T07:32:21.531359Z

How do I get macros from other namespaces working in sci in cljs? I found the following script to copy a namespace to sci https://github.com/babashka/sci#copy-a-namespace

(reduce (fn [ns-map [var-name var]]
            (let [m (meta var)
                  no-doc (:no-doc m)
                  doc (:doc m)
                  arglists (:arglists m)]
              (if no-doc ns-map
                  (assoc ns-map var-name
                         (sci/new-var (symbol var-name) @var
                                      (cond-> {:ns fns
                                               :name (:name m)}
                                        (:macro m) (assoc :macro true)
                                        doc (assoc :doc doc)
                                        arglists (assoc :arglists arglists)))))))
          {}
          (ns-publics 'foobar))
The bit with (:macro/m) makes me think that it should transfer macros as well. However, doing (ns-publics 'cljs.core.async) does not seem to return the macros like go, go-loop. Am I missing something?

baibhavbista 2022-03-03T08:05:30.459859Z

Ohh okay

baibhavbista 2022-03-03T08:05:54.012229Z

majority of promesa's stuff (like the let) is also implemented as macros, no?

borkdude 2022-03-03T08:06:27.312909Z

Not the majority, but quite a few: https://github.com/babashka/nbb/blob/main/src/nbb/promesa.cljs

baibhavbista 2022-03-03T08:09:10.331919Z

ohhh you have to write kind of a wrapper macro to get it to work?

baibhavbista 2022-03-03T08:10:01.786489Z

However, you have already done the work for almost everything I would want...I can just copy your code. Thanks a ton @borkdude !!

borkdude 2022-03-03T08:10:22.763139Z

Yeah please go ahead and copy it :)

❤️ 1
baibhavbista 2022-03-03T08:53:55.675459Z

It works great, thank you 😁

🎉 1
baibhavbista 2022-03-03T07:33:10.809209Z

I'm on org.babashka/sci {:mvn/version "0.2.8"}

baibhavbista 2022-03-03T07:34:32.907539Z

I'm trying to get cljs.core.async and cljs.core.async.interop to work on sci. Is that possible?

borkdude 2022-03-03T07:57:14.570739Z

core.async doesn't even work in self-hosted CLJS.

borkdude 2022-03-03T07:57:36.444889Z

I recommend using promesa for async programming in CLJS. See #nbb which has a config for that.

borkdude 2022-03-03T07:59:00.000749Z

In general, you can include a macro like this:

(defn ^:macro foo [_ _] `(do (+ 1 2 3)))

(def sci-ns (sci/create-ns 'foobar))
{'foo (sci/copy-var foo sci-ns)}

borkdude 2022-03-03T07:59:24.465289Z

Usually you have to re-implement the macro to be available in CLJS at runtime as a function, like that.