sci

awb99 2022-05-20T22:08:07.488069Z

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

borkdude 2022-05-21T09:12:35.449979Z

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

borkdude 2022-05-21T10:03:40.647759Z

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

awb99 2022-05-20T22:14:23.314549Z

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

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

borkdude 2022-05-21T09:11:57.426529Z

Do something like this:

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

(sci/copy-var info tns)

awb99 2022-05-20T22:56:57.515489Z

(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.

borkdude 2022-05-21T06:02:31.757789Z

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

borkdude 2022-05-21T09:10:56.324949Z

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

awb99 2022-05-20T23:43:15.883469Z

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 🙂

Bob B 2022-05-21T00:32:08.878419Z

https://github.com/babashka/sci/blob/master/doc/async.md#lazy-loading-a-namespace might be sort of along the lines of what you're looking for

awb99 2022-05-21T03:03:47.588859Z

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

borkdude 2022-05-21T06:01:15.633799Z

Yes, I will add require next, issue welcome

awb99 2022-05-23T00:15:23.087899Z

@borkdude Thank you so much!!

awb99 2022-05-23T00:16:57.993769Z

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

awb99 2022-05-23T00:17:14.722779Z

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

borkdude 2022-05-23T05:57:33.882529Z

Example please

awb99 2022-05-23T06:10:39.306929Z

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

awb99 2022-05-23T06:10:53.910319Z

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

awb99 2022-05-23T06:11:08.097269Z

because sync evals will always use the sync require,

awb99 2022-05-23T06:11:20.034919Z

and this will not be able to lazy load dependencies.

borkdude 2022-05-23T06:11:50.317729Z

Can you please give a full standalone example

borkdude 2022-05-23T06:11:55.264029Z

As code

borkdude 2022-05-23T06:12:58.186889Z

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

borkdude 2022-05-23T06:13:11.233369Z

GitHub issue welcome

awb99 2022-05-23T06:33:37.280249Z

I am trying to understand the implications:

awb99 2022-05-23T06:34:05.564609Z

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

awb99 2022-05-23T06:34:19.754709Z

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

awb99 2022-05-23T06:34:58.950229Z

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.

awb99 2022-05-23T06:35:13.861919Z

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

awb99 2022-05-23T06:36:19.962049Z

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

awb99 2022-05-23T06:36:31.187149Z

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

awb99 2022-05-23T06:36:44.258519Z

I think I got this right now 🙂

awb99 2022-05-23T06:37:07.004499Z

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

borkdude 2022-05-23T07:16:54.922019Z

resolve always only resolves the namespaces you have already loaded

borkdude 2022-05-23T07:17:02.349629Z

that is the same as in Clojure

awb99 2022-05-23T08:24:25.309519Z

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

borkdude 2022-05-21T09:10:30.338529Z

@hoertlehner Here is require: https://github.com/babashka/sci/blob/master/doc/async.md#require