I have a feature request for the 'use' function.  First an example.  I
have some real-world code like this:

(ns n01se.net.graph.issues
  (:import (java.text SimpleDateFormat ParsePosition)
           (java.util GregorianCalendar Calendar)
           (org.jfree.chart ChartFrame))
  (:use [clojure.zip                    :only (xml-zip node)]
        [clojure.contrib.lazy-xml       :only (parse-trim)]
        [clojure.contrib.zip-filter.xml :only (xml-> attr text)]
        [clojure.contrib.seq-utils      :only (reductions)])
  (:require [clojure.contrib.zip-filter     :as zf]
            [com.markmfredrickson.dejcartes :as chart]))

It struck me as awkward that libs are separated into :use and :require
blocks when I need almost the same thing from each.  In fact, any one
lib has a tendency to be shuffled between the two as I tidy up usages
in the code and change my mind about whether I want the whole
namespace aliased or specific functions brought in.

After kicking around some alternatives, I realized 'use' is sufficient
for all cases:

(ns n01se.net.graph.issues
  (:import (java.text SimpleDateFormat ParsePosition)
           (java.util GregorianCalendar Calendar)
           (org.jfree.chart ChartFrame))
  (:use [clojure.zip                    :only (xml-zip node)]
        [clojure.contrib.zip-filter     :as zf :only ()]
        [clojure.contrib.zip-filter.xml :only (xml-> attr text)]
        [clojure.contrib.lazy-xml       :only (parse-trim)]
        [clojure.contrib.seq-utils      :only (reductions)]
        [com.markmfredrickson.dejcartes :as chart :only ()]))

This is much prettier to my eye, but has a couple things that could be
better.  So, feature request #1 is that if a libspec has an ":as"
option, that the ":only []" option be implied.  That is, if I'm
aliasing an namespace, don't by default refer in all that namespaces
vars.

While this would technically be a breaking change, it seems unlikely
to me that it will cause much if any real-world disruption.  Any usage
that actually intended to both alias the namespace and refer all the
symbols could say [my.lib :as mylib :exclude ()]

--Chouser

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