Sorry - I've answered part of my own Q by reading the read-string doc… nothing 
is eval'ed of the result - just the first "object" is read.

Still unclear why read-string is used - why would a second "object" be 
discarded? Like: 

user=> (read-string "(+ 1 2) (- 3 2)")
(+ 1 2)

Still confused...

-FS.


On Sep 18, 2012, at 11:51 PM, Frank Siebenlist <frank.siebenl...@gmail.com> 
wrote:

> I'm trying to understand the clojurescript-code of the repl functionality, 
> and I'm confused…
> 
> The following cljs.repl/eval-and-print function takes a cljs-form, compiles 
> it, sends it to the browser as javascript, and then receives the result, and 
> the… try's to use "read-string" on that return value:
> 
> ---
> (defn- eval-and-print [repl-env env form]
>  (let [ret (evaluate-form repl-env
>                           (assoc env :ns (ana/get-namespace ana/*cljs-ns*))
>                           "<cljs repl>"
>                           form
>                           (wrap-fn form))]
>    (try (prn (read-string ret))
>         (catch Exception e
>           (if (string? ret)
>             (println ret)
>             (prn nil))))))
> ---
> 
> Why does it call read-string on the returned result from the js-eval?
> 
> The eval'ed compiled javascript could result in a clojure-form that would be 
> eval'ed on the return (???), and the result of the latter is then printed.
> 
> Confusingly yours, FrankS.
> 

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

Reply via email to