This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-08
Channels
- # announcements (6)
- # beginners (100)
- # calva (17)
- # cljs-dev (31)
- # cljsrn (2)
- # clojars (3)
- # clojure (137)
- # clojure-australia (1)
- # clojure-europe (41)
- # clojure-gamedev (3)
- # clojure-italy (1)
- # clojure-nl (3)
- # clojure-poland (16)
- # clojure-serbia (7)
- # clojure-taiwan (1)
- # clojure-uk (10)
- # clojurescript (10)
- # cursive (25)
- # data-oriented-programming (4)
- # datomic (26)
- # fulcro (39)
- # graalvm (6)
- # jobs (2)
- # jobs-discuss (2)
- # kaocha (19)
- # klipse (1)
- # leiningen (3)
- # lsp (18)
- # malli (21)
- # meander (26)
- # off-topic (29)
- # pathom (39)
- # polylith (3)
- # practicalli (2)
- # re-frame (11)
- # reitit (8)
- # rewrite-clj (7)
- # sci (11)
- # shadow-cljs (44)
- # sql (8)
- # tools-deps (32)
- # xtdb (3)
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
@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?I have a data file that is an edn map that looks something like
{:a [s1], :b [s1 s2]}
I only want to eval either the value of :a
or :b
. When I eval :a
, s2
is not available in the environment
So, my current approach is to slurp in the datafile, parse it as edn, and eval the value of :a
with sci
@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}
@markaddleman Fixed on master
Great. Thanks!
Yep. I'll check out master in about an hour