Fork me on GitHub
#sci
<
2022-05-20
>
awb9922:05:07

https://clojars.org/org.babashka/sci.impl.types -> is there a git repo for that somewhere?

borkdude09:05:35

Everything that contain .impl in the name should be considered private and may change at any time

borkdude10:05:40

Tell me what you need and we can try to make it a public API

awb9922:05:23

timbre logging: how difficult is it to convert a macro like that:

(defmacro info               [& args] `(log! :info   :p ~args ~{:?line (fline &form)}))

borkdude09:05:57

Do something like this:

(defn ^:macro info [&form _ & args]
  `(log! :info   :p ~args ~{:?line (fline &form)}))

(sci/copy-var info tns)

awb9922:05:57

(sci/binding [sci/out *out*] ;; this enables println etc.
     (scia/eval-string* ctx-repl code))
when I do this and I eval "(println 343)" I get this error message: "Attempting to call unbound fn: #'clojure.core/print-fn" It is weird, because I use sci in clojurescript.

borkdude06:05:31

Use sci/alter-var-root. Binding resets the var too early because async

borkdude09:05:56

(sci/alter-var-root sci/print-fn (constantly *print-fn*))

awb9923:05:15

I found a missing feature for async compile: async require. A require can also need to load a module asyncronous. This is helpful if there are reagent functions that vizualise something. And they will be in a lazy loaded module 🙂

awb9903:05:47

Thanks @U013JFLRFS8 I am using exactly that. But this only does compilation. I need also a require function that is async 🙂

borkdude06:05:15

Yes, I will add require next, issue welcome

awb9900:05:23

@U04V15CAJ Thank you so much!!

awb9900:05:57

I guess what it means really, is that there is EITHER a async version, OR a sync version.

awb9900:05:14

Or is it still possible to do sync evals, but unter the hood it is using async require?

borkdude05:05:33

Example please

awb9906:05:39

so if I want to load modules via the async loader,

awb9906:05:53

I guess that I have to remove the sync eval from sci

awb9906:05:08

because sync evals will always use the sync require,

awb9906:05:20

and this will not be able to lazy load dependencies.

borkdude06:05:50

Can you please give a full standalone example

borkdude06:05:58

I think there might be a solution but it depends on your exact example

borkdude06:05:11

GitHub issue welcome

awb9906:05:37

I am trying to understand the implications:

awb9906:05:05

So resolve will only depend on the state of the sci-context. So it means if i just call resolve,

awb9906:05:19

it will NOT give me something that is in a lazy namespace.

awb9906:05:58

So what I will need to do, if I resolve something, then there are situations where I might want to require the namespace of the resolve variable first.

awb9906:05:13

And since that resolve is via a promise, I need to await that promise.

awb9906:05:19

So in other words, it is perfectly fine that resolve is always synchronous,

awb9906:05:31

but depending on the usecase I might have to require (async) first.

awb9906:05:44

I think I got this right now 🙂

awb9906:05:07

But I will have to re-think it again, as it is pretty esential when one uses async compilation and requires.

borkdude07:05:54

resolve always only resolves the namespaces you have already loaded

borkdude07:05:02

that is the same as in Clojure

awb9908:05:25

perfect! then I know how I have to do it! no bugon your side 🙂