Re: apply with constructors

2010-06-02 Thread rzeze...@gmail.com
> Can you let the fn call figure that out for you? Like so: > >     (apply (fn ([p1 p2] (new Connection.Configuration p1 p2)) >                ([p1 p2 p3] (new Connection.Configuration p1 p2 p3))) >            params) > > I realize that reflection is probably better in this case, but was > wonderi

Re: apply with constructors

2010-06-02 Thread Mark Rathwell
Ah, makes sense now, thank you. I know the parameter list will be one of three possibilities, so probably makes more sense to specify the conditions than to use reflection. I don't have a repl handy, but either of the below should work: ;; using apply (per Konrad) (cond (= (count params) 2)

Re: apply with constructors

2010-06-02 Thread Konrad Hinsen
On 2 Jun 2010, at 21:10, Mike Meyer wrote: If your class has multiple constructors with different arity, there are ways to look up the right constructor using reflection, but I have forgotten the details already. Can you let the fn call figure that out for you? Like so: (apply (fn ([p1

Re: apply with constructors

2010-06-02 Thread Mike Meyer
On Wed, 2 Jun 2010 13:33:30 +0200 Konrad Hinsen wrote: > Constructors calls translate directly to Java constructor calls, meaning that > the number of arguments must be known at compile time. > > Assuming your constructor takes a fixed number of arguments, the easiest > solution to your proble

Re: apply with constructors

2010-06-02 Thread Meikel Brandmeyer
Hi, On Jun 2, 2:51 am, Mark Rathwell wrote: > ;; can do it with eval, but what is the correct way? > user=> (eval `(ConnectionConfiguration. ~...@params)) > (eval `(ConnectionConfiguration. ~...@params)) > # org.jivesoftware.smack.connectionconfigurat...@a0430b6> The best way is to use reflecti

Re: apply with constructors

2010-06-02 Thread Konrad Hinsen
On 02.06.2010, at 02:51, Mark Rathwell wrote: > I apologize for my ignorance, I've been struggling with this one for a couple > hours and can't figure it out. Why does apply not work with constructors, > special forms, etc.? Is there some other standard way to unpack a list? My > question is

apply with constructors

2010-06-02 Thread Mark Rathwell
I apologize for my ignorance, I've been struggling with this one for a couple hours and can't figure it out. Why does apply not work with constructors, special forms, etc.? Is there some other standard way to unpack a list? My question is outlined below, I have a variable length list of paramete