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 :) 


On Monday, April 29, 2013 4:44:13 PM UTC-4, Ben wrote:
>
> Because "1000N" is a complete expression, as you can verify with your REPL.
>
>
> On Mon, Apr 29, 2013 at 1:43 PM, noahlz <nzu...@gmail.com <javascript:>>wrote:
>
>> Understood, but what I was wondering is why the trailing parenthesis is 
>> discarded / not considered part of the "object" expression?
>>
>>
>> On Monday, April 29, 2013 4:32:49 PM UTC-4, Weber, Martin S wrote:
>>>
>>>
>>> user=> (doc read-string)
>>> -------------------------
>>> clojure.core/read-string
>>> ([s])
>>>   Reads *one* object from the string s
>>> nil
>>> (emphasis on *one* by me)
>>>
>>> one object from ":a(" = :a; ":a)" = :a; "( … " = fail; ")…" = fail. 
>>> (remember whitespace in front of a paren doesn't matter)
>>>
>>> Have fun.
>>>
>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com<javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> 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+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> 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