Heya! I’m playing with an experiment to to interpret rewrite-cljc tests via natively compile sci+rewrite-cljc src (thanks for the idea @borkdude). Here’s an interesting thing: rewrite-cljc automatically coerces Clojure to rewrite-cljc nodes. I think sci is sometimes including metadata on args from read time? Maybe? For example, on call (rewrite-cljc.zip/replace zloc [5 6 7])
, arg [5 6 7]
is adorned with sci metadata {:line 16 :column 35 :end-line 16 :end-column 42}
which rewrite-cljc sees as metadata and converts it to to meta node instead of a vector node.
> Here’s an interesting thing: rewrite-cljc automatically coerces Clojure to rewrite-cljc nodes.
how does that work?
and yeah, that metadata comes from edamame
and is used to produce error messages in the analyzer of sci
the coercing magic happens in https://github.com/lread/rewrite-cljc-playground/blob/master/src/rewrite_cljc/node/coercer.cljc
I’ll have to reboot my brain on how it all functions, been a while.
or maybe you could strip that metadata within sci yourself, just with walk and vary-meta
I suppose that would work in this specific case. I’ll play with that idea, thanks.
If we could clearly tell that the metadata belonged to sci (or edamame), a general solution could selectively strip it.
@lee Note that Clojure itself also puts metadata on things:
user=> (meta '(list 1 2 3))
{:line 1, :column 8}
The keys were :row
and :col
before but I aligned them with Clojure
hmm.. interesting… I’ll have to dig in and see how rewrite-cljc dealt with this fact.
Sci might put metadata on more things than Clojure. Maybe Clojure only puts them on lists.
Just remove it before you coerce the stuff
meta is also coercible in rewrite-cljc so not sure how I’d distinguish. I’ll poke around.
does it react to *print-meta*
?
nope
should it? 😉
Maybe? But I don’t see why it would yet.
maybe you can override the sci metadata with your own values so the test is the same in sci and clj?
That doesn't work:
$ bb "(meta ^{:line 666} '(list 1 2 3))"
{:line 1, :column 7, :end-line 1, :end-column 33}
You’ve given me some interesting ideas, I’ll explore.
You’ve also piqued my curiosity about what Clojure itself adds:
user=> (meta '(1 2 3))
{:line 1, :column 8}
user=> (meta '[1 2 3])
nil
thanks, as usual, for your help! :simple_smile: