Fork me on GitHub
#rewrite-clj
<
2020-11-27
>
lread22:11:38

Welcome @dave.dixon! 👋

3
sparkofreason22:11:47

Why does pr-str on a node yield something like <token: foo> rather than something which can be consumed by read-string? Not a big deal, but it can be confusing for tooling (like the Flow Storm Debugger) that seem to rely on pr-str for sending results.

sparkofreason22:11:45

By comparison, the result I get from the socket REPL using clover in VSCode looks like:

#rewrite_cljc.node.token.TokenNode {:value foo, :string-value "foo"}

lread23:11:49

I think @UG1C3AD5Z might have asked about that too, many moons ago. I think @UG1C3AD5Z was trying out REBL and details were maybe being hidden by this behaviour.

borkdude23:11:28

The VSCode rulest is what you get when printing in a defrecord. It seems rewrite-clj defines print-methods for its types here: https://github.com/lread/rewrite-cljc-playground/blob/cc8ded71f1ca056d4851f4664754e0e004e985ad/src/rewrite_cljc/node/protocols.cljc#L100 Maybe those print-methods can be removed, not sure. It doesn't seem to be a good idea to define a print-method which prints something which cannot be read.

sparkofreason23:11:43

Right. Or if there's something useful about the <> representation, maybe have another method that outputs that. Probably not a priority right now, but might be nice to clean up at some point.

lread23:11:50

I’m not sure why the original author of rewrite-clj made that decision, and he has moved on to other things and not available. My original position was to avoid all unnecessary breaking changes when migrating to rewrite-cljc, but am now revisiting for things that just don’t make good sense.

borkdude23:11:15

> By default, pr and prn print in a way that objects can be read by the reader It seems to go against the spirit of pr/prn

borkdude23:11:46

Emitting something with a reader tag is probably a better way and then define data readers

borkdude23:11:02

#rewrite-clj/token[foo]

3
sparkofreason23:11:30

I wonder if it was just to support the use of clojure.test, and save some keystrokes when defining tests. It's the only obvious place I find the <> notation used.

sparkofreason23:11:55

The reader-tag approach seems like a good alternative for that case.

lread23:11:07

I do have a set of popular projects that use rewrite-clj that I have tested against in the past. I could see if any of them are relying on this and in what way. I’ll raise an issue in rewrite-cljc to have a look at this.

lread23:11:24

Thanks for bringing it up @dave.dixon!

3
lread23:11:27

Huh! I guess I’d better get this sucker up on clojars sometime, huh? simple_smile

lread23:11:33

I like and use antq, I now use it instead of depot.

lread23:11:01

BTW @borkdude, I am working my way through an implementation of namespaced element support for rewrite-cljc - much of it as per our discussions. I think it is going pretty well.