sci

https://github.com/babashka/SCI - also see #babashka and #nbb
markaddleman 2021-03-08T20:57:51.000400Z

I think there is an inconsistency handling metadata. The first eval-form returns {:default true} while the second returns nil. Interestingly, if I replace v with a constant value, it works as expected

borkdude 2021-03-08T21:54:47.003100Z

@markaddleman The most common use case is that the form you are evaluating comes from the parser:

user=> (def ctx (sci/init {:namespaces {'user {'v 1}}}))
#'user/ctx
user=> (meta (sci/eval-form ctx '^:foo {:x v}))
nil
user=> (def reader (sci/reader "^:foo {:x v}"))
#'user/reader
user=> (def v (sci/parse-next ctx reader))
#'user/v
user=> (meta v)
{:foo true}
What is your use case of doing it like the above?

markaddleman 2021-03-08T21:56:41.003200Z

I have a data file that is an edn map that looks something like

{:a [s1], :b [s1 s2]}

markaddleman 2021-03-08T21:58:43.003400Z

I only want to eval either the value of :a or :b . When I eval :a , s2 is not available in the environment

markaddleman 2021-03-08T21:59:37.003600Z

So, my current approach is to slurp in the datafile, parse it as edn, and eval the value of :a with sci

borkdude 2021-03-08T22:03:52.004500Z

@markaddleman I was able to reproduce your case like this:

user=> (meta (sci/eval-string "^:foo {:x (+ 1 2 3)}"))
nil
user=> (meta (load-string "^:foo {:x (+ 1 2 3)}"))
{:foo true}

1👍
borkdude 2021-03-08T22:05:36.005700Z

https://github.com/borkdude/sci/issues/546

borkdude 2021-03-08T22:25:01.006100Z

@markaddleman Fixed on master

markaddleman 2021-03-08T22:25:10.006400Z

Great. Thanks!

borkdude 2021-03-08T22:28:36.006600Z

Are you using deps.edn?

markaddleman 2021-03-08T22:31:33.007100Z

Yep. I'll check out master in about an hour