While coarse-grained imports are pretty obviously a suboptimal practice, I 
believe the lack of some this possibility (in at least some form) hinders 
exploratory programming / API discoverability.

Would it be feasible to add an :as directive to 'import? An use case:

; --- state of the editor at time T1 ----

(import '[java.util.concurrent] :as conc)

conc/ ; a completion popup appears. user presses DOWN, DOWN, TAB

; --- state of the editor at time T2 ----

(import '[java.util.concurrent DelayedQueue] :as conc) ; the symbol gets 
added to the import list.

conc/DelayedQueue ; the user can optionally drop the 'conc/' qualification 
by calling 'import again

There are are least two JVM langs (Java and Scala) that can perform 
package-wide imports. Don't know if they achieve this by walking the 
classpath as Rich indicates (which would mean - we can have this too!) or 
by leveraging a feature that is consequence of their less-dynamic nature.

On Sunday, June 15, 2008 2:33:11 PM UTC+2, Rich Hickey wrote:
>
>
>
> On Jun 15, 7:55 am, "Bry Ashman" <[email protected]> wrote: 
> > Ah, good point. I read it as just wanting a way to find out what a 
> > package contains. 
> > 
> > There doesn't appear to be anything in java.lang.reflect for 
> > enumerating classes in a package directly. Seems to mainly for 
> > traversing class hierarchies. 
> > 
> > This thread (
> http://forum.java.sun.com/thread.jspa?threadID=341935&start=0 
> > ) seems to suggest parsing the contents of the jar files. 
> > 
> > I am not sure if importing all the classes from a package is a good 
> > idea. Convenient maybe, but not a wise idea. Especially since our 
> > import syntax is so much better than plain java. 
> > 
>
> Java packages are not enumerable. The only way to do so is to walk the 
> classpath/jars etc. I don't think import * is a good idea, as it 
> brings more into a namespace than you are going to use, making 
> Clojure's namespace enumeration, e.g. ns-imports, that much less 
> useful. 
>
> Rich 
>

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