On Mon, Apr 29, 2013 at 1:57 PM, noahlz <nzuc...@gmail.com> wrote:

> Ok. The parser reads a single complete expression and discards the rest.
> It understands that once it has hit a new character that represents the
> beginning of a new expression, it doesn't care.
>
> I suppose I thought the parser would raise an error on detecting an
> unmatched parenthesis, but that's wrong.
>
> Interestingly, when I try this at the repl (1.5.1) it errors as I expected
> (probably why I expected it in the first place):
>
> user=> 1000N)
> 1000N
>
> RuntimeException Unmatched delimiter: )
> clojure.lang.Util.runtimeException (Util.java:219)
>
>
> Of course, the repl doesn't use "read-string." So, the next step in my
> journey is to investigate the source of clojure.main. But - someone wants
> to take the opportunity to ruin the surprise for me - with a more detailed
> explanation / theory discussion - I'm open to it :)
>

But notice that this *also* returns 1000N, first. So the cases aren't that
different: it managed to read a complete expression, and evaluated it. Then
it tried to read *another* expression from the unconsumed input. The
difference is only that read-string doesn't attempt to exhaust its input
argument.

-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to