Re: Nasty java interop problem -- ideas?

2011-08-12 Thread Oskar Kvist
Oh yes, of course. Why didn't I think of that? For some reason, implementing 2 interfaces never occurred to me. :P On Aug 12, 4:48 pm, David Powell wrote: > > The simplest so far seems to be to use gen-interface to create a > > subinterface of Controller with all the methods I need, or gen-class.

Re: Nasty java interop problem -- ideas?

2011-08-12 Thread David Powell
> > > The simplest so far seems to be to use gen-interface to create a > subinterface of Controller with all the methods I need, or gen-class. > But that would require AOT compilation. Can I get away without it? > Can you use definterface to create an interface with your methods on, and then defty

Nasty java interop problem -- ideas?

2011-08-12 Thread Oskar Kvist
Hi! I have the following problem. I'm using a Java lib for making GUIs. One lays out the GUI in XML, then uses a Controller (Listener type thing) to do stuff. For example, in the XML one might have onClick="doSomething()". And then reflection is used to find the method of the controller instance.

Re: java interop problem

2010-09-14 Thread Alan
Also, if you want the behavior you describe, it's easy to get it in the current approach, whereas if the REPL didn't consume lazy sequences it would be very hard to get it to. Try: (def myvar (filter even? (range))) ; prints the Var object (nth myvar 1) ; realizes the first 10,000 items in the

Re: java interop problem

2010-09-14 Thread Alan
That would be very awkward: user=> (-> (range) (filter even?) (drop 10) (take 5)) LazySeq user=> (-> (range) (filter even?) (drop 10) (take 5) first) 20 user=> (-> (range) (filter even?) (drop 10) (take 5) second) 22 ... On Sep 14, 5:20 am, Ranjit wrote: > Thanks for clearing that up for me

Re: java interop problem

2010-09-14 Thread Ranjit
Thanks for clearing that up for me everyone. So the REPL itself acts like a consumer of lazy sequences? Is there some logic behind that? I guess I would have expected that the REPL would just return a reference to a lazy expression rather than evaluate it. Thanks, -Ranjit On Sep 13, 2:06 pm, Al

Re: java interop problem

2010-09-13 Thread Alan
Ranjit, try the following to see it in action even at the REPL: (def xt (make-array Float/TYPE 3 3)) (def myloop (for [x (range 3) y (range 3)] (aset xt x y 1))) (aget xt 1 1) ;; xt hasn't been changed myloop ;; force REPL to de-lazify (aget xt 1 1) ;; changed now On Sep 13, 9:28 am, Mark Nut

Re: java interop problem

2010-09-13 Thread Mark Nutter
Erg, gmail hiccup. Started to say if you try to use it in code that's *not* being called from the REPL, you'll be scratching your head trying to figure out why aset never gets called. Mark On Mon, Sep 13, 2010 at 12:27 PM, Mark Nutter wrote: > The REPL automatically realizes the lazy sequence in

Re: java interop problem

2010-09-13 Thread Mark Nutter
The REPL automatically realizes the lazy sequence in the process of printing it out, but if you try to us On Mon, Sep 13, 2010 at 11:07 AM, Ranjit wrote: > Thanks Armando for catching my stupid mistake. That fixed everything. > > Meikel, I'm not sure I understand what you're saying. When I evalua

Re: java interop problem

2010-09-13 Thread Ranjit
Thanks Armando for catching my stupid mistake. That fixed everything. Meikel, I'm not sure I understand what you're saying. When I evaluate this in the REPL (for [x (range 2) y (range 2)] (aset xt x y (+ x y))) (aget xt 0 0) (aget xt 1 1) I get back 0 and 2 as I expect. Isn't the call to aset co

Re: java interop problem

2010-09-13 Thread Meikel Brandmeyer
Hi, On 13 Sep., 15:07, Ranjit Chacko wrote: >     (for [x (range 3) y (range 3)] (aset xt x y 1)) Note that that this will not do what you think it does. for creates a lazy sequence which is thrown away immediately. So the aset calls are never done. for is a list comprehension, not a looping co

Re: java interop problem

2010-09-13 Thread Armando Blancas
Looks like you need a Float/TYPE instead of Double/TYPE. On Sep 13, 6:07 am, Ranjit Chacko wrote: >   I'm having a problem with java interop using one of the libraries in > the Incanter package. > > When I run the following code: > >     (use '(incanter core charts)) >     (import (edu.emory.math

java interop problem

2010-09-13 Thread Ranjit Chacko
I'm having a problem with java interop using one of the libraries in the Incanter package. When I run the following code: (use '(incanter core charts)) (import (edu.emory.mathcs.jtransforms.fft FloatFFT_2D)) (def xt (make-array Double/TYPE 3 3 )) (for [x (range 3) y (range 3)] (ase