Bug with clojure.set/intersection, clojure.set/difference etc.

2009-01-29 Thread ntupel
If its left argument is nil, "intersection" throws a NPE (Clojure rev. 1235): user=> (set/intersection nil #{1}) java.lang.NullPointerException (NO_SOURCE_FILE:0) user=> (.printStackTrace *e) java.lang.NullPointerException (NO_SOURCE_FILE:0) at clojure.lang.Compiler.eval(Compiler.java:418

compile and gen-class don't seem to work for me

2008-12-12 Thread ntupel
For the first time I tried to use gen-class (using svn r1156), but unfortunately compilation fails: u...@computer /tmp $ mkdir test u...@computer /tmp $ cd test/ u...@computer /tmp/test $ mkdir -p clojure/examples u...@computer /tmp/test $ gvim clojure/examples/instance.clj ;copied the source fr

seq and vector

2008-11-22 Thread ntupel
In one of my data structures I have a vector as a buffer where things are appended to. In addition the things in that buffer sometimes get modified using map or filter. Now as map and filter return sequences I wonder how to get a vector back efficiently. I need a vector in order for conj to append

Agent errors reporting

2008-11-15 Thread ntupel
Currently agent errors are only reported when the agent is derefenced or further actions are dispatched to the agent. It would be great if one can get immediate notification of agent errors maybe through a callback. Thanks, nt --~--~-~--~~~---~--~~ You received th

Re: Proxy Bug?

2008-10-30 Thread ntupel
On Thu, 2008-10-30 at 01:37 -0700, mb wrote: > I lookep up the implementation of proxy-super. It replaces the > method temporarily. So proxy-super basically doesn't work for > methods with multiple implementations for different arglists, > since only the actually called method-arglist combination

Re: Proxy Bug?

2008-10-30 Thread ntupel
On Wed, 2008-10-29 at 23:44 -0700, mb wrote: > But proxy-super to the rescue: You may try the following snippet > for the write method: Nice. Never heard of proxy-super before. Would be nice to mention it on the Java interop page and not only on the API page. > >(write > ([x] >

Proxy Bug?

2008-10-29 Thread ntupel
Consider the following code which attempts to redefine clojure/*out*: (ns test (:refer-clojure)) (def output System/out) (def output-stream (let [buffer (new java.io.ByteArrayOutputStream)] (proxy [java.io.OutputStream] [] (flush [] (.append output (.toString buffer "UTF-

Re: Get thread local bindings

2008-10-11 Thread ntupel
On Fri, 2008-10-10 at 12:46 -0700, Mike Hinchey wrote: > It's usually advised to avoid eval. Many thanks Mike. I would like to avoid eval, but I am too stupid. However I would love to find out how to do it. If you could give me hunch I would be more than happy. > See dothread-keeping in > http:

Get thread local bindings

2008-10-10 Thread ntupel
I still try to find a way to make threads inherit thread-local bindings established via binding in the parent thread. I searched for a function to get the thread bindings but couldn't find one. Did I miss anything? So I added getThreadBindings() to Var.java: diff --git a/trunk/src/jvm/clojure/lan

Re: NPE with binding [was: Repl over Socket, binding and threads]

2008-10-09 Thread ntupel
On Thu, 2008-10-09 at 22:06 +0200, ntupel wrote: > After further investigation and experimentation with macros I finally > managed to trigger a NullpointerException: > > user=> (defmacro on-thread [env exp] `(doto (new Thread #(binding ~env > (~exp))) (start))) Ignore me.

NPE with binding [was: Repl over Socket, binding and threads]

2008-10-09 Thread ntupel
On Thu, 2008-10-09 at 02:30 -0700, [EMAIL PROTECTED] wrote: > As bindings are not inherited by new threads, how can this be done > without actually changing the expressions that are evaluated? > > I know that in March it was briefly discussed, but wouldn't it be > useful to have a binding variant

Repl over Socket, Threads & Bindings

2008-10-09 Thread ntupel
The Clojure wikibook has an example implementation of a Repl over a socket (http://en.wikibooks.org/wiki/Clojure_Programming#Simple_REPL_on_a_Socket). I wonder how to solve the problem of showing output if somewhere in the evaluated expression, a new thread is created that will eventually print

Repl over Socket, Threads & Bindings

2008-10-09 Thread ntupel
The Clojure wikibook has an example implementation of a Repl over a socket (http://en.wikibooks.org/wiki/Clojure_Programming#Simple_REPL_on_a_Socket). I wonder how to solve the problem of showing output if somewhere in the evaluated expression, a new thread is created that will eventually print so

Re: true?

2008-09-30 Thread ntupel
On Tue, 2008-09-30 at 17:29 -0400, Stuart Halloway wrote: > For your specific case you should probably be using contains?, which > works for both. No. contains? is meant for maps, i.e. when applied to vectors it checks against indexes: user=> (contains? [1 2 3] 0) true --~--~-~--~--

true?

2008-09-30 Thread ntupel
The following looks weird to me: Clojure user=> (.contains [1 2 3] 2) true user=> (true? (.contains [1 2 3] 2)) false AFAICS true? is implemented using identical? which tests by reference equality. Now since Java boolean values are boxed into Booleans we have not only Boolean.TRUE. Maybe true? (

Re: Bug: self require -> stack overflow

2008-09-09 Thread ntupel
On Tue, 2008-09-09 at 07:26 -0700, Rich Hickey wrote: > Certainly there are areas where there could be more explicit messages, > but the detection and reporting of errors has a cost (in time, > sometimes runtime, effort, code size and complexity) and I don't want > to incur that cost unless it is

Re: Bug: self require -> stack overflow

2008-09-09 Thread ntupel
On Wed, 2008-09-10 at 16:47 +1100, Brett Morgan wrote: > On Wed, Sep 10, 2008 at 4:38 PM, ntupel <[EMAIL PROTECTED]> wrote: > > > > On Tue, 2008-09-09 at 23:57 +1000, Brett Morgan wrote: > >> On Tue, Sep 9, 2008 at 10:31 PM, [EMAIL PROTECTED] > >> <[EMAIL

Re: Bug: self require -> stack overflow

2008-09-09 Thread ntupel
On Tue, 2008-09-09 at 23:57 +1000, Brett Morgan wrote: > On Tue, Sep 9, 2008 at 10:31 PM, [EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote: > > > > On Sep 9, 11:26 am, "Brett Morgan" <[EMAIL PROTECTED]> wrote: > >> For C, protection against circular dependencies is on the head of the > >> programmer,

Re: Bug: self require -> stack overflow

2008-09-08 Thread ntupel
On Mon, 2008-09-08 at 13:15 -0700, Rich Hickey wrote: > Hmm, don't do that? > > Seriously, how is this a bug in Clojure, and not a bug in your > program, which resulted in an exception which easily leads you to your > problem? Well, first of all this bug in a users program results in undefined b

Bug: self require -> stack overflow

2008-09-08 Thread ntupel
(ns test (:require test)) results in: clojure.lang.Compiler$CompilerException: test.clj:0: null at clojure.lang.Compiler.analyzeSeq(Compiler.java:3824) at clojure.lang.Compiler.analyze(Compiler.java:3657) at clojure.lang.Compiler.eval(Compiler.java:3848) at cloj