sci

https://github.com/babashka/SCI - also see #babashka and #nbb
lread 2020-06-28T18:26:05.049300Z

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.

borkdude 2020-06-28T18:27:39.049500Z

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

borkdude 2020-06-28T18:27:45.049700Z

how does that work?

borkdude 2020-06-28T18:27:58.050Z

and yeah, that metadata comes from edamame

borkdude 2020-06-28T18:28:15.050400Z

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

lread 2020-06-28T18:30:43.053400Z

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

borkdude 2020-06-28T18:31:30.053900Z

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

lread 2020-06-28T18:36:55.055600Z

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

lread 2020-06-28T18:39:37.057Z

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

borkdude 2020-06-28T18:41:07.057400Z

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

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

borkdude 2020-06-28T18:41:33.057900Z

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

lread 2020-06-28T18:42:41.058800Z

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

borkdude 2020-06-28T18:43:55.059600Z

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

borkdude 2020-06-28T18:45:03.060Z

Just remove it before you coerce the stuff

lread 2020-06-28T18:48:04.062200Z

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

borkdude 2020-06-28T18:48:49.062800Z

does it react to *print-meta*?

lread 2020-06-28T18:49:58.063100Z

nope

borkdude 2020-06-28T18:50:36.063300Z

should it? 😉

lread 2020-06-28T18:51:27.064300Z

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

borkdude 2020-06-28T18:51:52.064800Z

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

borkdude 2020-06-28T18:52:44.065200Z

That doesn't work:

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

lread 2020-06-28T18:53:41.066200Z

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

lread 2020-06-28T18:54:37.066700Z

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

lread 2020-06-28T18:56:41.067300Z

thanks, as usual, for your help! :simple_smile: