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:

;; parameter list, can also be of length 3 or 4
user=> (def params '("example.com" 5222))
(def params '("example.com" 5222))
#'user/params

;; thought this would work
user=> (apply ConnectionConfiguration. params)
(apply ConnectionConfiguration. params)
java.lang.ClassNotFoundException: ConnectionConfiguration.
(NO_SOURCE_FILE:66)

;; thought this would work also
user=> (apply new ConnectionConfiguration params)
(apply new ConnectionConfiguration params)
java.lang.Exception: Unable to resolve symbol: new in this context
(NO_SOURCE_FILE:68)

;; can do it with eval, but what is the correct way?
user=> (eval `(ConnectionConfiguration. ~...@params))
(eval `(ConnectionConfiguration. ~...@params))
#<ConnectionConfiguration
org.jivesoftware.smack.connectionconfigurat...@a0430b6>

Any input is appreciated.

Thanks.

 - Mark

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