Re: type function returning a NullPointerException

2019-02-15 Thread Alex Miller
What's the stack trace when you get an NPE? (pst *e)

Are you shadowing a core function with your own `count` or something like 
that?

On Friday, February 15, 2019 at 8:27:55 AM UTC-6, KJO wrote:
>
> Hi-
>
> This one has me stumped. The following code snippet throws a 
> NullPointerException and I just can't understand how it could.
>
> (if (set? t-val)
>   (println t-val (type t-val)))
>
> It seems that if it's a set, it should have a set type.
>
> If I change the code to 
>
> (if (set? t-val)
>   (println t-val (count t-val)))
>
> It throws a ClassCastException
> with java.math.BigDecimal cannot be cast to clojure.lang.IFn
>
> The println is only there for debugging. I was seeing the count function 
> throwing an exception further down in the code, and I couldn't understand 
> why. Any ideas?
>
> t-val is defined in a let, but if I take it out and use the original 
> value, the result is the same. I'm afraid I can't reproduce the error in 
> the REPL using any of the values I captured. The only other thing I can 
> offer is that it's being used in a reducing function over a lazy sequence.
>
> I'm stumped.
>
> Thanks
>
>

-- 
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: type function returning a NullPointerException

2019-02-15 Thread KJO
Damn! That shadowing thing has tripped me up a bunch of times. I'm 
sheepish. Thanks for the reply.

And the type thing is just more of the same (more sheepish) - events do 
conspire against us. I'd been trying to track it down for quite a while. 
Appreciate the help.

Best

On Friday, February 15, 2019 at 9:32:02 AM UTC-5, Alex Miller wrote:
>
> What's the stack trace when you get an NPE? (pst *e)
>
> Are you shadowing a core function with your own `count` or something like 
> that?
>
> On Friday, February 15, 2019 at 8:27:55 AM UTC-6, KJO wrote:
>>
>> Hi-
>>
>> This one has me stumped. The following code snippet throws a 
>> NullPointerException and I just can't understand how it could.
>>
>> (if (set? t-val)
>>   (println t-val (type t-val)))
>>
>> It seems that if it's a set, it should have a set type.
>>
>> If I change the code to 
>>
>> (if (set? t-val)
>>   (println t-val (count t-val)))
>>
>> It throws a ClassCastException
>> with java.math.BigDecimal cannot be cast to clojure.lang.IFn
>>
>> The println is only there for debugging. I was seeing the count function 
>> throwing an exception further down in the code, and I couldn't understand 
>> why. Any ideas?
>>
>> t-val is defined in a let, but if I take it out and use the original 
>> value, the result is the same. I'm afraid I can't reproduce the error in 
>> the REPL using any of the values I captured. The only other thing I can 
>> offer is that it's being used in a reducing function over a lazy sequence.
>>
>> I'm stumped.
>>
>> Thanks
>>
>>

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


type function returning a NullPointerException

2019-02-15 Thread KJO
Hi-

This one has me stumped. The following code snippet throws a 
NullPointerException and I just can't understand how it could.

(if (set? t-val)
  (println t-val (type t-val)))

It seems that if it's a set, it should have a set type.

If I change the code to 

(if (set? t-val)
  (println t-val (count t-val)))

It throws a ClassCastException
with java.math.BigDecimal cannot be cast to clojure.lang.IFn

The println is only there for debugging. I was seeing the count function 
throwing an exception further down in the code, and I couldn't understand 
why. Any ideas?

t-val is defined in a let, but if I take it out and use the original value, 
the result is the same. I'm afraid I can't reproduce the error in the REPL 
using any of the values I captured. The only other thing I can offer is 
that it's being used in a reducing function over a lazy sequence.

I'm stumped.

Thanks

-- 
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: Got NullpointerException when using loop/recur/let together

2017-10-25 Thread Matching Socks
Also, have another look at 
'(ret (- time-now start-time))

It will yield a list containing the symbol 'ret and a nested list 
containing the symbol '- etc etc etc. 

I think what you expected was a vector of two numbers.

-- 
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: Got NullpointerException when using loop/recur/let together

2017-10-24 Thread Justin Smith
you wrap a call to Thread/sleep in parens, in clojure this means you want
to call it, Thread/sleep returns nil and calling nil gives a
NullpointerException

Parens are not for grouping or sequencing things in clojure, and you don't
need them here - fn has an implicit do block already, in other contexts
where there isn't a do block implicitly, you can use do to sequence
expressions

On Tue, Oct 24, 2017 at 5:26 PM yihao yang <yangyihao1...@gmail.com> wrote:

> Hi, all
>
>   I want to do sth. like query until timeout. So I write a function below.
> (defn wait-ls-ready
>   []
>   (let [pair-fn (fn [] (
>  (Thread/sleep 1000)
>  (let [ret (try
>  (c/exec :ls)
>  0
>  (catch RuntimeException e -1)
>),
>time-now (quot (System/currentTimeMillis)
> 1000)]
>'(ret (- time-now start-time))
>  )
>))]
> (loop [start-time (quot (System/currentTimeMillis) 1000)
>time-out 10]
>   (let [[ret time-delta] (pair-fn)]
> (info node "Waiting gsql works...")
> (if (= 0 ret) 0
>   (if (> time-delta time-out)
> (throw (RuntimeException.
>  (str "'ls' not working in " time-out "seconds.")))
> (recur start-time time-out
> )
>   )
> )
>
> But it returns a NullpointerException after 1 seconds. Could anyone help
> me out?
>
> Thanks,
> Yihao
>
> --
> 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.
>

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


Got NullpointerException when using loop/recur/let together

2017-10-24 Thread yihao yang
Hi, all

  I want to do sth. like query until timeout. So I write a function below.
(defn wait-ls-ready
  []
  (let [pair-fn (fn [] (
 (Thread/sleep 1000)
 (let [ret (try
 (c/exec :ls)
 0
 (catch RuntimeException e -1)
   ),
   time-now (quot (System/currentTimeMillis) 
1000)]
   '(ret (- time-now start-time))
 )
   ))]
(loop [start-time (quot (System/currentTimeMillis) 1000)
   time-out 10]
  (let [[ret time-delta] (pair-fn)]
(info node "Waiting gsql works...")
(if (= 0 ret) 0
  (if (> time-delta time-out)
(throw (RuntimeException.
 (str "'ls' not working in " time-out "seconds.")))
(recur start-time time-out))))
)
  )
)

But it returns a NullpointerException after 1 seconds. Could anyone help me 
out?

Thanks,
Yihao

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


NullPointerException on ManagementFactory/getThreadMXBean ???

2016-01-25 Thread piastkrakow
I've never had this problem before, but now I'm getting this:

in resource-usage there was this exception:  #

at startup, for this function: 

(defn- resource-usage []
  (let [my-pool (at/mk-pool)]
(at/every 6
  (fn []
(try
  (timbre/log :trace "Resource usage: "
  
(monitoring/show-stats-regarding-resources-used-by-this-app))
  (doseq [x (monitoring/thread-top)]
(timbre/log :trace x))
  (catch Exception e (println "in resource-usage there was 
this exception: " e
  my-pool)))


This line:

  (timbre/log :trace "Resource usage: "
  
(monitoring/show-stats-regarding-resources-used-by-this-app))

Correctly gives me:

Resource usage:  Memory in use (percentage/used/max-heap): ("9%" "43M" 
"444M")

So the problem comes here: 

  (doseq [x (monitoring/thread-top)]
(timbre/log :trace x))

Which relies on java.lang.management.ManagementFactory

(defn thread-top
  "Return a seq of threads sorted by their total userland CPU usage."
  []
  (let [mgr (ManagementFactory/getThreadMXBean)
cpu-times (map (fn [t]
 [(.getThreadCpuTime mgr (.getId t)) t])
(threads))]
(map
  (fn [[cpu t]] [cpu (.getName t) (.getId t) t])
  (reverse (sort-by first cpu-times)


With some code borrowed from here: 

http://lifeisagraph.com/2011/04/24/debugging-clojure.html

Does anyone see a place where a NullPointerException might get started? 

I assume this must be some circumstance unique to startup. I don't think 
this problem repeats. 



-- 
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: NullPointerException on ManagementFactory/getThreadMXBean ???

2016-01-25 Thread piastkrakow

This error is also intermittent. It doesn't happen every time I start the 
app. I would guess this is some kind of timing issue, but I can't think 
where the issue of timing comes up. 


On Monday, January 25, 2016 at 4:04:50 PM UTC-5, piast...@gmail.com wrote:
>
> I've never had this problem before, but now I'm getting this:
>
> in resource-usage there was this exception:  # java.lang.NullPointerException>
>
> at startup, for this function: 
>
> (defn- resource-usage []
>   (let [my-pool (at/mk-pool)]
> (at/every 6
>   (fn []
> (try
>   (timbre/log :trace "Resource usage: "
>   
> (monitoring/show-stats-regarding-resources-used-by-this-app))
>   (doseq [x (monitoring/thread-top)]
> (timbre/log :trace x))
>   (catch Exception e (println "in resource-usage there was 
> this exception: " e
>   my-pool)))
>
>
> This line:
>
>   (timbre/log :trace "Resource usage: "
>   
> (monitoring/show-stats-regarding-resources-used-by-this-app))
>
> Correctly gives me:
>
> Resource usage:  Memory in use (percentage/used/max-heap): ("9%" "43M" 
> "444M")
>
> So the problem comes here: 
>
>   (doseq [x (monitoring/thread-top)]
> (timbre/log :trace x))
>
> Which relies on java.lang.management.ManagementFactory
>
> (defn thread-top
>   "Return a seq of threads sorted by their total userland CPU usage."
>   []
>   (let [mgr (ManagementFactory/getThreadMXBean)
> cpu-times (map (fn [t]
>  [(.getThreadCpuTime mgr (.getId t)) t])
> (threads))]
> (map
>   (fn [[cpu t]] [cpu (.getName t) (.getId t) t])
>   (reverse (sort-by first cpu-times)
> 
>
> With some code borrowed from here: 
>
> http://lifeisagraph.com/2011/04/24/debugging-clojure.html
>
> Does anyone see a place where a NullPointerException might get started? 
>
> I assume this must be some circumstance unique to startup. I don't think 
> this problem repeats. 
>
>
>
>

-- 
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: NullPointerException when creating protocol in macro

2013-06-07 Thread Vincent
Thanks everyone for your answers. I must say I'm quite mystified as to why 
Stuart's version works.

I ended up defining a function that has the same signature as the protocol, 
and whose first argument wraps a function that contains the appropriate 
code.

Vincent

On Wednesday, 5 June 2013 23:57:16 UTC+2, Stuart Sierra wrote:

 Hi Vincent,

 `defprotocol` is a top-level form, not really meant to be mixed with 
 value-returning expressions like `fn`. Protocols are always global because 
 of how they compile into Java interfaces.

 Here's one way to make it work, by defining a symbol instead of returning 
 a function:

 (defmacro create-protocol [protocol symbol implementation]
   (let [[protocol-name signature] protocol]
 `(do
(defprotocol ~protocol-name ~signature)
(defn ~symbol [] (reify ~protocol-name ~implementation)

 (create-protocol [P (method [this])]
  constructor
  (method [this] (println method)))

 (method (constructor))

 -S


 On Wednesday, June 5, 2013 9:16:05 AM UTC-4, Vincent wrote:

 I’m trying to write a macro that defines a protocol and a function that, 
 when called, returns an implementation of that protocol.

 I’ve reduced the code to the following example:
 (defmacro create-protocol [protocol implementation]
   (let [[protocol-name signature] protocol]
 `(do
(defprotocol ~protocol-name ~signature)
(fn [] (reify ~protocol-name ~implementation)

 (let [f (create-protocol [P (method [this])]
  (method [this] (println method)))]
   (method (f)))


 The original code is more complicated, where the function will read a 
 value from a file and, depending on that value, return the appropriate 
 implementation of the protocol.

 When I run Clojure 1.5.1 on that code I get the following exception:
 Exception in thread main java.lang.NullPointerException, 
 compiling:(protocol.clj:7:9)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6567)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyze(Compiler.java:6322)
 at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
 at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
 at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyze(Compiler.java:6322)
 at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.access$100(Compiler.java:37)
 at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:5973)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyze(Compiler.java:6322)
 at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
 at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
 at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.eval(Compiler.java:6616)
 at clojure.lang.Compiler.load(Compiler.java:7064)
 at clojure.lang.Compiler.loadFile(Compiler.java:7020)
 at clojure.main$load_script.invoke(main.clj:294)
 at clojure.main$script_opt.invoke(main.clj:356)
 at clojure.main$main.doInvoke(main.clj:440)
 at clojure.lang.RestFn.invoke(RestFn.java:408)
 at clojure.lang.Var.invoke(Var.java:415)
 at clojure.lang.AFn.applyToHelper(AFn.java:161)
 at clojure.lang.Var.applyTo(Var.java:532)
 at clojure.main.main(main.java:37)
 Caused by: java.lang.NullPointerException
 at clojure.lang.Compiler.resolveIn(Compiler.java:6840)
 at clojure.lang.Compiler.resolve(Compiler.java:6818)
 at clojure.lang.Compiler$NewInstanceExpr.build(Compiler.java:7427)
 at 
 clojure.lang.Compiler$NewInstanceExpr$ReifyParser.parse(Compiler.java:7377)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
 ... 38 more

 From what I understood by tracing through the compiler it seems that the 
 P var is created at macro expansion time but bound at execution time only. 
 When expanding the ‘reify’ macro, P is still unbound, which yields a nil 
 interface, which triggers the NPE.

 I could solve the problem by redefining the macro in the following way:
 (defmacro create-protocol [protocol 

NullPointerException when creating protocol in macro

2013-06-05 Thread Vincent
I’m trying to write a macro that defines a protocol and a function that, 
when called, returns an implementation of that protocol.

I’ve reduced the code to the following example:
(defmacro create-protocol [protocol implementation]
  (let [[protocol-name signature] protocol]
`(do
   (defprotocol ~protocol-name ~signature)
   (fn [] (reify ~protocol-name ~implementation)

(let [f (create-protocol [P (method [this])]
 (method [this] (println method)))]
  (method (f)))


The original code is more complicated, where the function will read a value 
from a file and, depending on that value, return the appropriate 
implementation of the protocol.

When I run Clojure 1.5.1 on that code I get the following exception:
Exception in thread main java.lang.NullPointerException, 
compiling:(protocol.clj:7:9)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6567)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:5973)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.eval(Compiler.java:6616)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.Compiler.loadFile(Compiler.java:7020)
at clojure.main$load_script.invoke(main.clj:294)
at clojure.main$script_opt.invoke(main.clj:356)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:415)
at clojure.lang.AFn.applyToHelper(AFn.java:161)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
Caused by: java.lang.NullPointerException
at clojure.lang.Compiler.resolveIn(Compiler.java:6840)
at clojure.lang.Compiler.resolve(Compiler.java:6818)
at clojure.lang.Compiler$NewInstanceExpr.build(Compiler.java:7427)
at 
clojure.lang.Compiler$NewInstanceExpr$ReifyParser.parse(Compiler.java:7377)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
... 38 more

From what I understood by tracing through the compiler it seems that the P 
var is created at macro expansion time but bound at execution time only. 
When expanding the ‘reify’ macro, P is still unbound, which yields a nil 
interface, which triggers the NPE.

I could solve the problem by redefining the macro in the following way:
(defmacro create-protocol [protocol implementation]
  (let [[protocol-name signature] protocol]
(eval `(defprotocol ~protocol-name ~signature))
`(fn [] (reify ~protocol-name ~implementation

Using eval doesn’t feel right though.

I guess I could modify my code to avoid using protocols, but it seemed to 
me to be the most natural way of achieving what I wanted.

I was just wondering if anybody had any opinion or suggestion about that. 
Am I going off track? Is there a more idiomatic way of doing things that I 
missed?

Thanks,
Vincent

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

Re: NullPointerException when creating protocol in macro

2013-06-05 Thread Stuart Sierra
Hi Vincent,

`defprotocol` is a top-level form, not really meant to be mixed with 
value-returning expressions like `fn`. Protocols are always global because 
of how they compile into Java interfaces.

Here's one way to make it work, by defining a symbol instead of returning a 
function:

(defmacro create-protocol [protocol symbol implementation]
  (let [[protocol-name signature] protocol]
`(do
   (defprotocol ~protocol-name ~signature)
   (defn ~symbol [] (reify ~protocol-name ~implementation)

(create-protocol [P (method [this])]
 constructor
 (method [this] (println method)))

(method (constructor))

-S


On Wednesday, June 5, 2013 9:16:05 AM UTC-4, Vincent wrote:

 I’m trying to write a macro that defines a protocol and a function that, 
 when called, returns an implementation of that protocol.

 I’ve reduced the code to the following example:
 (defmacro create-protocol [protocol implementation]
   (let [[protocol-name signature] protocol]
 `(do
(defprotocol ~protocol-name ~signature)
(fn [] (reify ~protocol-name ~implementation)

 (let [f (create-protocol [P (method [this])]
  (method [this] (println method)))]
   (method (f)))


 The original code is more complicated, where the function will read a 
 value from a file and, depending on that value, return the appropriate 
 implementation of the protocol.

 When I run Clojure 1.5.1 on that code I get the following exception:
 Exception in thread main java.lang.NullPointerException, 
 compiling:(protocol.clj:7:9)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6567)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyze(Compiler.java:6322)
 at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
 at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
 at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyze(Compiler.java:6322)
 at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.access$100(Compiler.java:37)
 at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:5973)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.analyze(Compiler.java:6322)
 at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
 at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
 at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
 at clojure.lang.Compiler.analyze(Compiler.java:6361)
 at clojure.lang.Compiler.eval(Compiler.java:6616)
 at clojure.lang.Compiler.load(Compiler.java:7064)
 at clojure.lang.Compiler.loadFile(Compiler.java:7020)
 at clojure.main$load_script.invoke(main.clj:294)
 at clojure.main$script_opt.invoke(main.clj:356)
 at clojure.main$main.doInvoke(main.clj:440)
 at clojure.lang.RestFn.invoke(RestFn.java:408)
 at clojure.lang.Var.invoke(Var.java:415)
 at clojure.lang.AFn.applyToHelper(AFn.java:161)
 at clojure.lang.Var.applyTo(Var.java:532)
 at clojure.main.main(main.java:37)
 Caused by: java.lang.NullPointerException
 at clojure.lang.Compiler.resolveIn(Compiler.java:6840)
 at clojure.lang.Compiler.resolve(Compiler.java:6818)
 at clojure.lang.Compiler$NewInstanceExpr.build(Compiler.java:7427)
 at 
 clojure.lang.Compiler$NewInstanceExpr$ReifyParser.parse(Compiler.java:7377)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
 ... 38 more

 From what I understood by tracing through the compiler it seems that the P 
 var is created at macro expansion time but bound at execution time only. 
 When expanding the ‘reify’ macro, P is still unbound, which yields a nil 
 interface, which triggers the NPE.

 I could solve the problem by redefining the macro in the following way:
 (defmacro create-protocol [protocol implementation]
   (let [[protocol-name signature] protocol]
 (eval `(defprotocol ~protocol-name ~signature))
 `(fn [] (reify ~protocol-name ~implementation

 Using eval doesn’t feel right though.

 I guess I could modify my code to avoid using protocols, but it seemed to 
 me to be the most natural way of achieving what I wanted.

 I 

Re: NullPointerException when creating protocol in macro

2013-06-05 Thread Colin Fleming
*`defprotocol` is a top-level form...*

This is interesting, and it's something I've wondered about. As far as I
can tell, there's really no distinction between top-level forms and other
forms, for example this is legal and works:

(defn define-my-functions []
  (defn test-1 []
1)
  (defn test-2 []
2))
= #=(var plugin.performance.project/define-my-functions)
test-1
= Unbound: #'plugin.performance.project/test-1
test-2
= Unbound: #'plugin.performance.project/test-2
(define-my-functions)
= #=(var plugin.performance.project/test-2)
test-1
= plugin.performance.project$define_my_functions$test_1__3112@30e63c09
test-2
= plugin.performance.project$define_my_functions$test_2__3114@24ae6e0a

Given this, are there any forms that are genuinely top-level from the
compiler's point of view? I'm assuming defining functions like this is
generally discouraged, but defining them inside of let-forms seems
relatively common:

(let [a 1]
  (defn get-a []
a))
= #=(var plugin.performance.project/get-a)
(get-a)
= 1




On 6 June 2013 09:57, Stuart Sierra the.stuart.sie...@gmail.com wrote:

 Hi Vincent,

 `defprotocol` is a top-level form, not really meant to be mixed with
 value-returning expressions like `fn`. Protocols are always global because
 of how they compile into Java interfaces.

 Here's one way to make it work, by defining a symbol instead of returning
 a function:

 (defmacro create-protocol [protocol symbol implementation]

   (let [[protocol-name signature] protocol]
 `(do
(defprotocol ~protocol-name ~signature)
(defn ~symbol [] (reify ~protocol-name ~implementation)


 (create-protocol [P (method [this])]
  constructor

  (method [this] (println method)))

 (method (constructor))

 -S



 On Wednesday, June 5, 2013 9:16:05 AM UTC-4, Vincent wrote:

 I’m trying to write a macro that defines a protocol and a function that,
 when called, returns an implementation of that protocol.

 I’ve reduced the code to the following example:
 (defmacro create-protocol [protocol implementation]
   (let [[protocol-name signature] protocol]
 `(do
(defprotocol ~protocol-name ~signature)
(fn [] (reify ~protocol-name ~implementation)

 (let [f (create-protocol [P (method [this])]
  (method [this] (println method)))]
   (method (f)))


 The original code is more complicated, where the function will read a
 value from a file and, depending on that value, return the appropriate
 implementation of the protocol.

 When I run Clojure 1.5.1 on that code I get the following exception:
 Exception in thread main java.lang.**NullPointerException,
 compiling:(protocol.clj:7:9)
 at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6567)
 at clojure.lang.Compiler.analyze(**Compiler.java:6361)
 at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6548)
 at clojure.lang.Compiler.analyze(**Compiler.java:6361)
 at clojure.lang.Compiler.analyze(**Compiler.java:6322)
 at clojure.lang.Compiler$**BodyExpr$Parser.parse(**
 Compiler.java:5708)
 at clojure.lang.Compiler$**FnMethod.parse(Compiler.java:**5139)
 at clojure.lang.Compiler$FnExpr.**parse(Compiler.java:3751)
 at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6558)
 at clojure.lang.Compiler.analyze(**Compiler.java:6361)
 at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6548)
 at clojure.lang.Compiler.analyze(**Compiler.java:6361)
 at clojure.lang.Compiler.analyze(**Compiler.java:6322)
 at clojure.lang.Compiler$**BodyExpr$Parser.parse(**
 Compiler.java:5708)
 at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6560)
 at clojure.lang.Compiler.analyze(**Compiler.java:6361)
 at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6548)
 at clojure.lang.Compiler.analyze(**Compiler.java:6361)
 at clojure.lang.Compiler.access$**100(Compiler.java:37)
 at clojure.lang.Compiler$LetExpr$**Parser.parse(Compiler.java:**5973)
 at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6560)
 at clojure.lang.Compiler.analyze(**Compiler.java:6361)
 at clojure.lang.Compiler.analyze(**Compiler.java:6322)
 at clojure.lang.Compiler$**BodyExpr$Parser.parse(**
 Compiler.java:5708)
 at clojure.lang.Compiler$**FnMethod.parse(Compiler.java:**5139)
 at clojure.lang.Compiler$FnExpr.**parse(Compiler.java:3751)
 at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6558)
 at clojure.lang.Compiler.analyze(**Compiler.java:6361)
 at clojure.lang.Compiler.eval(**Compiler.java:6616)
 at clojure.lang.Compiler.load(**Compiler.java:7064)
 at clojure.lang.Compiler.**loadFile(Compiler.java:7020)
 at clojure.main$load_script.**invoke(main.clj:294)
 at clojure.main$script_opt.**invoke(main.clj:356)
 at clojure.main$main.doInvoke(**main.clj:440)
 at clojure.lang.RestFn.invoke(**RestFn.java:408)
 at clojure.lang.Var.invoke(Var.**java:415)
 at clojure.lang.AFn.**applyToHelper(AFn.java:161

Re: NullPointerException when creating protocol in macro

2013-06-05 Thread Stuart Sierra
On Wed, Jun 5, 2013 at 7:35 PM, Colin Fleming
colin.mailingl...@gmail.comwrote:

 Given this, are there any forms that are genuinely top-level from the
 compiler's point of view?



It's never explicitly enforced, just a consequence of how the compiler
creates and loads Java classes. Generally, the things which compile
directly to named Java classes -- defprotocol, deftype, defrecord -- may
not work except as top-level forms, as Vincent discovered.

-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/groups/opt_out.




Re: NullPointerException when creating protocol in macro

2013-06-05 Thread Softaddicts
Legal but comparable to a hidden side effect with all the pitfalls that can 
derive
from this.

It's not a compiler issue, more a discipline issue.

Having a helper macro like Stuart suggest is acceptable to me
if it's called at top level, it's always done. There's less ambiguity.

Using def/defn in a function is less desirable, the definition/redefinition 
occurs when you
call the fn and it may occur at less desirable times or could be hard to spot.

If you need a local fn, let-fn is exactly for this purpose. The scope is limited
to the let-fn body.

Luc P.


 *`defprotocol` is a top-level form...*
  This is interesting, and it's something I've wondered about. As far as I
 can tell, there's really no distinction between top-level forms and other
 forms, for example this is legal and works:
  (defn define-my-functions []
   (defn test-1 []
 1)
   (defn test-2 []
 2))
 = #=(var plugin.performance.project/define-my-functions)
 test-1
 = Unbound: #'plugin.performance.project/test-1
 test-2
 = Unbound: #'plugin.performance.project/test-2
 (define-my-functions)
 = #=(var plugin.performance.project/test-2)
 test-1
 = plugin.performance.project$define_my_functions$test_1__3112@30e63c09
 test-2
 = plugin.performance.project$define_my_functions$test_2__3114@24ae6e0a
  Given this, are there any forms that are genuinely top-level from the
 compiler's point of view? I'm assuming defining functions like this is
 generally discouraged, but defining them inside of let-forms seems
 relatively common:
  (let [a 1]
   (defn get-a []
 a))
 = #=(var plugin.performance.project/get-a)
 (get-a)
 = 1
 On 6 June 2013 09:57, Stuart Sierra the.stuart.sie...@gmail.com 
 wrote:
   Hi Vincent,
 
  `defprotocol` is a top-level form, not really meant to be mixed with
  value-returning expressions like `fn`. Protocols are always global because
  of how they compile into Java interfaces.
 
  Here's one way to make it work, by defining a symbol instead of returning
  a function:
 
  (defmacro create-protocol [protocol symbol implementation]
 
(let [[protocol-name signature] protocol]
  `(do
 (defprotocol ~protocol-name ~signature)
 (defn ~symbol [] (reify ~protocol-name ~implementation)
 
 
  (create-protocol [P (method [this])]
   constructor
 
   (method [this] (println method)))
 
  (method (constructor))
 
  -S
 
 
 
  On Wednesday, June 5, 2013 9:16:05 AM UTC-4, Vincent wrote:
 
  I’m trying to write a macro that defines a protocol and a function that,
  when called, returns an implementation of that protocol.
 
  I’ve reduced the code to the following example:
  (defmacro create-protocol [protocol implementation]
(let [[protocol-name signature] protocol]
  `(do
 (defprotocol ~protocol-name ~signature)
 (fn [] (reify ~protocol-name ~implementation)
 
  (let [f (create-protocol [P (method [this])]
   (method [this] (println method)))]
(method (f)))
 
 
  The original code is more complicated, where the function will read a
  value from a file and, depending on that value, return the appropriate
  implementation of the protocol.
 
  When I run Clojure 1.5.1 on that code I get the following exception:
  Exception in thread main java.lang.**NullPointerException,
  compiling:(protocol.clj:7:9)
  at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6567)
  at clojure.lang.Compiler.analyze(**Compiler.java:6361)
  at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6548)
  at clojure.lang.Compiler.analyze(**Compiler.java:6361)
  at clojure.lang.Compiler.analyze(**Compiler.java:6322)
  at clojure.lang.Compiler$**BodyExpr$Parser.parse(**
  Compiler.java:5708)
  at clojure.lang.Compiler$**FnMethod.parse(Compiler.java:**5139)
  at clojure.lang.Compiler$FnExpr.**parse(Compiler.java:3751)
  at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6558)
  at clojure.lang.Compiler.analyze(**Compiler.java:6361)
  at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6548)
  at clojure.lang.Compiler.analyze(**Compiler.java:6361)
  at clojure.lang.Compiler.analyze(**Compiler.java:6322)
  at clojure.lang.Compiler$**BodyExpr$Parser.parse(**
  Compiler.java:5708)
  at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6560)
  at clojure.lang.Compiler.analyze(**Compiler.java:6361)
  at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6548)
  at clojure.lang.Compiler.analyze(**Compiler.java:6361)
  at clojure.lang.Compiler.access$**100(Compiler.java:37)
  at clojure.lang.Compiler$LetExpr$**Parser.parse(Compiler.java:**5973)
  at clojure.lang.Compiler.**analyzeSeq(Compiler.java:6560)
  at clojure.lang.Compiler.analyze(**Compiler.java:6361)
  at clojure.lang.Compiler.analyze(**Compiler.java:6322)
  at clojure.lang.Compiler$**BodyExpr$Parser.parse(**
  Compiler.java:5708)
  at clojure.lang.Compiler$**FnMethod.parse(Compiler.java:**5139

what is the issue: NullPointerException com.mongodb.DBCursor._check (DBCursor.java:365) for congomongo

2013-04-18 Thread Zhi Yang
I use a mongodb which use sharding, so I connect to mongos.

but when I query like: 
(fetch :locations)
NullPointerException   com.mongodb.DBCursor._check (DBCursor.java:365)

there is error

if the use (fetch :locations :one? true) it works.

anyone know what is going on? I use version  [congomongo 0.4.1], is it 
driver issue or usage issue?


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




what is the issue: NullPointerException com.mongodb.DBCursor._check (DBCursor.java:365) for congomongo

2013-04-18 Thread Zhi Yang
I use a mongodb which use sharding, so I connect to mongos.

but when I query like: 
(fetch :locations)
NullPointerException   com.mongodb.DBCursor._check (DBCursor.java:365)

there is error

if the use (fetch :locations :one? true) it works.

anyone know what is going on? I use version  [congomongo 0.4.1], is it 
driver issue or usage issue?


-- 
-- 
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: clj-logging-config, lein2 and AOT compilation == NullPointerException

2012-09-05 Thread Leonardo Borges
I haven't really found out what the problem is - and haven't been looking 
into it - but I put a small clojure app together to replicate the issue.

You can find it on dropbox[1]

I've also updated the issue I had opened on the clj-logging-config github 
issues page [2]

If you're keen on debugging this, just grab the project on dropbox, extract 
somewhere and compile it:

lein with-profile production compile :all

Then try to start the server like so:

lein trampoline with-profile production run -m logging-tests.core 4000

You should have a big fat exception right on your terminal.

[1] https://dl.dropbox.com/u/6251992/logging-tests.zip
[2] https://github.com/malcolmsparks/clj-logging-config/issues/15


On Tuesday, September 4, 2012 2:57:21 PM UTC+10, Leonardo Borges wrote:

 Hi all,

 I've been debugging an issue in my Clojure app deployed on Heroku and 
 after some time I finally tracked it down to what appears 
 to be an issue when AOT compiling the project while using 
 clj-logging-config [1]

 It works without any issues if I let Clojure compile my namespaces on the 
 fly. As soon as I AOT compile, I can't run my jetty server any longer.

 This led me to open an issue [2] with clj-logging-config where you can 
 find some extra info on my setup.

 I'm posting this here in the hopes someone has been through this before 
 and that the solution is something trivial I've overlooked.

 [1] https://github.com/malcolmsparks/clj-logging-config
 [2] https://github.com/malcolmsparks/clj-logging-config/issues/15

 Thanks,
 Leonardo Borges
 www.leonardoborges.com
  

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

clj-logging-config, lein2 and AOT compilation == NullPointerException

2012-09-03 Thread Leonardo Borges
Hi all,

I've been debugging an issue in my Clojure app deployed on Heroku and after
some time I finally tracked it down to what appears
to be an issue when AOT compiling the project while using
clj-logging-config [1]

It works without any issues if I let Clojure compile my namespaces on the
fly. As soon as I AOT compile, I can't run my jetty server any longer.

This led me to open an issue [2] with clj-logging-config where you can find
some extra info on my setup.

I'm posting this here in the hopes someone has been through this before and
that the solution is something trivial I've overlooked.

[1] https://github.com/malcolmsparks/clj-logging-config
[2] https://github.com/malcolmsparks/clj-logging-config/issues/15

Thanks,
Leonardo Borges
www.leonardoborges.com

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

NullPointerException

2012-05-17 Thread Sargash
Hi!

I have a problem. With that code:

; ===
; ex 1.17 multiply
(defn ex1_17 []
  (defn double [x] (+ x x))
  (defn halve [x] (/ x 2))

  (defn * [a b]
(cond
  (= b 0) 0
  (even? b) (* (double a) (halve b))
  :else (+ a (* a (- b 1)

  (println (* 5 5))
)
(ex1_17 )

I gave that exception:

Exception in thread main java.lang.NullPointerException, compiling:
(D:\workprivate\ll\1\src\first.clj:3)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:518)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.analyze(Compiler.java:6223)
at clojure.lang.Compiler.eval(Compiler.java:6515)
at clojure.lang.Compiler.load(Compiler.java:6952)
at clojure.lang.Compiler.loadFile(Compiler.java:6912)
at clojure.main$load_script.invoke(main.clj:283)
at clojure.main$script_opt.invoke(main.clj:343)
at clojure.main$main.doInvoke(main.clj:427)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:415)
at clojure.lang.AFn.applyToHelper(AFn.java:161)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:
120)
Caused by: java.lang.NullPointerException
at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4774)
at clojure.lang.Compiler$DefExpr.emit(Compiler.java:418)
at clojure.lang.Compiler$BodyExpr.emit(Compiler.java:5659)
at clojure.lang.Compiler$FnMethod.doEmit(Compiler.java:5215)
at clojure.lang.Compiler$FnMethod.emit(Compiler.java:5069)
at clojure.lang.Compiler$FnExpr.emitMethods(Compiler.java:3600)
at clojure.lang.Compiler$ObjExpr.compile(Compiler.java:4233)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3732)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6453)
... 24 more

Could you tell me where I wrong?

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


Re: NullPointerException

2012-05-17 Thread eniotna
Hi,

Look at your parenthesis.
You did not close your first function.

Antoine

2012/5/17 Sargash gerby...@gmail.com

 Hi!

 I have a problem. With that code:

 ; ===
 ; ex 1.17 multiply
 (defn ex1_17 []
  (defn double [x] (+ x x))
  (defn halve [x] (/ x 2))

  (defn * [a b]
(cond
  (= b 0) 0
  (even? b) (* (double a) (halve b))
  :else (+ a (* a (- b 1)

  (println (* 5 5))
 )
 (ex1_17 )

 I gave that exception:

 Exception in thread main java.lang.NullPointerException, compiling:
 (D:\workprivate\ll\1\src\first.clj:3)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:518)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.analyze(Compiler.java:6223)
at clojure.lang.Compiler.eval(Compiler.java:6515)
at clojure.lang.Compiler.load(Compiler.java:6952)
at clojure.lang.Compiler.loadFile(Compiler.java:6912)
at clojure.main$load_script.invoke(main.clj:283)
at clojure.main$script_opt.invoke(main.clj:343)
at clojure.main$main.doInvoke(main.clj:427)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:415)
at clojure.lang.AFn.applyToHelper(AFn.java:161)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
 39)
at

 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
 25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:
 120)
 Caused by: java.lang.NullPointerException
at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4774)
at clojure.lang.Compiler$DefExpr.emit(Compiler.java:418)
at clojure.lang.Compiler$BodyExpr.emit(Compiler.java:5659)
at clojure.lang.Compiler$FnMethod.doEmit(Compiler.java:5215)
at clojure.lang.Compiler$FnMethod.emit(Compiler.java:5069)
at clojure.lang.Compiler$FnExpr.emitMethods(Compiler.java:3600)
at clojure.lang.Compiler$ObjExpr.compile(Compiler.java:4233)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3732)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6453)
... 24 more

 Could you tell me where I wrong?

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

Re: NullPointerException

2012-05-17 Thread Raoul Duke
On Thu, May 17, 2012 at 10:55 AM, eniotna eniotn...@gmail.com wrote:
 Look at your parenthesis.
 You did not close your first function.

some day we'll have the technology to let the compiler tell us that,
instead of spewing some horrible, pointless, stack trace?

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


Re: NullPointerException

2012-05-17 Thread eniotna
Furthermore, The syntax you're using is not correct.
If you want to define functions inside your function ex1_17, use letfn.

Something along the line:

(defn ex1_17 []
  (letfn [(double [x] (+ x x))
  (halve [x] (/ x 2))
  (mult [a b]
(cond
 (= b 0) 0
 (even? b) (* (double a) (halve b))
 :else (+ a (* a (- b 1)]
(println (mult 5 5

I prefer not to mess with the default function so i redefined your * by mult

Antoine

2012/5/17 eniotna eniotn...@gmail.com

 Hi,

 Look at your parenthesis.
 You did not close your first function.

 Antoine


 2012/5/17 Sargash gerby...@gmail.com

 Hi!

 I have a problem. With that code:

 ; ===
 ; ex 1.17 multiply
 (defn ex1_17 []
  (defn double [x] (+ x x))
  (defn halve [x] (/ x 2))

  (defn * [a b]
(cond
  (= b 0) 0
  (even? b) (* (double a) (halve b))
  :else (+ a (* a (- b 1)

  (println (* 5 5))
 )
 (ex1_17 )

 I gave that exception:

 Exception in thread main java.lang.NullPointerException, compiling:
 (D:\workprivate\ll\1\src\first.clj:3)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:518)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
at clojure.lang.Compiler.analyze(Compiler.java:6223)
at clojure.lang.Compiler.eval(Compiler.java:6515)
at clojure.lang.Compiler.load(Compiler.java:6952)
at clojure.lang.Compiler.loadFile(Compiler.java:6912)
at clojure.main$load_script.invoke(main.clj:283)
at clojure.main$script_opt.invoke(main.clj:343)
at clojure.main$main.doInvoke(main.clj:427)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:415)
at clojure.lang.AFn.applyToHelper(AFn.java:161)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
 39)
at

 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
 25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:
 120)
 Caused by: java.lang.NullPointerException
at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4774)
at clojure.lang.Compiler$DefExpr.emit(Compiler.java:418)
at clojure.lang.Compiler$BodyExpr.emit(Compiler.java:5659)
at clojure.lang.Compiler$FnMethod.doEmit(Compiler.java:5215)
at clojure.lang.Compiler$FnMethod.emit(Compiler.java:5069)
at clojure.lang.Compiler$FnExpr.emitMethods(Compiler.java:3600)
at clojure.lang.Compiler$ObjExpr.compile(Compiler.java:4233)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3732)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6453)
... 24 more

 Could you tell me where I wrong?

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

Re: NullPointerException

2012-05-17 Thread eniotna
2012/5/17 Raoul Duke rao...@gmail.com

 On Thu, May 17, 2012 at 10:55 AM, eniotna eniotn...@gmail.com wrote:
  Look at your parenthesis.
  You did not close your first function.

 some day we'll have the technology to let the compiler tell us that,


emacs told me.
But i'm sure some other editors can tell you that too.

instead of spewing some horrible, pointless, stack trace?

 indeed.

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

Re: NullPointerException

2012-05-17 Thread Armando Blancas
The redefinition of functions somehow is spooking the compiler. But if 
you're at the REPL you should be seeing these warnings (are you doing AOT 
compile?)
WARNING: double already refers to: #'clojure.core/double in namespace: 
user, being replaced by: #'user/double
WARNING: * already refers to: #'clojure.core/* in namespace: user, being 
replaced by: #'user/*

Clojure 1.2 will compile regardless; later versions will produce the NPE. 
There's nothing wrong with your parens or your use of local functions. I 
just changed double to doubl and * to x and it all works fine. The 
stack trace isn't pretty but the warnings would've helped, so it's good to 
try things at the REPL.

On Wednesday, May 16, 2012 3:25:20 PM UTC-7, Sargash wrote:

 Hi! 

 I have a problem. With that code: 

 ; === 
 ; ex 1.17 multiply 
 (defn ex1_17 [] 
   (defn double [x] (+ x x)) 
   (defn halve [x] (/ x 2)) 

   (defn * [a b] 
 (cond 
   (= b 0) 0 
   (even? b) (* (double a) (halve b)) 
   :else (+ a (* a (- b 1) 

   (println (* 5 5)) 
 ) 
 (ex1_17 ) 

 I gave that exception: 

 Exception in thread main java.lang.NullPointerException, compiling: 
 (D:\workprivate\ll\1\src\first.clj:3) 
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462) 
 at clojure.lang.Compiler.analyze(Compiler.java:6262) 
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443) 
 at clojure.lang.Compiler.analyze(Compiler.java:6262) 
 at clojure.lang.Compiler.access$100(Compiler.java:37) 
 at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:518) 
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455) 
 at clojure.lang.Compiler.analyze(Compiler.java:6262) 
 at clojure.lang.Compiler.analyze(Compiler.java:6223) 
 at clojure.lang.Compiler.eval(Compiler.java:6515) 
 at clojure.lang.Compiler.load(Compiler.java:6952) 
 at clojure.lang.Compiler.loadFile(Compiler.java:6912) 
 at clojure.main$load_script.invoke(main.clj:283) 
 at clojure.main$script_opt.invoke(main.clj:343) 
 at clojure.main$main.doInvoke(main.clj:427) 
 at clojure.lang.RestFn.invoke(RestFn.java:408) 
 at clojure.lang.Var.invoke(Var.java:415) 
 at clojure.lang.AFn.applyToHelper(AFn.java:161) 
 at clojure.lang.Var.applyTo(Var.java:532) 
 at clojure.main.main(main.java:37) 
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
 at 
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 
 39) 
 at 
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
  

 25) 
 at java.lang.reflect.Method.invoke(Method.java:597) 
 at 
 com.intellij.rt.execution.application.AppMain.main(AppMain.java: 
 120) 
 Caused by: java.lang.NullPointerException 
 at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4774) 
 at clojure.lang.Compiler$DefExpr.emit(Compiler.java:418) 
 at clojure.lang.Compiler$BodyExpr.emit(Compiler.java:5659) 
 at clojure.lang.Compiler$FnMethod.doEmit(Compiler.java:5215) 
 at clojure.lang.Compiler$FnMethod.emit(Compiler.java:5069) 
 at clojure.lang.Compiler$FnExpr.emitMethods(Compiler.java:3600) 
 at clojure.lang.Compiler$ObjExpr.compile(Compiler.java:4233) 
 at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3732) 
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6453) 
 ... 24 more 

 Could you tell me where I wrong?

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

Re: NullPointerException

2012-05-17 Thread Alan Malloy
There's nothing wrong is a pretty strong statement. It works, but it
is definitely the wrong way to do things. Using a letfn, or external
helper functions, is a much better approach.

On May 17, 12:19 pm, Armando Blancas abm221...@gmail.com wrote:
 The redefinition of functions somehow is spooking the compiler. But if
 you're at the REPL you should be seeing these warnings (are you doing AOT
 compile?)
 WARNING: double already refers to: #'clojure.core/double in namespace:
 user, being replaced by: #'user/double
 WARNING: * already refers to: #'clojure.core/* in namespace: user, being
 replaced by: #'user/*

 Clojure 1.2 will compile regardless; later versions will produce the NPE.
 There's nothing wrong with your parens or your use of local functions. I
 just changed double to doubl and * to x and it all works fine. The
 stack trace isn't pretty but the warnings would've helped, so it's good to
 try things at the REPL.







 On Wednesday, May 16, 2012 3:25:20 PM UTC-7, Sargash wrote:

  Hi!

  I have a problem. With that code:

  ; ===
  ; ex 1.17 multiply
  (defn ex1_17 []
    (defn double [x] (+ x x))
    (defn halve [x] (/ x 2))

    (defn * [a b]
      (cond
        (= b 0) 0
        (even? b) (* (double a) (halve b))
        :else (+ a (* a (- b 1)

    (println (* 5 5))
  )
  (ex1_17 )

  I gave that exception:

  Exception in thread main java.lang.NullPointerException, compiling:
  (D:\workprivate\ll\1\src\first.clj:3)
          at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462)
          at clojure.lang.Compiler.analyze(Compiler.java:6262)
          at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443)
          at clojure.lang.Compiler.analyze(Compiler.java:6262)
          at clojure.lang.Compiler.access$100(Compiler.java:37)
          at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:518)
          at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455)
          at clojure.lang.Compiler.analyze(Compiler.java:6262)
          at clojure.lang.Compiler.analyze(Compiler.java:6223)
          at clojure.lang.Compiler.eval(Compiler.java:6515)
          at clojure.lang.Compiler.load(Compiler.java:6952)
          at clojure.lang.Compiler.loadFile(Compiler.java:6912)
          at clojure.main$load_script.invoke(main.clj:283)
          at clojure.main$script_opt.invoke(main.clj:343)
          at clojure.main$main.doInvoke(main.clj:427)
          at clojure.lang.RestFn.invoke(RestFn.java:408)
          at clojure.lang.Var.invoke(Var.java:415)
          at clojure.lang.AFn.applyToHelper(AFn.java:161)
          at clojure.lang.Var.applyTo(Var.java:532)
          at clojure.main.main(main.java:37)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
  39)
          at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp 
  l.java:

  25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at
  com.intellij.rt.execution.application.AppMain.main(AppMain.java:
  120)
  Caused by: java.lang.NullPointerException
          at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4774)
          at clojure.lang.Compiler$DefExpr.emit(Compiler.java:418)
          at clojure.lang.Compiler$BodyExpr.emit(Compiler.java:5659)
          at clojure.lang.Compiler$FnMethod.doEmit(Compiler.java:5215)
          at clojure.lang.Compiler$FnMethod.emit(Compiler.java:5069)
          at clojure.lang.Compiler$FnExpr.emitMethods(Compiler.java:3600)
          at clojure.lang.Compiler$ObjExpr.compile(Compiler.java:4233)
          at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3732)
          at clojure.lang.Compiler.analyzeSeq(Compiler.java:6453)
          ... 24 more

  Could you tell me where I wrong?

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


Re: NullPointerException

2012-05-17 Thread Moritz Ulrich
It's called Emacs + Paredit :-)

On Thu, May 17, 2012 at 8:00 PM, Raoul Duke rao...@gmail.com wrote:
 some day we'll have the technology to let the compiler tell us that,
 instead of spewing some horrible, pointless, stack trace?



-- 
Moritz Ulrich

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


Re: NullPointerException

2012-05-17 Thread Armando Blancas


 There's nothing wrong is a pretty strong statement. 


LOL. Perhaps as strong as it is definitely the wrong way to do things? 
Jeez.

Pedantry is the wrong way to welcome newbies to this board.

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

Re: NullPointerException

2012-05-17 Thread Raoul Duke
On Thu, May 17, 2012 at 12:52 PM, Armando Blancas abm221...@gmail.com wrote:
 Pedantry is the wrong way to welcome newbies to this board.

stop with your pedantry about there must be no pedantry?

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


Re: NullPointerException

2012-05-17 Thread Evan Mezeske
On Thursday, May 17, 2012 12:52:27 PM UTC-7, Armando Blancas wrote:

 There's nothing wrong is a pretty strong statement.


 LOL. Perhaps as strong as it is definitely the wrong way to do things? 
 Jeez.

 Pedantry is the wrong way to welcome newbies to this board.


Far from being pedantic, Alan's advice was extremely practical.  Anyone 
with moderate Clojure experience will agree that letfn or helper functions 
are actually what the OP wants, rather than def inside def.  As a newcomer, 
it's helpful to find out about these kinds of things as early as possible.

Your original advice, that There's nothing wrong with [...] your use of 
local functions not only fails to convey the fact that the OP's approach 
is probably not what they want -- it's also just plain wrong.  Those are 
not local functions: def always operates at top-level.


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

Re: NullPointerException

2012-05-17 Thread Armando Blancas


 -- it's also just plain wrong.  Those are not local functions: def always 
 operates at top-level.


Big deal. You see what I mean? Pedantry is contagious.

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

Re: NullPointerException

2012-05-17 Thread Raoul Duke
On Thu, May 17, 2012 at 1:25 PM, Armando Blancas abm221...@gmail.com wrote:
 -- it's also just plain wrong.  Those are not local functions: def always
 operates at top-level.
 Big deal. You see what I mean? Pedantry is contagious.

er, i should think it *is* a big deal: programming languages really
don't give one much room / do give one plenty of rope to hang oneself
by. (anybody remember the high-school thing where you have to write
natural language instructions for somebody on how to make a peanut
butter sandwich?)

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


Re: NullPointerException

2012-05-17 Thread Evan Mezeske
On Thursday, May 17, 2012 1:25:45 PM UTC-7, Armando Blancas wrote:

 -- it's also just plain wrong.  Those are not local functions: def always 
 operates at top-level.


 Big deal. You see what I mean? Pedantry is contagious.


Well, I guess if trying not to give newcomers blatantly false information 
is what you consider pedantry, then I'm all for it, and I'm glad to hear 
that it's contagious.

Also, *plonk*.

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

Re: NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-09 Thread Brian Marick

On Nov 8, 2011, at 6:44 PM, Stuart Halloway wrote:

 Line 4 of midje.util.report is unusual in several ways:  it precedes the ns 
 call, adds a second ns call, does an eval, and uses def forms not at the top 
 level:

Thanks, Stu. That code was a patch that came in when I was new to Clojure, and 
I didn't understand it. I think it was a workaround for something in Clojure 
1.1. I bet I can figure it out now.

-
Brian Marick, Artisanal Labrador
Now working at http://path11.com
Contract programming in Ruby and Clojure
Occasional consulting on Agile


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


Re: NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-09 Thread Brian Marick

On Nov 8, 2011, at 8:47 PM, Alan Malloy wrote:
 (let [ns-obj (the-ns (doto 'clojure.test require))
   the-var (intern ns-obj 'old-report)]
   (when-not (.hasRoot the-var)
 (intern ns-obj 'old-report clojure.test/report)))
 
 Seems to have the same effect as the defonce in some simple testing.
 
 Of course it's silly to use intern the second time: (.setRoot the-var
 clojure.test/report) would have been simpler. 

Thank you. You've made a user happy.

(You meant .bindRoot rather than .setRoot, right?)


-
Brian Marick, Artisanal Labrador
Now working at http://path11.com
Contract programming in Ruby and Clojure
Occasional consulting on Agile


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


Re: NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-09 Thread Stuart Halloway
 Line 4 of midje.util.report is unusual in several ways:  it precedes the ns 
 call, adds a second ns call, does an eval, and uses def forms not at the top 
 level:
 
 Thanks, Stu. That code was a patch that came in when I was new to Clojure, 
 and I didn't understand it. I think it was a workaround for something in 
 Clojure 1.1. I bet I can figure it out now.

Let me know if you don't find a workaround -- I would still like to understand 
that NPE.

Stu

Stuart Halloway
Clojure/core
http://clojure.com

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

Re: NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-09 Thread Brian Marick

On Nov 9, 2011, at 4:58 PM, Stuart Halloway wrote:

 Line 4 of midje.util.report is unusual in several ways:  it precedes the ns 
 call, adds a second ns call, does an eval, and uses def forms not at the 
 top level:
 
 Thanks, Stu. That code was a patch that came in when I was new to Clojure, 
 and I didn't understand it. I think it was a workaround for something in 
 Clojure 1.1. I bet I can figure it out now.
 
 Let me know if you don't find a workaround -- I would still like to 
 understand that NPE.

It's all better now. Alan Malloy's fix worked fine on Clojure 1.2.1 and 1.3.


-
Brian Marick, Artisanal Labrador
Now working at http://path11.com
Contract programming in Ruby and Clojure
Occasional consulting on Agile


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


NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-08 Thread Brian Marick
This is under clojure 1.2.0, 1.2.1, 1.3.0, though the error messages differ.

Consider a trivial project that `uses` midje:

(ns midje-aot.core
  (:use midje.sweet))

If it's aot-compiled, everything appears to go well:

1762 $ lein compile
Copying 6 files to /Users/marick/src/midje-aot/lib
Copying 1 file to /Users/marick/src/midje-aot/lib/dev
Compiling midje-aot.core
Compilation succeeded.

But certain of the namespaces can't be loaded:

1766 $ lein repl
REPL started; server listening on localhost port 40437
user= (require 'midje.semi-sweet)
NullPointerException   clojure.lang.Compiler.lookupVar (Compiler.java:6780)

What could that exception mean? What's a starting point for debugging?

-
Brian Marick, Artisanal Labrador
Now working at http://path11.com
Contract programming in Ruby and Clojure
Occasional consulting on Agile


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


Re: NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-08 Thread Stuart Halloway
 This is under clojure 1.2.0, 1.2.1, 1.3.0, though the error messages differ.
 
 Consider a trivial project that `uses` midje:
 
(ns midje-aot.core
  (:use midje.sweet))
 
 If it's aot-compiled, everything appears to go well:
 
1762 $ lein compile
Copying 6 files to /Users/marick/src/midje-aot/lib
Copying 1 file to /Users/marick/src/midje-aot/lib/dev
Compiling midje-aot.core
Compilation succeeded.
 
 But certain of the namespaces can't be loaded:
 
 1766 $ lein repl
 REPL started; server listening on localhost port 40437
 user= (require 'midje.semi-sweet)
 NullPointerException   clojure.lang.Compiler.lookupVar (Compiler.java:6780)
 
 What could that exception mean? What's a starting point for debugging?

The full stack trace:

clojure.lang.Compiler.lookupVar (Compiler.java:6780)
clojure.lang.Compiler.isMacro (Compiler.java:6260)
clojure.lang.Compiler.macroexpand1 (Compiler.java:6315)
clojure.lang.Compiler.macroexpand (Compiler.java:6381)
clojure.lang.Compiler.eval (Compiler.java:6449)
clojure.lang.Compiler.eval (Compiler.java:6454)
clojure.lang.Compiler.eval (Compiler.java:6431)
clojure.core/eval (core.clj:2795)
midje.util.report__init.load (:4)
midje.util.report__init.clinit (:-1)
java.lang.Class.forName0 (Class.java:-2)
java.lang.Class.forName (Class.java:247)

Line 4 of midje.util.report is unusual in several ways:  it precedes the ns 
call, adds a second ns call, does an eval, and uses def forms not at the top 
level:

(when (= (class clojure.test/report) clojure.lang.MultiFn)
  (eval
   '(do (require 'clojure.test)
(ns clojure.test)
(defonce old-report clojure.test/report

Not sure where the problem is yet, and I have no time to look further tonight, 
but perhaps this will help somebody track the root cause.

Stu

Stuart Halloway
Clojure/core
http://clojure.com

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

Re: NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-08 Thread Alan Malloy
On Nov 8, 4:44 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:
  This is under clojure 1.2.0, 1.2.1, 1.3.0, though the error messages differ.

  Consider a trivial project that `uses` midje:

     (ns midje-aot.core
       (:use midje.sweet))

  If it's aot-compiled, everything appears to go well:

     1762 $ lein compile
     Copying 6 files to /Users/marick/src/midje-aot/lib
     Copying 1 file to /Users/marick/src/midje-aot/lib/dev
     Compiling midje-aot.core
     Compilation succeeded.

  But certain of the namespaces can't be loaded:

  1766 $ lein repl
  REPL started; server listening on localhost port 40437
  user= (require 'midje.semi-sweet)
  NullPointerException   clojure.lang.Compiler.lookupVar (Compiler.java:6780)

  What could that exception mean? What's a starting point for debugging?

 The full stack trace:

         clojure.lang.Compiler.lookupVar (Compiler.java:6780)
         clojure.lang.Compiler.isMacro (Compiler.java:6260)
         clojure.lang.Compiler.macroexpand1 (Compiler.java:6315)
         clojure.lang.Compiler.macroexpand (Compiler.java:6381)
         clojure.lang.Compiler.eval (Compiler.java:6449)
         clojure.lang.Compiler.eval (Compiler.java:6454)
         clojure.lang.Compiler.eval (Compiler.java:6431)
         clojure.core/eval (core.clj:2795)
         midje.util.report__init.load (:4)
         midje.util.report__init.clinit (:-1)
         java.lang.Class.forName0 (Class.java:-2)
         java.lang.Class.forName (Class.java:247)

 Line 4 of midje.util.report is unusual in several ways:  it precedes the ns 
 call, adds a second ns call, does an eval, and uses def forms not at the top 
 level:

 (when (= (class clojure.test/report) clojure.lang.MultiFn)
   (eval
    '(do (require 'clojure.test)
         (ns clojure.test)
         (defonce old-report clojure.test/report

 Not sure where the problem is yet, and I have no time to look further 
 tonight, but perhaps this will help somebody track the root cause.

At least you could simplify this and avoid using eval, by using
clojure.core/intern directly instead of trying to get the compiler to
believe you're in that namespace. Grabbing the source for the defonce
macro, here's a draft of how I might rewrite this to avoid eval:

(let [ns-obj (the-ns (doto 'clojure.test require))
  the-var (intern ns-obj 'old-report)]
  (when-not (.hasRoot the-var)
(intern ns-obj 'old-report clojure.test/report)))

Seems to have the same effect as the defonce in some simple testing.

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


Re: NullPointerException in c.l.Compiler.lookupVar after aot compilation: means what?

2011-11-08 Thread Alan Malloy
On Nov 8, 6:46 pm, Alan Malloy a...@malloys.org wrote:
 On Nov 8, 4:44 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:
   This is under clojure 1.2.0, 1.2.1, 1.3.0, though the error messages 
   differ.

   Consider a trivial project that `uses` midje:

      (ns midje-aot.core
        (:use midje.sweet))

   If it's aot-compiled, everything appears to go well:

      1762 $ lein compile
      Copying 6 files to /Users/marick/src/midje-aot/lib
      Copying 1 file to /Users/marick/src/midje-aot/lib/dev
      Compiling midje-aot.core
      Compilation succeeded.

   But certain of the namespaces can't be loaded:

   1766 $ lein repl
   REPL started; server listening on localhost port 40437
   user= (require 'midje.semi-sweet)
   NullPointerException   clojure.lang.Compiler.lookupVar 
   (Compiler.java:6780)

   What could that exception mean? What's a starting point for debugging?

  The full stack trace:

          clojure.lang.Compiler.lookupVar (Compiler.java:6780)
          clojure.lang.Compiler.isMacro (Compiler.java:6260)
          clojure.lang.Compiler.macroexpand1 (Compiler.java:6315)
          clojure.lang.Compiler.macroexpand (Compiler.java:6381)
          clojure.lang.Compiler.eval (Compiler.java:6449)
          clojure.lang.Compiler.eval (Compiler.java:6454)
          clojure.lang.Compiler.eval (Compiler.java:6431)
          clojure.core/eval (core.clj:2795)
          midje.util.report__init.load (:4)
          midje.util.report__init.clinit (:-1)
          java.lang.Class.forName0 (Class.java:-2)
          java.lang.Class.forName (Class.java:247)

  Line 4 of midje.util.report is unusual in several ways:  it precedes the ns 
  call, adds a second ns call, does an eval, and uses def forms not at the 
  top level:

  (when (= (class clojure.test/report) clojure.lang.MultiFn)
    (eval
     '(do (require 'clojure.test)
          (ns clojure.test)
          (defonce old-report clojure.test/report

  Not sure where the problem is yet, and I have no time to look further 
  tonight, but perhaps this will help somebody track the root cause.

 At least you could simplify this and avoid using eval, by using
 clojure.core/intern directly instead of trying to get the compiler to
 believe you're in that namespace. Grabbing the source for the defonce
 macro, here's a draft of how I might rewrite this to avoid eval:

 (let [ns-obj (the-ns (doto 'clojure.test require))
       the-var (intern ns-obj 'old-report)]
   (when-not (.hasRoot the-var)
     (intern ns-obj 'old-report clojure.test/report)))

 Seems to have the same effect as the defonce in some simple testing.

Of course it's silly to use intern the second time: (.setRoot the-var
clojure.test/report) would have been simpler. And of course I don't
know whether this will fix the problem, but it seems like it should at
least simplify it.

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


Re: SICP sqrt function generates unexpected NullPointerException

2011-10-16 Thread Timo Grodzinski
+1 hangs with Clojure 1.2.1 in Slimes REPL on Java 1.6.0_26 (Ubuntu)

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

Re: SICP sqrt function generates unexpected NullPointerException

2011-10-16 Thread Alan Malloy
An infinite loop on large inputs is unrelated to his null-pointer
problem. As SICP makes clear, the imprecision of floating-point
arithmetic means this particular algorithm will not terminate for
large inputs. That is, rounding errors stop it from making progress
when the numbers are large and the deltas small. If a larger (or
adaptive) delta were chosen, this would succeed.

On Oct 16, 4:52 am, Timo Grodzinski timo.grodzin...@googlemail.com
wrote:
 +1 hangs with Clojure 1.2.1 in Slimes REPL on Java 1.6.0_26 (Ubuntu)

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


SICP sqrt function generates unexpected NullPointerException

2011-10-14 Thread Alan O'Donnell
Hi everyone,

I've encountered an unexpected NullPointerException while translating
some early SICP code into Clojure 1.3.0. In particular, I'm
implementing the iterative sqrt procedure from section 1.1.7.

Here's my code:

(defn square [x] (* x x))

(defn abs [x]
  (cond
( x 0) (- x)
:else x))

(defn average [x y]
  (/ (+ x y) 2))

(defn sqrt
  ([x] (sqrt 1.0 x))
  ([guess x]
(letfn [(good-enough? [guess]
  ( (abs (- (square guess) x)) 0.001))
(improve [guess]
  (average guess (/ x guess)))]
  (if (good-enough? guess)
guess
(recur (improve guess) x)

Rather mysteriously, this works correctly for inputs less than roughly
(square 2718.259...); anything larger throws a NullPointerException
clojure.lang.Numbers.lt (Numbers.java:3693).

Any ideas?

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


Re: SICP sqrt function generates unexpected NullPointerException

2011-10-14 Thread Armando Blancas
With 1.3/OSX this code worked up to:

user= (sqrt 1)
100.0

and then hanged here:

user= (sqrt 10)
~ $

On Oct 13, 7:04 pm, Alan O'Donnell alan.m.odonn...@gmail.com
wrote:
 Hi everyone,

 I've encountered an unexpected NullPointerException while translating
 some early SICP code into Clojure 1.3.0. In particular, I'm
 implementing the iterative sqrt procedure from section 1.1.7.

 Here's my code:

 (defn square [x] (* x x))

 (defn abs [x]
   (cond
     ( x 0) (- x)
     :else x))

 (defn average [x y]
   (/ (+ x y) 2))

 (defn sqrt
   ([x] (sqrt 1.0 x))
   ([guess x]
     (letfn [(good-enough? [guess]
               ( (abs (- (square guess) x)) 0.001))
             (improve [guess]
               (average guess (/ x guess)))]
       (if (good-enough? guess)
         guess
         (recur (improve guess) x)

 Rather mysteriously, this works correctly for inputs less than roughly
 (square 2718.259...); anything larger throws a NullPointerException
 clojure.lang.Numbers.lt (Numbers.java:3693).

 Any ideas?

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


Re: SICP sqrt function generates unexpected NullPointerException

2011-10-14 Thread Alan O'Donnell
Armando, I get the same behavior as you with Clojure 1.2.1. But if I lein 
dep Clojure 1.3.0, I'm back to NullPointerExceptions.

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

Re: NullPointerException on disj

2010-05-27 Thread Rich Hickey


On May 27, 1:10 am, Allen Johnson akjohnso...@gmail.com wrote:
 Hey everyone. I was playing around with the protocols/deftype stuff
 and ran into a weird NullPointerException when calling the satisfies?
 function. Seems to only happen with a java.lang.Object instance.

 Clojure 1.2.0-master-SNAPSHOT
 user= (defprotocol Greeter (greet [this]))
 Greeter
 user= (satisfies? Greeter nil)
 false
 user= (satisfies? Greeter )
 false
 user= (satisfies? Greeter (Object.))
 java.lang.NullPointerException (NO_SOURCE_FILE:0)

 Narrowed it down to this function:

 ;; core_deftype.clj
 (defn find-protocol-impl [protocolx]
   (if (instance? (:on-interfaceprotocol) x)
     x
     (let [c (class x)
           impl #(get (:implsprotocol) %)]
       (or (impl c)
           (and c (or (first (remove nil? (map impl (butlast (super-chain 
 c)
                      (when-let [t (reduce pref (filter impl (disj
 (supers c) Object)))]
                        (impl t))
                      (impl Object)))

 More specifically, here:

 (disj (supers c) Object)

 Since in this case, `c` is java.lang.Object, supers returns nil which
 disj doesn't seem to like. Shouldn't disj handle nil gracefully?


Yes, could you please enter a ticket for this?

Thanks,

Rich

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


NullPointerException on disj

2010-05-26 Thread Allen Johnson
Hey everyone. I was playing around with the protocols/deftype stuff
and ran into a weird NullPointerException when calling the satisfies?
function. Seems to only happen with a java.lang.Object instance.

Clojure 1.2.0-master-SNAPSHOT
user= (defprotocol Greeter (greet [this]))
Greeter
user= (satisfies? Greeter nil)
false
user= (satisfies? Greeter )
false
user= (satisfies? Greeter (Object.))
java.lang.NullPointerException (NO_SOURCE_FILE:0)

Narrowed it down to this function:

;; core_deftype.clj
(defn find-protocol-impl [protocol x]
  (if (instance? (:on-interface protocol) x)
x
(let [c (class x)
  impl #(get (:impls protocol) %)]
  (or (impl c)
  (and c (or (first (remove nil? (map impl (butlast (super-chain c)
 (when-let [t (reduce pref (filter impl (disj
(supers c) Object)))]
   (impl t))
 (impl Object)))

More specifically, here:

(disj (supers c) Object)

Since in this case, `c` is java.lang.Object, supers returns nil which
disj doesn't seem to like. Shouldn't disj handle nil gracefully?

Thanks,
Allen

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


Clojars.org artifact upload issue - NullPointerException

2010-04-01 Thread Shantanu Kumar
Hi,

I am trying to upload a JAR to Clojars.org but I am getting
NullPointerException. Can somebody help me understand what's going on?
The log is below:

D:\projects\hgrepos\jettify\jettify-parent\jettify-java\targetscp
pom.xml jettify-java-0.2.jar cloj...@clojars.org:
Welcome to Clojars, kumarshantanu!
pom.xml
100% 2539 2.5KB/s   00:00
jettify-
java-0.2.jar
100% 3780 3.7KB/s   00:00
Error: transaction rolled back: null
java.lang.Exception: transaction rolled back: null
at clojure.contrib.sql.internal
$throw_rollback__7448.invoke(internal.clj:135)
at clojure.contrib.sql.internal
$transaction_STAR___7451.invoke(internal.clj:162)
at clojars.db$add_jar__134$fn__137.invoke(db.clj:163)
at clojure.contrib.sql.internal
$with_connection_STAR___7428.invoke(internal.clj:98)
at clojars.db$add_jar__134.doInvoke(db.clj:162)
at clojure.lang.RestFn.invoke(RestFn.java:445)
at clojars.scp$finish_deploy__51.invoke(scp.clj:123)
at clojars.scp$nail__86.invoke(scp.clj:162)
at clojars.scp$_nailMain__93.invoke(scp.clj:174)
at clojars.scp.nailMain(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)
at java.lang.reflect.Method.invoke(Method.java:616)
at com.martiansoftware.nailgun.NGSession.run(Unknown Source)
Caused by: java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Matcher.java:1151)
at java.util.regex.Matcher.reset(Matcher.java:308)
at java.util.regex.Matcher.init(Matcher.java:228)
at java.util.regex.Pattern.matcher(Pattern.java:905)
at clojure.core$re_matcher__5789.invoke(core.clj:3143)
at clojure.core$re_matches__5803.invoke(core.clj:3175)
at clojars.db$check_and_add_group__128.invoke(db.clj:144)
at clojars.db$add_jar__134$fn__137$fn__139.invoke(db.clj:165)
at clojure.contrib.sql.internal
$transaction_STAR___7451.invoke(internal.clj:153)
... 13 more

The pom.xml has the following content:

project xmlns=http://maven.apache.org/POM/4.0.0; xmlns:xsi=http://
www.w3.org/2001/XMLSchema-instance
  xsi:schemaLocation=http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd;
  modelVersion4.0.0/modelVersion
  parent
groupIdorg.bitumenframework.jettify/groupId
artifactIdjettify-parent/artifactId
version0.2/version
  /parent
  artifactIdjettify-java/artifactId
  packagingjar/packaging

  version0.2/version

  namejettify-java/name

  urlhttp://code.google.com/p/bitumenframework//url

  dependencies
dependency
  groupIdorg.mortbay.jetty/groupId
  artifactIdjetty/artifactId
  version6.1.22/version
/dependency
dependency
  groupIdjavax.servlet/groupId
  artifactIdservlet-api/artifactId
  version2.5/version
  scopeprovided/scope
/dependency
dependency
  groupIdjunit/groupId
  artifactIdjunit/artifactId
  version4.7/version
  scopetest/scope
/dependency
dependency
  groupIdorg.mortbay.jetty/groupId
  artifactIdjetty-embedded/artifactId
  version6.1.22/version
/dependency
dependency
  groupIdorg.mortbay.jetty/groupId
  artifactIdjsp-2.1-jetty/artifactId
  version6.1.22/version
/dependency
dependency
  groupIdorg.apache.httpcomponents/groupId
  artifactIdhttpclient/artifactId
  version4.0.1/version
  scopetest/scope
/dependency
dependency
  groupIdorg.bitumenframework.jettify/groupId
  artifactIdjettify-test-support/artifactId
  version0.2/version
  scopetest/scope
/dependency
  /dependencies
  build
plugins
  plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-surefire-plugin/artifactId
configuration
  systemProperties
property
  namebasedir/name
  value${basedir}/value
/property
  /systemProperties
/configuration
  /plugin
  plugin
groupIdorg.mortbay.jetty/groupId
artifactIdjetty-maven-plugin/artifactId
  /plugin
  plugin
artifactIdmaven-compiler-plugin/artifactId
configuration
  source1.5/source
  target1.5/target
/configuration
  /plugin
/plugins
  /build
/project


Regards,
Shantanu

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

To unsubscribe, reply using remove me

Re: Clojars.org artifact upload issue - NullPointerException

2010-04-01 Thread Alex Osborne
Hi Shantanu,

Shantanu Kumar kumar.shant...@gmail.com writes:

   artifactIdjettify-java/artifactId
   packagingjar/packaging
   version0.2/version
   namejettify-java/name
   urlhttp://code.google.com/p/bitumenframework//url

You appear to not be specifying a groupId in your POM.  Try adding one.

Cheers,

Alex

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

To unsubscribe, reply using remove me as the subject.


Re: Clojars.org artifact upload issue - NullPointerException

2010-04-01 Thread Shantanu Kumar


On Apr 2, 4:37 am, Alex Osborne a...@meshy.org wrote:
 Hi Shantanu,

 Shantanu Kumar kumar.shant...@gmail.com writes:
    artifactIdjettify-java/artifactId
    packagingjar/packaging
    version0.2/version
    namejettify-java/name
    urlhttp://code.google.com/p/bitumenframework//url

 You appear to not be specifying a groupId in your POM.  Try adding one.

It worked. Thanks!

Regards,
Shantanu

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

To unsubscribe, reply using remove me as the subject.


NullPointerException from #' et al.

2010-01-14 Thread C. Florian Ebeling
Hi,

out of curiosity, what is the reasoning behind this behavior (I'm
pretty sure it is intended):

(= nil 1)
= false

( nil 1) ;; NullPointerException

Same behavior for = = etc.

Florian



-- 
Florian Ebeling
florian.ebel...@gmail.com
-- 
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

Re: NullPointerException from #' et al.

2010-01-14 Thread ataggart
What do you think should be the boolean result of ( nil 1)?

Since the inequality functions only work with Numbers, and nil is not
a Number.  The only way to make that work would be to impute some
default numerical value to nil, which would probably introduce more
problems than it solved.


On Jan 14, 7:57 am, C. Florian Ebeling florian.ebel...@gmail.com
wrote:
 Hi,

 out of curiosity, what is the reasoning behind this behavior (I'm
 pretty sure it is intended):

 (= nil 1)
 = false

 ( nil 1) ;; NullPointerException

 Same behavior for = = etc.

 Florian

 --
 Florian Ebeling
 florian.ebel...@gmail.com
-- 
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

Re: NullPointerException from #' et al.

2010-01-14 Thread C. Florian Ebeling
 What do you think should be the boolean result of ( nil 1)?

 Since the inequality functions only work with Numbers, and nil is not
 a Number.  The only way to make that work would be to impute some
 default numerical value to nil, which would probably introduce more
 problems than it solved.

I agree. It only looks inconsistent when you assume nil is treated
uniformly by these comparison function, which does not make sense.
Sorry, this question was probably a tad stupid :)


-- 
Florian Ebeling
florian.ebel...@gmail.com
-- 
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

Re: NullPointerException from #' et al.

2010-01-14 Thread ataggart


On Jan 14, 9:00 am, C. Florian Ebeling florian.ebel...@gmail.com
wrote:
  What do you think should be the boolean result of ( nil 1)?

  Since the inequality functions only work with Numbers, and nil is not
  a Number.  The only way to make that work would be to impute some
  default numerical value to nil, which would probably introduce more
  problems than it solved.

 I agree. It only looks inconsistent when you assume nil is treated
 uniformly by these comparison function, which does not make sense.

Perhaps you should use compare, which doesn't have the numerical
restriction and also works well with nil.
-- 
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

Re: NullPointerException from #' et al.

2010-01-14 Thread ataggart
Also, it is consistent given that == is the numerical analogue to =,
etc.
-- 
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

Re: NullPointerException from #' et al.

2010-01-14 Thread Timothy Pratley
2010/1/15 C. Florian Ebeling florian.ebel...@gmail.com:
 I agree. It only looks inconsistent when you assume nil is treated
 uniformly by these comparison function, which does not make sense.


I quite often wish to compare comparable objects that are not numbers
and wrote some simple operators to do that:
user= (? \a \b \c)
true
user= (? \c \b)
false
user= (? 1 nil)
false
user= (? nil 1)
true

Which would work in your situation...

However if you are using numbers but sometimes encounter nil, then a
better solution would be to use fnil, which is a function that returns
a function that will substitute any nil arguments with some default
value. This is very handy shorthand when you have nil data points that
you want to treat as zero:

user= ((fnil 0 0 ) nil 1)
true
user= ((fnil 0 0 ) 1 nil)
false

You can find the implementation for both object comparator operators
and fnil from my github if you are interested:
http://github.com/timothypratley/strive/blob/master/clj/timothypratley/extensions.clj



Regards,
Tim.
-- 
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

NullPointerException with defmacro and none without?!

2009-09-01 Thread Sir Diddymus

Hi all,

I'm new to Clojure and I'm playing around with Qt Jambi, which works
as expected, until I started to use a self written macro. Now I don't
know if this is just a problem I don't see (probably) or if it is a
bug in Clojure. I have the following sample code (I hope this is
readable when posted. Otherwise I'll use something like pastebin):


 (ns a.namespace.sample
   (:gen-class)
   (:import
  (com.trolltech.qt.gui QApplication QMainWindow)))

 (defmacro RunQt [args  body]
   `(
 (try
   (QApplication/initialize (into-array [~args]))
   (catch RuntimeException e# (println e#)))
 ~...@body
 (QApplication/exec)))


 (defn -main [args]
   (RunQt args
 (let [mainWindow (QMainWindow.)]
   (.show mainWindow

 (defn -main2 [args]
   (try
 (QApplication/initialize (into-array [args]))
 (catch RuntimeException e (println e)))
   (let [mainWindow (QMainWindow.)]
 (.show mainWindow))
   (QApplication/exec))


 ; (-main )
 ; (-main2 )


Now both -main and -main2 work as expected, they show a simple Window
with nothing in it. So far so good. But after I close the Window, -
main throws the following exception:

 Exception in thread main java.lang.NullPointerException (qtest.clj:0)
 at clojure.lang.Compiler.eval(Compiler.java:4543)
 at clojure.lang.Compiler.load(Compiler.java:4857)
 at clojure.lang.Compiler.loadFile(Compiler.java:4824)
 at clojure.main$load_script__5833.invoke(main.clj:206)
 at clojure.main$script_opt__5864.invoke(main.clj:258)
 at clojure.main$main__5888.doInvoke(main.clj:333)
 at clojure.lang.RestFn.invoke(RestFn.java:413)
 at clojure.lang.Var.invoke(Var.java:346)
 at clojure.lang.AFn.applyToHelper(AFn.java:173)
 at clojure.lang.Var.applyTo(Var.java:463)
 at clojure.main.main(main.java:39)
 Caused by: java.lang.NullPointerException
 at a.namespace.sample$_main__8.invoke(qtest.clj:16)
 at a.namespace.sample$eval__20.invoke(qtest.clj:29)
 at clojure.lang.Compiler.eval(Compiler.java:4532)
 ... 10 more


whereas -main2 does not. Now they both look to my newbie eyes the
same, except the code of -main is generated by a macro. This is the
same if I compile the code. The uncompiled version I started with
(paths omitted for better readability):

 java -cp clojure.jar;qtjambi-4.5.2_01.jar;qtjambi-win32-msvc2005-4.5.2_01.jar 
 clojure.main qtest.clj


I have this behavior under WinXP and 2k, with Java RE 1.5.x and with
JDK 1.6.0_16, Clojure 1.0.0 and the latest Qt Jambi. Am I just missing
something totally fundamental and this is expected behavior? I fiddled
with this code for I don't know how long, tried this and that but
cannot figure out where this NullPointerException is coming from.

Any help would be appreciated.


Thanks and greetings

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



Re: NullPointerException with defmacro and none without?!

2009-09-01 Thread Meikel Brandmeyer

Hi,

Am 01.09.2009 um 17:44 schrieb Sir Diddymus:


(defmacro RunQt [args  body]
 `(
   (try
 (QApplication/initialize (into-array [~args]))
 (catch RuntimeException e# (println e#)))
   ~...@body
   (QApplication/exec)))


You have to wrap the try and QApplication/exec call into a `do`:

(do
  (try )
  (Qapplication/exec))


(defn -main2 [args]
 (try
   (QApplication/initialize (into-array [args]))
   (catch RuntimeException e (println e)))
 (let [mainWindow (QMainWindow.)]
   (.show mainWindow))
 (QApplication/exec))


`defn` does the `do`-wrapping for you.

You get a NPE, because your macro basically expands to ((try ...)  
(QApplication/exec)). So the return value of the try is used as  
function which is called on the result of the QApp/exec. Now  
obviously QApp/initialize returns nil. Hence the exception.


Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


NullPointerException in Compiler.java

2009-07-03 Thread jon

Hi, could Rich or someone knowledgeable look into this (reflection
related?) NullPointerException in Compiler.java.
I think it's either a bug or at least should provide a better error
message, but I don't have any time to look deeper into it..
Thanks, Jon

-
I was using clojure-1.0 but looks likely to still be a problem with
the trunk.

* compile the below java class and make available on classpath:
   package mypkg;
   public class MyClass {
   public MyClass() {
   }
   Object myField;
   }

* then this line of clojure throws a NullPointerException:
   (set! (.myField (mypkg.MyClass.)) test)

-
When myField definition is private, as above, (or completely removed)
the NullPointerException
occurs. When you add 'public' to myField definition, the problem goes
away..

Looking at InstanceFieldExpr in Compiler.java (approx line 900)..
the emit() and emitUnboxed() functions guard against 'field' being
null
   if(targetClass != null  field != null)
but the emitAssign() function doesn't
   if(targetClass != null)
and therefore in this case field.getType() causes the
NullPointerException

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



Re: NullPointerException in Compiler.java

2009-07-03 Thread Rich Hickey



On Jul 3, 5:27 am, jon superuser...@googlemail.com wrote:
 Hi, could Rich or someone knowledgeable look into this (reflection
 related?) NullPointerException in Compiler.java.
 I think it's either a bug or at least should provide a better error
 message, but I don't have any time to look deeper into it..
 Thanks, Jon

 -
 I was using clojure-1.0 but looks likely to still be a problem with
 the trunk.

 * compile the below java class and make available on classpath:
    package mypkg;
    public class MyClass {
        public MyClass() {
        }
        Object myField;
    }

 * then this line of clojure throws a NullPointerException:
    (set! (.myField (mypkg.MyClass.)) test)

 -
 When myField definition is private, as above, (or completely removed)
 the NullPointerException
 occurs. When you add 'public' to myField definition, the problem goes
 away..

 Looking at InstanceFieldExpr in Compiler.java (approx line 900)..
 the emit() and emitUnboxed() functions guard against 'field' being
 null
    if(targetClass != null  field != null)
 but the emitAssign() function doesn't
    if(targetClass != null)
 and therefore in this case field.getType() causes the
 NullPointerException

Fixed - thanks for the report:

http://www.assembla.com/spaces/clojure/tickets/142-Bug--Compile-time-NPE-on-set!-of-non-existent-field

RIch

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



Re: clojure.contrib.test-is/run-tests throws NullPointerException w/ invalid args

2009-05-06 Thread Stuart Sierra

On May 5, 2:05 pm, Timo Mihaljov noid@gmail.com wrote:
 When clojure.contrib.test-is/run-tests is given an invalid argument, it
 throws a NullPointerException:

Fixed!
-SS
--~--~-~--~~~---~--~~
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
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
-~--~~~~--~~--~--~---



clojure.contrib.test-is/run-tests throws NullPointerException w/ invalid args

2009-05-05 Thread Timo Mihaljov

When clojure.contrib.test-is/run-tests is given an invalid argument, it 
throws a NullPointerException:

user= (use 'clojure.contrib.test-is)
nil
user= (run-tests 'asdf)
java.lang.RuntimeException: java.lang.NullPointerException 
(NO_SOURCE_FILE:0)

The issue seems harmless in a simple case like this, but in a more 
complex case the error is quite hard to debug for two reasons:
- When the stack trace is longer it's not immediately obvious what 
caused the NullPointerException.
- The error can be caused by a simple typo so it's quite easy to miss 
when reading the code because the code reads aloud correctly.

Having something like 'clojure.contrib.test-is.NamespaceException: No 
such namespace asdf' would make the source of the error easy to find.

I found this bug by having a namespace called errorr (deliberate 
typo), and accidentally spelled it correctly as error in the argument 
to run-tests. You might say that I got what I deserved for picking a 
clever Web2.0 name like that (and I would agree :), but keep in mind 
that any other typo would have worked and could have been as hard to find.

As an example, here's the the stack trace that one typo gave me.

Exception in thread main java.lang.RuntimeException: 
java.lang.NullPointerException (run-tests.clj:0)
at clojure.lang.Compiler.eval(Compiler.java:4543)
at clojure.lang.Compiler.load(Compiler.java:4857)
at clojure.lang.Compiler.loadFile(Compiler.java:4824)
at clojure.main$load_script__5833.invoke(main.clj:206)
at clojure.main$script_opt__5864.invoke(main.clj:258)
at clojure.main$main__5888.doInvoke(main.clj:333)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at clojure.lang.Var.invoke(Var.java:346)
at clojure.lang.AFn.applyToHelper(AFn.java:173)
at clojure.lang.Var.applyTo(Var.java:463)
at clojure.main.main(main.java:39)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at clojure.lang.LazySeq.seq(LazySeq.java:46)
at clojure.lang.RT.seq(RT.java:436)
at clojure.core$seq__3133.invoke(core.clj:103)
at clojure.core$spread__3240.invoke(core.clj:383)
at clojure.core$spread__3240.invoke(core.clj:384)
at clojure.core$apply__3243.doInvoke(core.clj:390)
at clojure.lang.RestFn.invoke(RestFn.java:443)
at clojure.contrib.test_is$run_tests__4789.doInvoke(test_is.clj:914)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at errorr.engine.gfx.tests$run__7.invoke(tests.clj:5)
at user$eval__10.invoke(run-tests.clj:2)
at clojure.lang.Compiler.eval(Compiler.java:4532)
... 10 more
Caused by: java.lang.NullPointerException
at 
java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768)
at clojure.lang.Namespace.find(Namespace.java:129)
at clojure.core$find_ns__4309.invoke(core.clj:2347)
at clojure.core$the_ns__4321.invoke(core.clj:2371)
at clojure.core$ns_name__4325.invoke(core.clj:2376)
at clojure.contrib.test_is$fn__4660.invoke(test_is.clj:586)
at clojure.lang.MultiFn.invoke(MultiFn.java:157)
at clojure.contrib.test_is$test_ns__4785.invoke(test_is.clj:896)
at clojure.core$map__3815$fn__3817.invoke(core.clj:1503)
at clojure.lang.LazySeq.seq(LazySeq.java:41)
... 21 more

--
Timo

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



Re: clojure.contrib.test-is/run-tests throws NullPointerException w/ invalid args

2009-05-05 Thread Stuart Sierra

On May 5, 2:05 pm, Timo Mihaljov noid@gmail.com wrote:
 When clojure.contrib.test-is/run-tests is given an invalid argument, it
 throws a NullPointerException:

Yes, I'm aware of this, will try to fix.
-SS


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



Not really a NullPointerException, and repl lines

2008-11-28 Thread Jeff Rose

Clojure
user= (nil (println asd)
)
java.lang.NullPointerException (NO_SOURCE_FILE:1)
user=


This seems like an odd error to get here.  Couldn't it say something 
like invalid function as first value?

It also made me wonder, would it be possible to have a line counter 
inside the REPL, and just use repl as the filename?  The repl could 
optionally show a line-number on every line.  For that matter, it could 
even be interesting to do development from within the repl, if you could 
save to source.  Is it possible to generate the source code from say a 
function or a namespace?

-Jeff

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---