Fork me on GitHub
#sci
<
2020-06-28
>
lread18:06:05

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.

borkdude18:06:39

> Here’s an interesting thing: rewrite-cljc automatically coerces Clojure to rewrite-cljc nodes.

borkdude18:06:45

how does that work?

borkdude18:06:58

and yeah, that metadata comes from edamame

borkdude18:06:15

and is used to produce error messages in the analyzer of sci

lread18:06:43

I’ll have to reboot my brain on how it all functions, been a while.

borkdude18:06:30

or maybe you could strip that metadata within sci yourself, just with walk and vary-meta

lread18:06:55

I suppose that would work in this specific case. I’ll play with that idea, thanks.

lread18:06:37

If we could clearly tell that the metadata belonged to sci (or edamame), a general solution could selectively strip it.

borkdude18:06:07

@lee Note that Clojure itself also puts metadata on things:

user=> (meta '(list 1 2 3))
{:line 1, :column 8}

borkdude18:06:33

The keys were :row and :col before but I aligned them with Clojure

lread18:06:41

hmm.. interesting… I’ll have to dig in and see how rewrite-cljc dealt with this fact.

borkdude18:06:55

Sci might put metadata on more things than Clojure. Maybe Clojure only puts them on lists.

borkdude18:06:03

Just remove it before you coerce the stuff

lread18:06:04

meta is also coercible in rewrite-cljc so not sure how I’d distinguish. I’ll poke around.

borkdude18:06:49

does it react to *print-meta*?

borkdude18:06:36

should it? 😉

lread18:06:27

Maybe? But I don’t see why it would yet.

borkdude18:06:52

maybe you can override the sci metadata with your own values so the test is the same in sci and clj?

borkdude18:06:44

That doesn't work:

$ bb "(meta ^{:line 666} '(list 1 2 3))"
{:line 1, :column 7, :end-line 1, :end-column 33}

lread18:06:41

You’ve given me some interesting ideas, I’ll explore.

lread18:06:37

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

lread18:06:41

thanks, as usual, for your help! simple_smile