rewrite-clj

https://github.com/clj-commons/rewrite-clj
lread 2020-11-27T22:22:38.131400Z

Welcome @dave.dixon! 👋

1
sparkofreason 2020-11-27T22:57:47.133100Z

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.

sparkofreason 2020-11-27T22:59:45.133200Z

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"}

lread 2020-11-27T23:03:49.133400Z

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

borkdude 2020-11-27T23:08:28.133700Z

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.

sparkofreason 2020-11-27T23:10:43.134100Z

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.

lread 2020-11-27T23:10:50.134300Z

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.

borkdude 2020-11-27T23:11:15.134500Z

> 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

borkdude 2020-11-27T23:11:46.134700Z

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

borkdude 2020-11-27T23:12:02.134900Z

#rewrite-clj/token[foo]

1
sparkofreason 2020-11-27T23:12:30.135200Z

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.

sparkofreason 2020-11-27T23:12:55.135400Z

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

lread 2020-11-27T23:13:07.135600Z

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.

lread 2020-11-27T23:13:24.135900Z

Thanks for bringing it up @dave.dixon!

1
borkdude 2020-11-27T23:23:48.136700Z

@lee Just saw this via #announcements : https://github.com/liquidz/antq/blob/222addc76766319f2f6fe73491abc53c6f8d2b0a/deps.edn#L11

lread 2020-11-27T23:34:27.138Z

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

lread 2020-11-27T23:37:01.139700Z

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.

lread 2020-11-27T23:39:33.139800Z

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