lib integrated into clojure namespace

13 views
Skip to first unread message

Rich Hickey

unread,
Aug 28, 2008, 7:40:18 PM8/28/08
to Clojure
I'm pleased to announce that Stephen C. Gilardi's lib code has been
integrated into the clojure namespace and is included in boot.clj, as
of SVN rev 1009.

This means that use, require, and load-resources are now available by
default.

There is also a new macro, ns, which should be the preferred way to
use in-ns/import/use/require:

clojure/ns
([name & references])
Macro
Sets *ns* to the namespace named by name (unevaluated), creating it
if needed.
If the ns didn't already exist, refers the clojure namespace.
references can be zero or more of:
(:requires ...) (:uses ...) (:imports ...) with the syntax of
require/use/import respectively,
except the arguments are unevaluated and need not be quoted. Use of
ns is preferred to
individual calls to in-ns/require/use/import:

(ns foo
(:requires [clojure.parallel :as par])
(:uses clojure.inspector)
(:imports (java.util Date Timer Random)
(java.sql Connection Statement)))


load-resources should be preferred to load-file, and works relative to
the classpath/namespace. Loading code from the classpath will become
important for debugging.

Note that ns automatically refers clojure unless the namespace already
exists. To control/avoid the refer to clojure, create the ns first:

(create-ns 'bar)
(ns bar)
;no clojure names in bar

Along the way, I also added Steve's format and printf, and added a new
macro, defonce, which will define a var, but initialize it only the
first time. This is especially useful for vars that hold data which
you do not want to lose when you reload the file in order to get new/
fixed function defs.

(defonce baz 42)
(defonce baz 43)

baz
-> 42

There are extensive docs on the vars, so (doc require) etc.

Many thanks to Steve for his tireless work in defining and refining
lib, a very useful contribution!

Rich

Stephen C. Gilardi

unread,
Aug 28, 2008, 8:41:55 PM8/28/08
to clo...@googlegroups.com
On Aug 28, 2008, at 7:40 PM, Rich Hickey wrote:

I'm pleased to announce that Stephen C. Gilardi's lib code has been integrated into the clojure namespace and is included in boot.clj, as of SVN rev 1009.

This means that use, require, and load-resources are now available by default.

That's great news, Rich. Thanks very much!

There is also a new macro, ns, which should be the preferred way to use in-ns/import/use/require:

I like what you've done with clojure/ns -- tying a lot of often-used functions neatly into one concise and powerful call. Nicely done!

Many thanks to Steve for his tireless work in defining and refining lib, a very useful contribution!

You're quite welcome!

Working with Clojure makes it feel more like tireless fun.  :-)

Thanks!

--Steve

Michael Reid

unread,
Aug 28, 2008, 9:52:52 PM8/28/08
to clo...@googlegroups.com
Hi,

May I be the first to say: Thanks Steve and Rich!

This is a great addition and really helps tie up the loose ends in the
stuff I am currently working on--I didn't want to reimplement anything
that I knew was coming into the language.

Cheers,
/mike.

Rich Hickey

unread,
Aug 29, 2008, 10:27:32 AM8/29/08
to Clojure
It was mentioned by Chouser on the IRC that having the keyword args
differ from the functions via an English-specific transformation would
be confusing and error-prone, and I've agreed, so the syntax is now
(rev 1011):

(ns foo
(:require [clojure.parallel :as par])
(:use clojure.inspector)
(:import (java.util Date Timer Random)
(java.sql Connection Statement)))

Rich

Stuart Sierra

unread,
Aug 29, 2008, 1:38:40 PM8/29/08
to Clojure
On Aug 28, 7:40 pm, Rich Hickey <richhic...@gmail.com> wrote:
> I'm pleased to announce that Stephen C. Gilardi's lib code has been
> integrated into the clojure namespace and is included in boot.clj, as
> of SVN rev 1009.
>
> This means that use, require, and load-resources are now available by
> default.
>
> There is also a new macro, ns, which should be the preferred way to
> use in-ns/import/use/require:

Rockin! I predict sudden explosive growth in the number of Clojure
libraries. :)
-Stuart

Crsteen

unread,
Aug 30, 2008, 3:15:18 AM8/30/08
to Clojure
Congratulations Steve on your amazing work and accomplishment. Your
dedication to the improvement of Clojure deserves a medal.
I'm only new to this all, but am looking forward to the future. :P

--Christine Poole
Reply all
Reply to author
Forward
0 new messages