Perhaps a small extension to (import ..) is warranted then, since the
underlying machinery seems to support aliases?

    (import [the.java.package {Clazz1 Alias1 Clazz2 Alias2} Clazz3])

or, maybe more in keeping with require:

    (import [the.java.package Clazz1 Clazz2 Clazz3 :rename {Clazz1
Alias1 Clazz2 Alias2}])

Sean

On Sun, Nov 3, 2013 at 4:38 AM, Marshall Bockrath-Vandegrift
<llas...@gmail.com> wrote:
> Mark <mjt0...@gmail.com> 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 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
> ---
> 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 clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
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
--- 
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to