I have notice a discrepancy in how comments are read between cljs.tools.reader/read-string and cljs.reader/read-string.
In cljs.reader, as shown here no exception is thrown but nil is returned, concretely ignoring the comment.
Conversely, the following throws:
(r/read-string {:read-cond :allow :features #{:cljs ;; comment) ;;+> EOF
In my opinion the cljs.reader is the correct one and cljs.tools.reader should be patched, but of course there might be a reason I ignore to throw an exception.
This is consistent with how the clojure reader works, and the correct behaviour.
Reading a comment is not the same as reading nil
Can you expand on this a bit? The reader should ignore comments, so it is like the reader is actually reading nothing (therefore nil). Maybe I am missing?
The reader must return the object it read. If there's nothing to read, an EOF exception signales that the stream terminated before it could find an object to read. Otherwise reading nil and reading nothing would mean different things in different contexts
Thanks, it was just for curiosity, of course a lot of clever people have already thought about this. I am then a bit surprised by the different behaviour in cljs.reader but this is another story.