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 outlined below, I have a variable length list of parameters that 
> I want to send to the matching constructor:

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 problem is to wrap the constructor in a function:

        (apply (fn [p1 p2] (new Connection.Configuration p1 p2)) params)

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.

Konrad.

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

Reply via email to