On Aug 6, 8:31 pm, Howard Lewis Ship <hls...@gmail.com> wrote:
> I'm cringing at the sight of XML here.

XML is frequently overused, but it is a good format for representing
dense, structured data. For example:

<repository name="third-party">
  <package name="Compojure" href="/compojure.xml"/>
</repository>

Compared to:

{:type :repository
 :name "third-party"
 :content [{ :type :package
             :name "Compojure"
             :href "/compojure.xml" }]}

> I would like to see idiomatic Clojure, not XML, something along the lines of:
>
> (ns com.example.foo
>   (:use 'clojure.packages))
>
> (packages
>   (:use [(clojure.contrib "1.0-alpha-3" test-is pprint)
>             (foo.mylib "2.0.3")]))

I think you've misunderstood. The format you outline is almost exactly
what I first had in mind as the user interface. I was suggesting an
XML format as the syntax the packager uses internally to communicate
with the repository servers.

For the user, I was thinking of a syntax like:

  (package/get "compojure" "0.2")

This would download "compojure" from a repository, then dynamically
add it to the Clojure classpath. The repositories would be a list of
URLs the user could add to, similar to Apt's sources.list.

I thought about integrating :use and :require into a 'packages' macro,
pretty much exactly as you've done, but I've since discarded that
approach. Once you put version number logic in, the syntax starts to
get messy. Additionally, a package name might not match up to it's
namespace. Also, how many levels of "."s do you go to find the package
name? "compojure.html" belongs to the "compojure" package, whilst
"clojure.contrib.json.read" belongs to the "clojure.contrib" package.

Instead, perhaps something like:

(package/get "compojure" "0.2")
(package/get "clojure-contrib" [:>= "1.0-alpha3"])

(ns example
  (:use 'clojure.contrib.json.read)
  (:use 'compojure.html))

You could add (require 'package) to user.clj to ensure that it's
always loaded into the user namespace.

Behind the scenes, the package/get function would be communicating
with a web service containing the packages and package metadata. It
would download and cache the packages in some user-configurable
directory.

At the REPL, the user could also query packages:

user=> (package/list)
clojure-contrib
compojure
...
user=> (:description (package/query "compojure"))
"A functional web framework"

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

Reply via email to