Understanding unmatched parenthesis in read-string

2013-04-29 Thread noahlz
(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

Re: Understanding unmatched parenthesis in read-string

2013-04-29 Thread Weber, Martin S
...@gmail.commailto:nzuc...@gmail.com Reply-To: Clojure clojure@googlegroups.commailto:clojure@googlegroups.com Date: Monday, April 29, 2013 16:26 To: Clojure clojure@googlegroups.commailto:clojure@googlegroups.com Subject: Understanding unmatched parenthesis in read-string (Disclaimer: I post

Re: Understanding unmatched parenthesis in read-string

2013-04-29 Thread noahlz
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

Re: Understanding unmatched parenthesis in read-string

2013-04-29 Thread Ben Wolfson
Because 1000N is a complete expression, as you can verify with your REPL. On Mon, Apr 29, 2013 at 1:43 PM, noahlz nzuc...@gmail.com 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,

Re: Understanding unmatched parenthesis in read-string

2013-04-29 Thread noahlz
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

Re: Understanding unmatched parenthesis in read-string

2013-04-29 Thread Ben Wolfson
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

Re: Understanding unmatched parenthesis in read-string

2013-04-29 Thread Cedric Greevey
On Mon, Apr 29, 2013 at 5:02 PM, Ben Wolfson wolf...@gmail.com wrote: 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

Re: Understanding unmatched parenthesis in read-string

2013-04-29 Thread noahlz
On Monday, April 29, 2013 6:07:01 PM UTC-4, Cedric Greevey wrote: If you want to exhaust read-string's input argument, getting back a vector of all of the objects in the input and an error if any of them are syntactically invalid, just call (read-string (str [ in-string ])). This also

Re: Understanding unmatched parenthesis in read-string

2013-04-29 Thread Ben Wolfson
On Mon, Apr 29, 2013 at 3:21 PM, noahlz nzuc...@gmail.com wrote: I'm guessing vectors are safer than lists for passing to eval? They're equally unsafe. -- Ben Wolfson Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based.