sci

Ingy döt Net 2023-11-23T22:22:46.509089Z

Anyone know if there's a way to get time to work in SCI?

borkdude 2023-11-24T11:08:33.975419Z

done 0.8.41 available

Ingy döt Net 2023-11-24T17:05:36.758219Z

So I'm using the new SCI release with time support

$ ys -pe '.*sci-version*'
{:major 0, :minor 8, :incremental 41}
but it doesn't seem to work for me:
$ bb -e '(time 123)'
"Elapsed time: 0.013047 msecs"
123
$ ys -pe '(time 123)'
Exception in thread "main" java.lang.Exception: Error: clojure.lang.ExceptionInfo: Could not resolve symbol: java.lang.System {:type :sci/error, :line 1, :column 1, :file "NO_SOURCE_PATH", :phase "analysis"}
        at yamlscript.cli$die.invokeStatic(cli.clj:50)
        at yamlscript.cli$do_run.invokeStatic(cli.clj:230)
        at yamlscript.cli$_main.invokeStatic(cli.clj:375)
        at yamlscript.cli$_main.doInvoke(cli.clj:349)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at yamlscript.cli.main(Unknown Source)
        at java.base@21.0.1/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
I have a feeling it's because time is a macro and I'm setting it up wrong in the sci context: https://github.com/yaml/yamlscript/blob/main/core/src/yamlscript/runtime.clj#L51-L62

borkdude 2023-11-24T17:07:18.645879Z

I think this is because you have copied bb's previous macro and are not using the one from SCI.

user=> (sci/binding [sci/out *out*] (sci/eval-string "(time 1)"))
"Elapsed time: 0.007292 msecs"
1

Ingy döt Net 2023-11-24T17:08:52.718079Z

I didn't copy anything from bb whatsoever. I was just showing the bb command works as I expected the ys command to work.

borkdude 2023-11-24T17:09:38.429949Z

behold what I typed in the REPL above. this shows that the time macro works. I think you have added something manually to {:namespaces ...} that overrides time

borkdude 2023-11-24T17:10:54.976859Z

is your project public?

Ingy döt Net 2023-11-24T17:10:57.721369Z

I think so too. Behold the url I posted above: https://github.com/yaml/yamlscript/blob/main/core/src/yamlscript/runtime.clj#L51-L62 😉

Ingy döt Net 2023-11-24T17:11:15.905179Z

of course 🙂

borkdude 2023-11-24T17:11:20.022589Z

:) yeah so remove the 'time thing

Ingy döt Net 2023-11-24T17:11:47.382599Z

ah right

borkdude 2023-11-24T17:11:48.838929Z

since it is now built into SCI you don't need that

Ingy döt Net 2023-11-24T17:12:00.193299Z

yeah, derp...

Ingy döt Net 2023-11-24T17:16:44.814809Z

$ ys -pe '(time 123)'
"Elapsed time: 0.001493 msecs"
123
Thank you!

borkdude 2023-11-24T17:19:04.910719Z

Awesome!

borkdude 2023-11-23T22:23:14.913119Z

Actually I think that's already in SCI on master

Ingy döt Net 2023-11-23T22:27:01.638059Z

Hmm, so not released? I'm not sure how to use stuff from git. But I guess I can wait 🙂

borkdude 2023-11-23T22:27:15.938509Z

are you using clj or lein?

Ingy döt Net 2023-11-23T22:27:22.922129Z

lein

borkdude 2023-11-23T22:29:17.383729Z

you can just copy over that configuration as well and add it to your SCI config in clojure.core. that's what I had in bb initially before I moved it to SCI: https://github.com/babashka/babashka/commit/838608647a080d7c940d92032318756b703314d4 but I can make a new release tomorrow as well

Ingy döt Net 2023-11-23T22:31:21.998989Z

OK I'll wait. I just made a list of things available in clojure and in sci and diffed them and looked for things I'd want and noticed time. Thanks in advance for the release 🙂

👍 1
Ingy döt Net 2023-11-23T22:40:44.926909Z

Also a bonus that destructure will be released

👍 1