(let [c String]
  (.newInstance c))

If you need to pass arguments to the constructor there's more work to
do - check out clojure.lang.Reflector.

On Apr 2, 5:53 pm, JonathanBelolo <[email protected]> wrote:
> Ok, so here's the thing:
>
> I'd like to keep a reference to a class somewhere, and later retrieve
> it to instantiate.
> But references to classes don't seem to be valid arguments to the new
> special function.
>
> For ex,
>
> (let [the-class java.lang.String]
>  (new the-class))
>
> this throws an error (at least, in 1.2) : Unable to resolve classname:
> the-class
>
> After fiddling around, I found this ugly hack :
>
> (let [the-class java.lang.String]
>  (eval `(new ~the-class)))
>
> Am I missing something?
>
> Cheers!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to