(Disclaimer: I post this aware that read-string is considered dangerous for
untrusted code and having starred tools.reader)
I was writing some code using read-string and encountered the following
(somewhat odd?) behavior:
Clojure 1.5.1
user=> (read-string "1000N(")
1000N
user=> (read-string "1000N)")
1000N
user=> (read-string "(1000N")
RuntimeException EOF while reading clojure.lang.Util.runtimeException
(Util.java:219)
user=> (read-string ")1000N")
RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException
(Util.java:219)
So if the string ends with an unmatched ) or (, the preceding value gets
returned and the unmatched character discarded. But if the string starts
with an unmatched parens - EOF (as expected). I was a little surprised as I
expected the first to cases to throw some kind of RuntimeException.
What is the explanation for this behavior if any, and where can I go / read
more about the underlying theory of "correctly" handling this case? I'm
aware that lexical parsing is a big topic - just wondering what the ruling
was here (if any) and looking for a jumping off point into further
readings. Also if this was discussed elsewhere (searching "read-string
unmatched paren" yielded nothing).
Thanks!
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.