Mark <[email protected]> writes:
> I think my preferred solution would be to allow imported Java classes
> to be aliased, so I could do this:
>
>> (import '(org.fooinstitute.team.library.foo package :as foop))
> => org.fooinstitute.team.library.foo.package
>> (foop/isFoo "foop")
> => false
>
> But to the best of my knowledge (and searching), that doesn't exist in
> Clojure.
Clojure doesn’t provide it as a part of the `ns` or `import` forms, but
the underlying `Namespace` objects support it just fine, and then almost
everything works as you’d expect w/ the arbitrary alias:
user> (.importClass *ns* 'Q java.util.concurrent.LinkedBlockingQueue)
java.util.concurrent.LinkedBlockingQueue
user> Q
java.util.concurrent.LinkedBlockingQueue
user> (Q.)
#<LinkedBlockingQueue []>
user> (fn [q x] (.offer q x))
Reflection warning, /tmp/form-init7252328014986537096.clj:1:11 - call to
offer can't be resolved.
#<user$eval1302$fn__1303 user$eval1302$fn__1303@ece88d2>
user> (fn [q x] (.offer ^Q q x))
#<user$eval1308$fn__1309 user$eval1308$fn__1309@251c4123>
HTH,
-Marshall
--
--
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
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.