Re: Eval vs the repl

2013-08-28 Thread Alex Miller
I think you may be tripping over this 
bug: http://dev.clojure.org/jira/browse/CLJ-1184

which is waiting for Rich's approval to go into 1.6.

Alex

On Wednesday, August 28, 2013 11:13:54 AM UTC-5, Jamie Brandon wrote:
>
> I had previously assumed that the clojure repl effectively just did 
> (eval (read-string input)). That doesn't seem to be the case eg: 
>
> user> [do (inc 1)] 
> CompilerException java.lang.RuntimeException: Unable to resolve 
> symbol: do in this context, compiling:(NO_SOURCE_PATH:1:1) 
> user> (eval '[do (inc 1)]) 
> 2 
> nil 
> user> (load-string "[do (inc 1)]") 
> 2 
> nil 
>
> user> ^{:line 11, :column 20} [] 
> [] 
> nil 
> user> (eval ^{:line 11, :column 20} []) 
> ClassCastException java.lang.Long cannot be cast to java.lang.Integer 
> clojure.lang.Compiler.eval (Compiler.java:6597) 
> user> (load-string "^{:line 11, :column 20} []") 
> ClassCastException java.lang.Long cannot be cast to java.lang.Integer 
> clojure.lang.Compiler.eval (Compiler.java:6597) 
>
> What can I do to eval a string in the same way that the repl does? 
>

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


Re: Eval vs the repl

2013-08-28 Thread Jamie Brandon
> Just curious: what do you expect that to do?

It was actually the second example that was causing me trouble and
when I was digging through the compiler for the cause I noticed the
first. I don't actually want to write that code, I'm just confused as
to why nrepl.el gives a different answer to lein repl.

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


Re: Eval vs the repl

2013-08-28 Thread John Gabriele
On Wednesday, August 28, 2013 12:13:54 PM UTC-4, Jamie Brandon wrote:

>
> user> [do (inc 1)] 
>
>
Just curious: what do you expect that to do? To me it looks like a 
2-element vector... (containing a `do` special form and then the value 2), 
but my repl yields 2 as the result (?).

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


Re: Eval vs the repl

2013-08-28 Thread Jamie Brandon
Huh, I'm using nrepl.el but if I use lein repl I get the same results as you.

On 28 August 2013 18:16, Aaron Cohen  wrote:
> What repl are you using? I think it's doing something weird.
>
> java -cp clojure-1.5.1.jar clojure.main
> user=> [do (inc 1)]
> 2
> user> ^{:line 11, :column 20} []
> ClassCastException java.lang.Long cannot be cast to java.lang.Integer
> clojure.lang.Compiler.eval (Compiler.java:6597)
>
> --Aaron
>
> --
> --
> 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.

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


Re: Eval vs the repl

2013-08-28 Thread Aaron Cohen
What repl are you using? I think it's doing something weird.

java -cp clojure-1.5.1.jar clojure.main
user=> [do (inc 1)]
2
user> ^{:line 11, :column 20} []
ClassCastException java.lang.Long cannot be cast to java.lang.Integer
 clojure.lang.Compiler.eval (Compiler.java:6597)

--Aaron

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


Eval vs the repl

2013-08-28 Thread Jamie Brandon
I had previously assumed that the clojure repl effectively just did
(eval (read-string input)). That doesn't seem to be the case eg:

user> [do (inc 1)]
CompilerException java.lang.RuntimeException: Unable to resolve
symbol: do in this context, compiling:(NO_SOURCE_PATH:1:1)
user> (eval '[do (inc 1)])
2
nil
user> (load-string "[do (inc 1)]")
2
nil

user> ^{:line 11, :column 20} []
[]
nil
user> (eval ^{:line 11, :column 20} [])
ClassCastException java.lang.Long cannot be cast to java.lang.Integer
clojure.lang.Compiler.eval (Compiler.java:6597)
user> (load-string "^{:line 11, :column 20} []")
ClassCastException java.lang.Long cannot be cast to java.lang.Integer
clojure.lang.Compiler.eval (Compiler.java:6597)

What can I do to eval a string in the same way that the repl does?

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