This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-10
Channels
- # announcements (5)
- # aws (18)
- # babashka (1)
- # beginners (81)
- # calva (7)
- # chlorine-clover (1)
- # cider (5)
- # cljs-dev (8)
- # clojure (125)
- # clojure-dev (1)
- # clojure-europe (31)
- # clojure-italy (3)
- # clojure-nl (2)
- # clojure-norway (1)
- # clojure-spec (5)
- # clojure-sweden (1)
- # clojure-uk (31)
- # clojurescript (85)
- # code-reviews (1)
- # core-async (17)
- # cursive (39)
- # datomic (16)
- # emacs (1)
- # fulcro (6)
- # java (16)
- # kaocha (2)
- # luminus (4)
- # malli (2)
- # off-topic (65)
- # pathom (3)
- # re-frame (11)
- # reagent (5)
- # remote-jobs (1)
- # rum (5)
- # sci (10)
- # shadow-cljs (24)
- # spacemacs (4)
- # test-check (3)
- # tools-deps (22)
- # xtdb (15)
Heya @borkdude! I’m assuming https://github.com/borkdude/sci/blob/88bb9c542fd1d404fd3bb25eb556e86668ef30de/src/sci/impl/interpreter.cljc#L587? Reason I ask is because I am stripping sci positional metadata when calling rewrite-cljc API but this adds an unwanted :line
metadata back in for me.
In my unit tests it comes out as :line nil
which would be easy to address in sci, but then when I tried to distill the issue I see :line 1
which currently has me confused.
Here’s my little distillation attempt:
(require '[clojure.walk :as walk])
(require '[sci.core :as sci])
;; my utility fns to remove sci positional metadata
(defn remove-sci-meta [expr]
(walk/prewalk (fn [e]
(if-let [orig (meta e)]
(let [new (dissoc orig :line :column :end-line :end-column)
new (if (seq new) new nil)]
(with-meta e new))
e))
expr))
(defn fn-without-sci-meta-on-args
"Wrap `target-fn` removing all sci positional metadata from call arguments."
[ target-fn ]
(fn [ & fn-args ]
(apply target-fn (map #(remove-sci-meta %) fn-args))))
;; a dummy api fn
(defn my-api-fn [a] a)
;; calling this under Clojure
(meta (my-api-fn ^:hi [1 2 3]))
;; => {:hi true}
;; calling same fn bound to sci
(sci/eval-string "(meta (my-api-fn ^:hi [1 2 3]))" {:bindings {'my-api-fn my-api-fn}})
;; => {:line 1, :column 19, :end-line 1, :end-column 31, :hi true}
;; calling same fn bound to sci with metadata stripped from args
(sci/eval-string "(meta (my-api-fn ^:hi [1 2 3]))" {:bindings {'my-api-fn (fn-without-sci-meta-on-args my-api-fn)}})
;; => {:hi true, :line 1}
It's a little bit too late for me to dive into this now, but hopefully I'll have time next week. Tomorrow I have to prepare a presentation about babashka+sci for Clojure NYC 🙂
If you can meanwhile distill this in an issue, and describe the exact problem you are encountering, that would probably be good
Thanks @borkdude! I shall continue to tinker. Have a great presentation! Looking forward to the video!
Maybe it would be interesting to see what happens if you leave out the "fixing" of the metadata, see what tests will fail