Re: “compiling” stacktrace error

2016-02-12 Thread Scaramaccai


On Friday, February 12, 2016 at 9:51:50 AM UTC+1, Scaramaccai wrote:
>
>
>
> On Thursday, February 11, 2016 at 9:54:19 PM UTC+1, Sean Corfield wrote:
>>
>> Scaramaccai wrote on Thursday, February 11, 2016 at 8:32 AM: 
>> >I'm learning Clojure, and I find difficult to understand where a 
>> specific compiler error happens: 
>>
>> The stacktraces can be pretty daunting at first, unfortunately. 
>>
>> How are you compiling / running the code? That will have some bearing on 
>> how errors are reported. 
>>
>>
> Yes, the problem seems to be how I compiled the code. I was using 
> Vim+Fireplace, and doing a "cpr" (takes the content from the active buffer 
> and requires it inside the REPL) I had the error without a proper 
> stacktrace (see below). Running using "reipl run" gives the "proper" 
> stacktrace:
>


BTW using 

(.printStackTrace *e)

>From inside the REPL gave me the full stack... so I can actually keep using 
Fireplace and get the full stack when needed.

-- 
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/d/optout.


Re: “compiling” stacktrace error

2016-02-12 Thread Scaramaccai


On Thursday, February 11, 2016 at 9:54:19 PM UTC+1, Sean Corfield wrote:
>
> Scaramaccai wrote on Thursday, February 11, 2016 at 8:32 AM: 
> >I'm learning Clojure, and I find difficult to understand where a specific 
> compiler error happens: 
>
> The stacktraces can be pretty daunting at first, unfortunately. 
>
> How are you compiling / running the code? That will have some bearing on 
> how errors are reported. 
>
>
Yes, the problem seems to be how I compiled the code. I was using 
Vim+Fireplace, and doing a "cpr" (takes the content from the active buffer 
and requires it inside the REPL) I had the error without a proper 
stacktrace (see below). Running using "reipl run" gives the "proper" 
stacktrace:

[...]
Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to 
clojure.lang.IPersistentCollection
at clojure.core$conj__4345.invokeStatic(core.clj:82)
at clojure.core$conj__4345.invoke(core.clj:82)
at fwpd.core$fib_seq3.invokeStatic(core.clj:98)
at fwpd.core$fib_seq3.invoke(core.clj:92)
at fwpd.core$fib_seq3.invokeStatic(core.clj:94)
at fwpd.core$fib_seq3.invoke(core.clj:92)
at fwpd.core$eval70.invokeStatic(core.clj:105)
at fwpd.core$eval70.invoke(core.clj:105)
at clojure.lang.Compiler.eval(Compiler.java:6927)
at clojure.lang.Compiler.load(Compiler.java:7379)


*Thank you!!!*


Fireplace+REPL stacktrace:

|| java.lang.ClassCastException: java.lang.Long cannot be cast to 
clojure.lang.IPersistentCollection, compiling:(fwpd/core.clj:100:1)
|| clojure.lang.Compiler.load(Compiler.java:7391)
|| clojure.lang.RT.loadResourceScript(RT.java:372)
|| clojure.lang.RT.loadResourceScript(RT.java:363)
|| clojure.lang.RT.load(RT.java:453)
|| clojure.lang.RT.load(RT.java:419)
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5893|
 
clojure.core$load$fn__5677.invoke
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5892|
 
clojure.core$load.invokeStatic
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5876|
 
clojure.core$load.doInvoke
|| clojure.lang.RestFn.invoke(RestFn.java:408)
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5697|
 
clojure.core$load_one.invokeStatic
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5692|
 
clojure.core$load_one.invoke
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5737|
 
clojure.core$load_lib$fn__5626.invoke
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5736|
 
clojure.core$load_lib.invokeStatic
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5717|
 
clojure.core$load_lib.doInvoke
|| clojure.lang.RestFn.applyTo(RestFn.java:142)
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|648|
 
clojure.core$apply.invokeStatic
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5774|
 
clojure.core$load_libs.invokeStatic
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5758|
 
clojure.core$load_libs.doInvoke
|| clojure.lang.RestFn.applyTo(RestFn.java:137)
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|648|
 
clojure.core$apply.invokeStatic
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5796|
 
clojure.core$require.invokeStatic
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|5796|
 
clojure.core$require.doInvoke
|| clojure.lang.RestFn.invoke(RestFn.java:421)
|| fwpd.core$eval3604.invokeStatic(form-init936506867427907734.clj:1)
|| fwpd.core$eval3604.invoke(form-init936506867427907734.clj:1)
|| clojure.lang.Compiler.eval(Compiler.java:6927)
|| clojure.lang.Compiler.eval(Compiler.java:6890)
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|3105|
 
clojure.core$eval.invokeStatic
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\core.clj|3101|
 
clojure.core$eval.invoke
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\main.clj|240|
 
clojure.main$repl$read_eval_print__7408$fn__7411.invoke
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\main.clj|240|
 
clojure.main$repl$read_eval_print__7408.invoke
zipfile:C:\Users\105066315\.m2\repository\org\clojure\clojure\1.8.0\clojure-1.8.0.jar::clojure\main.clj|258|
 
clojure.main$repl$fn__7417.invoke

Re: “compiling” stacktrace error

2016-02-12 Thread Stuart Sierra
(.printStackTrace *e) 
will print the full stacktrace of the most recent exception to the standard 
error stream (STDERR) of the Java process.

Depending on your REPL / tooling environment, stuff printed to standard 
error may not show up in your REPL. If that happens, try this:
(.printStackTrace *e *out*)

*out* is Clojure's thread-local binding for standard output (STDOUT), which 
tools like nREPL rebind to capture output and display in the REPL.

–S

-- 
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/d/optout.


Re: “compiling” stacktrace error

2016-02-12 Thread Sean Corfield
Scaramaccai wrote on Friday, February 12, 2016 at 1:01 AM:
On Friday, February 12, 2016 at 9:51:50 AM UTC+1, Scaramaccai wrote:
Yes, the problem seems to be how I compiled the code. I was using 
Vim+Fireplace, and doing a "cpr" (takes the content from the active buffer and 
requires it inside the REPL) I had the error without a proper stacktrace (see 
below). Running using "reipl run" gives the "proper" stacktrace:
BTW using 

(.printStackTrace *e)

>From inside the REPL gave me the full stack... so I can actually keep using 
>Fireplace and get the full stack when needed.

Excellent!

Welcome to the Clojure community BTW.

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood




-- 
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/d/optout.


Re: “compiling” stacktrace error

2016-02-11 Thread Sean Corfield
Scaramaccai wrote on Thursday, February 11, 2016 at 8:32 AM:
>I'm learning Clojure, and I find difficult to understand where a specific 
>compiler error happens:

The stacktraces can be pretty daunting at first, unfortunately.

How are you compiling / running the code? That will have some bearing on how 
errors are reported.

The exception you are seeing is a runtime failure so part of the stacktrace 
will show the line that initiated the call — line 100 — but other parts of the 
stacktrace should provide the path to the actual exception.

>java.lang.ClassCastException: java.lang.Long cannot be cast to 
>clojure.lang.IPersistentCollection, compiling:(fwpd/core.clj:100:1)

I created a new Clojure app with this as the main namespace:

(ns fib3.core
  (:gen-class))

(defn fib-seq3
  ([to]
   (fib-seq3 [] 0 1 0 to))
  ([coll a b k to]
   (if (= k to)
 coll
 (fib-seq3 (conj b coll) b (+ a b) (inc k) to

(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (println (fib-seq3 5)))

When I run this (via Boot — see below for Leiningen), I get:

 clojure.lang.ExceptionInfo: java.lang.ClassCastException: 
java.lang.Long cannot be cast to clojure.lang.IPersistentCollection
...
clojure.core/conj/invokeStatic  core.clj:   82
  clojure.core/conj  core.clj:   82
fib3.core/fib-seq3/invokeStatic  core.clj:   10
 fib3.core/fib-seq3  core.clj:4
fib3.core/fib-seq3/invokeStatic  core.clj:6
 fib3.core/fib-seq3  core.clj:4
   fib3.core/-main/invokeStatic  core.clj:   15
fib3.core/-main  core.clj:   12


Line 10 is (fib-seq3 (conj b coll) b (+ a b) (inc k) to)

Reading bottom to top for lines reported in our code we see:

-main is defined on line 12
-main makes a call on line 15 to…
fib-seq3 which is defined on line 4…
…which makes a call on line 6 to…
fib-seq3 which is defined on line 4…
…which makes a call on line 10 to…
clojure.core/conj which is where the failure occurs.

Since I have direct linking enabled with Boot, I wanted to check whether 
running the code via Leiningen was different (where I do not have direct 
linking enabled):

Exception in thread "main" java.lang.ClassCastException: java.lang.Long cannot 
be cast to clojure.lang.IPersistentCollection, 
compiling:(/private/var/folders/p1/30gnjddx6p193frh670pl8nhgn/T/form-init8259964769198669862.clj:1:125)
…
Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to 
clojure.lang.IPersistentCollection
at clojure.core$conj__4345.invokeStatic(core.clj:82)
at clojure.core$conj__4345.invoke(core.clj:82)
at fib3.core$fib_seq3.invokeStatic(core.clj:10)
at fib3.core$fib_seq3.invoke(core.clj:4)
at fib3.core$fib_seq3.invokeStatic(core.clj:6)
at fib3.core$fib_seq3.invoke(core.clj:4)
at fib3.core$_main.invokeStatic(core.clj:15)
at fib3.core$_main.doInvoke(core.clj:12)

I omitted the top-level stacktrace (because it relates to clojure.main which is 
in turn running the actual code above) but in the cause we see the same 
sequence of line numbers as with Boot above.


Does that help?

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood




-- 
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/d/optout.


“compiling” stacktrace error

2016-02-11 Thread Scaramaccai


I'm learning Clojure, and I find difficult to understand *where* a specific 
compiler error happens:


java.lang.ClassCastException: java.lang.Long cannot be cast to 
clojure.lang.IPersistentCollection, compiling:(fwpd/core.clj:100:1)


Line 100 is just:


(fib-seq3 5)


So it says nothing, because in fact the error is in the fib-seq3 function 
(parameters to a "conj" call are inverted, see below).


Is this normal? No way to know where an error is???


Just for reference, here's the code (again, *I know where the error is*; I 
just don't understand how was I supposed to find it, given that the message 
doesn't tell me at which line it happens):


(defn fib-seq3
  ([to]
   (fib-seq3 [] 0 1 0 to))
  ([coll a b k to]
(if (= k to)
  coll
  (fib-seq3 (conj b coll) b (+ a b) (inc k) to)))
(fib-seq3 5)



Thank you!


-- 
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/d/optout.