Welcome @dave.dixon! 👋
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.
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"}
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.
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.
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.
> 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
Emitting something with a reader tag is probably a better way and then define data readers
#rewrite-clj/token[foo]
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.
The reader-tag approach seems like a good alternative for that case.
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.
Thanks for bringing it up @dave.dixon!
@lee Just saw this via #announcements : https://github.com/liquidz/antq/blob/222addc76766319f2f6fe73491abc53c6f8d2b0a/deps.edn#L11
Huh! I guess I’d better get this sucker up on clojars sometime, huh? :simple_smile:
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.
I like and use antq, I now use it instead of depot.