Fork me on GitHub
#sci
<
2021-03-08
>
markaddleman20:03:51

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

borkdude21:03:47

@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?

markaddleman21:03:41

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

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

markaddleman21:03:43

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

markaddleman21:03:37

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

borkdude22:03:52

@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}

👍 3
markaddleman22:03:10

Great. Thanks!

borkdude22:03:36

Are you using deps.edn?

markaddleman22:03:33

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