20080213 Release

78 views
Skip to first unread message

Rich Hickey

unread,
Feb 13, 2008, 2:06:41 PM2/13/08
to Clojure
20080213 Release

http://sourceforge.net/project/showfiles.php?group_id=137961

Many significant new features, including first-class namespaces,
pervasive abstract destructuring binding, list comprehensions, var
metadata, regex literals and more! Browse through the site for
details:

http://clojure.sourceforge.net/


There is some renaming/removing in this release:


Folded strcat functionality into str

Removed export, *exports*, unintern, unimport

Renamed ns-exports to ns-publics

Made fn and let macros, which, by the end of boot.clj, do
destructuring, as do all macros which emit them.

Removed thisfn, use (fn name [] ...)

boot.clj is now loaded from .jar, no longer from command line.

Renamed eql? to =, compares numbers without regard for type.

Renamed struct to struct-map


Changelist:


renamed :sigs to :arglists, added pr*-str fns, with-out-str
added re-find, re-matcher
added :sigs metadata
added field names to error messages
added re-groups and use in re-seq and re-matches
added re-seq, re-matches, nth support for matcher
added compiled regex literals via #"pattern"
renamed fn and let special ops to fn* and let*. Made fn and let
macros, which, by the end of boot.clj, do destructuring, as do all
macros which emit them.
added nth support for Map.Entry
changed strcat to str
added assoc/dissoc/conj support for beans
folded strcat into str
added :else to collection-tag
removed export
added when-first, lazy-cat
fixed for so bindings can nest, e.g. (for [x xs y (f x)]...
made meta return nil on non-IObjs
added prstr, assert, test
renamed ns-exports ns-publics
var metadata support
added seq support and inspector support for Java Maps
added bean, which creates a live read-only map of an object's
javabeans properties
added default handling of equals, toString and hashCode in implement
fixed maybeClass when passed Class
moved boot.clj load to RT.init()
added destructuring
added get and contains support for strings and arrays, treating as
associative, keyed by index, like vectors
added string? symbol? map? vector? seq? nthrest
prevent access to non-exported macro from other ns
added count, nth support for strings, Java Collections and arrays,
get and contains? support for Java Maps
added optional anonymous function name binding (fn name [args] ...)
added seq calls to for
added list comprehensions (for)
fixed subvec assoc at end
simplified cycle
got rid of thisfn
simplified, now includes .clj files in jar
simple inspector support
new constant handling
added first-class namespaces
added array-map
rename != not=
added ns- prefix to refers et al
added ns-unmap
made = use equiv for Numbers
added emit to xml.clj
fixed boolean return in proxy handler
coerce all Boolean false returns to Boolean.FALSE
renamed struct to struct-map, construct to struct. Added to-set and
distinct
made make-proxy use Compiler's classloader as parent
made DynamicClassLoader no-arg ctor use Compiler's classloader as
parent
added construct, resultset-seq, keyword fn, vars in namespace tables
fixed BigNum.equals
added pr support for \r in strings
fixed *warn-on-reflection* access


Thanks to all for your feedback!

Rich

arsala...@gmail.com

unread,
Feb 15, 2008, 4:44:42 AM2/15/08
to Clojure
Hi.

Some errors on the website:

1. http://clojure.sourceforge.net/features/functional_programming.html
- still mentions thisfn
2. http://clojure.sourceforge.net/reference/special_forms.html - let:
Are you sure you mean to use let* here and not let?

More if I find any :-)

Regards.

--Arsalan

Rich Hickey

unread,
Feb 15, 2008, 7:53:47 AM2/15/08
to Clojure


On Feb 15, 4:44 am, "arsalan.za...@gmail.com"
<arsalan.za...@gmail.com> wrote:
> Hi.
>
> Some errors on the website:
>
> 1.http://clojure.sourceforge.net/features/functional_programming.html
> - still mentions thisfn
> 2.http://clojure.sourceforge.net/reference/special_forms.html- let:
> Are you sure you mean to use let* here and not let?
>
> More if I find any :-)
>

Fixed - thanks!

Rich

arsala...@gmail.com

unread,
Feb 15, 2008, 9:00:51 AM2/15/08
to Clojure
One more:

http://clojure.sourceforge.net/reference/reader.html - the-var is now
var IIRC.

--Arsalan

Rich Hickey

unread,
Feb 15, 2008, 9:19:00 AM2/15/08
to Clojure


On Feb 15, 9:00 am, "arsalan.za...@gmail.com"
<arsalan.za...@gmail.com> wrote:
> On Feb 15, 5:53 pm, Rich Hickey <richhic...@gmail.com> wrote:
>

> One more:
>
> http://clojure.sourceforge.net/reference/reader.html- the-var is now
> var IIRC.
>

Fixed - thanks again!

Rich

jon

unread,
Feb 15, 2008, 11:27:05 AM2/15/08
to Clojure
Also, check these pages for corrections:
http://clojure.sourceforge.net/reference/getting_started.html
http://clojure.sourceforge.net/features/dynamic.html

They mention "java -cp clojure.jar clojure.lang.Repl"...
do you also want to mention "java -jar clojure.jar"
since it's 'short-and-sweet'er.

Also does the following still want to mention src/boot.clj:
"java -cp jline-0.9.91.jar:clojure.jar jline.ConsoleRunner
clojure.lang.Repl src/boot.clj"

-----
Many thanks for your dedication on clojure. I seriously hope that
clojure
is going to continue from strength to strength as I'm planning to use
it
for all my projects from now on :)

I had a *tiny* play with using clojure with the IKVM.net JVM under
(gasp) Visual Studio 2005 / .Net 2.0 / WinXP -- seems to work fine --
even let me step through boot.clj line-by-line when debugging!

Rich Hickey

unread,
Feb 15, 2008, 3:09:17 PM2/15/08
to Clojure


On Feb 15, 11:27 am, jon <superuser...@googlemail.com> wrote:
> Also, check these pages for corrections:
> http://clojure.sourceforge.net/reference/getting_started.html
> http://clojure.sourceforge.net/features/dynamic.html
>
> They mention "java -cp clojure.jar clojure.lang.Repl"...
> do you also want to mention "java -jar clojure.jar"
> since it's 'short-and-sweet'er.
>

I'm going to hold off for now on that - java -jar is kind of a pain in
not considering the classpath.

> Also does the following still want to mention src/boot.clj:
> "java -cp jline-0.9.91.jar:clojure.jar jline.ConsoleRunner
> clojure.lang.Repl src/boot.clj"
>

Fixed, thanks.

> -----
> Many thanks for your dedication on clojure. I seriously hope that
> clojure
> is going to continue from strength to strength as I'm planning to use
> it
> for all my projects from now on :)
>

You're welcome!

> I had a *tiny* play with using clojure with the IKVM.net JVM under
> (gasp) Visual Studio 2005 / .Net 2.0 / WinXP -- seems to work fine --
> even let me step through boot.clj line-by-line when debugging!

That's pretty neat. I'm always impressed with the things people get to
run under IKVM.

Rich

jon

unread,
Feb 17, 2008, 10:27:30 AM2/17/08
to Clojure
Hi, another small thing:

On http://clojure.sourceforge.net/reference/multimethods.html
(defmulti area :Shape)

As a total newbie.. that example had me confused for a few minutes
since I didn't know (or at least remember) that a keyword is also a
function.. so (although contradicting the defined pattern for
defmulti) it did feel like :Shape was supposed to be setting the
default-dispatch-val, and that dispatch-fn was strangely missing.

Perhaps add a comment above it:
"NB. :Shape is being used as a function here
(see http://clojure.sourceforge.net/reference/data_structures.html)"

----
And a couple of basic newbie questions, if I may:

1) Is my understanding correct that the general structure of a clojure
program should be more C-like than Java-like in that we'll have a data
structure for each 'instance' of say a customer or product, and the
functions that operate on customers are generally bundled into a
'customer' namespace, and likewise for 'product'?

So this kind of thing should look about right?
(def c (customer/create "fred"))
(customer/amount-owing c)

2) Is it good-style to prefix with customer/ all over the place for
clarity
or more standard to (refer customer)

3) If using (refer customer) and (refer product), and both namespaces
have a (create) function, what's the recommended way to avoid the
clash.. eg. a naming convention like (cust-create) and (prod-create)?
--- (of course in Java, c.create() and p.create() wouldn't be a clash)

4) To change the value of a variable (I mean a Var, I think?), is it
perfectly ok to 'def' it again? or is that kind of thing not lisp
style at all?
(def c (customer/create "fred"))
(do-something c)
(do-something-else c)
(def c (customer/create "jim"))
(do-something c)

Many thanks, Jon

Rich Hickey

unread,
Feb 17, 2008, 12:09:42 PM2/17/08
to Clojure


On Feb 17, 10:27 am, jon <superuser...@googlemail.com> wrote:
> Hi, another small thing:
>
> Onhttp://clojure.sourceforge.net/reference/multimethods.html
> (defmulti area :Shape)
>
> As a total newbie.. that example had me confused for a few minutes
> since I didn't know (or at least remember) that a keyword is also a
> function..
> Perhaps add a comment above it:

Good idea - done.

> ----
> And a couple of basic newbie questions, if I may:
>
> 1) Is my understanding correct that the general structure of a clojure
> program should be more C-like than Java-like in that we'll have a data
> structure for each 'instance' of say a customer or product, and the
> functions that operate on customers are generally bundled into a
> 'customer' namespace, and likewise for 'product'?
>

There's a presumption built-in to that question that I think needs to
be addressed first. That is, that there should be specialized, named,
data structures/classes corresponding to imagined information-based
entities in a system, and a partitioning of functions by their
association with same entities, either in classes or modules. I've
come to the conclusion after 20 years of C++/Java/C#/CLOS/OODBMS that
this is a bad idea.

OO is not bad when there is an actual entity - i.e. a stream, a
socket, a window, etc to which an object corresponds, or in a
simulation of actual entities. That's where it was born and where it
shines. When applied to the information/data in a system, however, it
causes code to be 10x as large and 1/10th as useful.

For instance, don't customers buy products? Which should own the
functions that involve both? Do databases have different functions for
different tables? One would hope not. And if a DB query returns a
recordset with fields from more than one table, should a custom entity
be defined that maps to it? No - ORM is an even worse idea.

Data is data, and having very few general data structures to hold it
and very many general functions to manipulate it is the key. That is
the Clojure philosophy. (I'm not claiming that this is unique to
Clojure, btw)

Look at the xml.clj - it deals with an external entity, a SAX parser
fronting some XML source, gets the data out of it and into a map, and
it's done. There aren't and won't be many more functions specific to
XML. The world of functions for manipulating maps will now apply. And
if it becomes necessary to have more XQuery-like capabilities in order
to handle XML applications, they will be built for maps generally, and
be available and reusable on all maps. Contrast this with your typical
XML DOM, a huge collection of functions useful nowhere else.

Similarly, resultset-seq pulls the data out of a db query and into a
sequence of maps right away, where it can be manipulated as generally
as possible.

That isn't to say you can't or shouldn't tag your data with some
information/metadata helping you discern its source, use, or
categorization in one or more contexts.

But you should avoid the ghettoization of your logic, lest you have to
repeat it endlessly.

That's a long way to say you might have to think a bit differently
about your problem in Clojure in order to achieve the desired result
of writing less, more powerful, code.

> 4) To change the value of a variable (I mean a Var, I think?), is it
> perfectly ok to 'def' it again? or is that kind of thing not lisp
> style at all?
> (def c (customer/create "fred"))
> (do-something c)
> (do-something-else c)
> (def c (customer/create "jim"))
> (do-something c)

Doing this at the Repl while you are experimenting is fine. But if you
find you have non-top-level defs in a program that is not otherwise a
code-generator, that is a sign you are treating vars as mutable
globals, and should investigate using per-thread binding, refs or
agents instead.

Rich

jon

unread,
Feb 20, 2008, 10:35:33 AM2/20/08
to Clojure
Hi Rich,
Thanks for this insight.. giving me plenty to chew on whilst designing
a new project
from a completely clean slate.

Just another tiny typo for you:
on http://clojure.sourceforge.net/reference/special_forms.html,
in (def symbol init?) section,
"...and is consider bad style."
:)

jon

unread,
Feb 20, 2008, 1:23:43 PM2/20/08
to Clojure
Hi Rich,
One more thing.. I could be missing sth but if the (class ...) special
operator
no longer exists then the documentation for (make-array class dim+)
on http://clojure.sourceforge.net/reference/java_interop.html
is wrong.. (??)
Jon

Rich Hickey

unread,
Feb 20, 2008, 1:58:35 PM2/20/08
to Clojure


On Feb 20, 1:23 pm, jon <superuser...@googlemail.com> wrote:
> Hi Rich,
> One more thing.. I could be missing sth but if the (class ...) special
> operator
> no longer exists then the documentation for (make-array class dim+)
> onhttp://clojure.sourceforge.net/reference/java_interop.html
> is wrong.. (??)
> Jon

Fixed (as well as the last one).

Thanks,

Rich

jon

unread,
Feb 21, 2008, 9:30:32 AM2/21/08
to Clojure
Hi Rich... more tweaks for your docs..
If I'm understanding things correctly, do both of these places now
need to mention that metadata can be attached to Vars?

1 - http://clojure.sourceforge.net/reference/metadata.html
2 - http://clojure.sourceforge.net/reference/reader.html
"Metadata (#^)
Symbols, Lists, Vector and Maps can have metadata,"

Thanks, Jon

jon

unread,
Feb 21, 2008, 11:41:17 AM2/21/08
to Clojure
And if I may mention one more thing before I forget,
something that's a little confusing to a newbie like me..

Do you think the first sentence introducing maps on
http://clojure.sourceforge.net/reference/data_structures.html
"Maps (IPersistentMap)
Map keys to values. Two different map types
are provided - hashed and sorted."
would benefit from being short but complete overview of all the
'puzzle pieces' and how they inter-relate?
ie. mention hash-map, sorted-map, struct-map, array-map and what to
expect from { } literals, right up front, perhaps in a little grid,
and say what the different categories are, what automatic conversions
can happen, etc.
And although it's a reference, maybe add a friendly comment along the
lines of:
"For average use, using a key of integers,strings,etc works for all
kinds of maps, so all you need to decide is whether you need the
contents sorted or not."

Thanks, Jon

jon

unread,
Feb 21, 2008, 12:38:02 PM2/21/08
to Clojure
(ps. by "although it's a reference", I mean "although it's a technical-
reference-guide")

jon

unread,
Feb 22, 2008, 3:51:26 AM2/22/08
to Clojure
Hi,
Found a couple more 'documentation bugs' for you..
These 2 pages still mention 'thisfn':

http://clojure.sourceforge.net/reference/refs.html
http://clojure.sourceforge.net/reference/lisps.html


(you seem to be getting this clojure design so _right_ it's scary :)
really a joy to work with!)

Rich Hickey

unread,
Feb 22, 2008, 9:12:58 AM2/22/08
to Clojure


On Feb 22, 3:51 am, jon <superuser...@googlemail.com> wrote:
> Hi,
> Found a couple more 'documentation bugs' for you..
> These 2 pages still mention 'thisfn':
>
> http://clojure.sourceforge.net/reference/refs.htmlhttp://clojure.sourceforge.net/reference/lisps.html
>
> (you seem to be getting this clojure design so _right_ it's scary :)
> really a joy to work with!)

Fixed - thanks!

Rich

jon

unread,
Feb 23, 2008, 7:51:56 AM2/23/08
to Clojure
Hi,
Two tiny typos and a possible mistake..
on http://clojure.sourceforge.net/reference/sequences.html
1 - "... then so to is the resulting seq." (too)
2 - "In all the functions that follow, if the arguments are specified
as collections, seq will be called on the collection" (seq is not
highlighted)
3 - And I may be misunderstanding something, but the documented
definition of:
(lazy-cons first-expr rest-expr)
doesn't seem to marry up with boot.clj -- ie. it can take several rest-
expr's
"(defmacro lazy-cons [x & body]"

Thanks, Jon

Rich Hickey

unread,
Feb 23, 2008, 8:39:24 AM2/23/08
to Clojure


On Feb 23, 7:51 am, jon <superuser...@googlemail.com> wrote:
> Hi,
> Two tiny typos and a possible mistake..
> onhttp://clojure.sourceforge.net/reference/sequences.html
> 1 - "... then so to is the resulting seq." (too)
> 2 - "In all the functions that follow, if the arguments are specified
> as collections, seq will be called on the collection" (seq is not
> highlighted)

Fixed -thanks.

> 3 - And I may be misunderstanding something, but the documented
> definition of:
> (lazy-cons first-expr rest-expr)
> doesn't seem to marry up with boot.clj -- ie. it can take several rest-
> expr's
> "(defmacro lazy-cons [x & body]"
>

That's right. I'm not promising more than one expr and will probably
eventually remove the & body. I've never used it, and I'm not sure I'd
want to read code that did.

Rich

jon

unread,
Feb 23, 2008, 4:31:30 PM2/23/08
to Clojure
Hi Rich..
Found another documentation-bug for you..
on http://clojure.sourceforge.net/reference/data_structures.html
(bit-shift-right x)
(bit-shift-left x)
These should take 2 arguments, right?
Cheers, Jon

jon

unread,
Feb 24, 2008, 10:47:30 AM2/24/08
to Clojure
Hello again,
I could be wrong, but isn't this another documentation bug?
on http://clojure.sourceforge.net/reference/java_interop.html

(implement [interface-name+] method-fn+)
method-fn => (name [args+] body)

Should there have to be at-least-one 'args', can't there be none?
Thanks,
Jon

Rich Hickey

unread,
Feb 25, 2008, 3:27:04 PM2/25/08
to Clojure


On Feb 24, 10:47 am, jon <superuser...@googlemail.com> wrote:
> Hello again,
> I could be wrong, but isn't this another documentation bug?
> onhttp://clojure.sourceforge.net/reference/java_interop.html
>
> (implement [interface-name+] method-fn+)
> method-fn => (name [args+] body)
>
> Should there have to be at-least-one 'args', can't there be none?

Fixed - thanks,

Rich

jon

unread,
Mar 6, 2008, 3:59:36 PM3/6/08
to Clojure
Hi,
Apologies if this was already mentioned, but are these definitions
wrong on:
http://clojure.sourceforge.net/reference/sequences.html
(map f colls*)
(mapcat f colls*)

..mustn't they take at least 1 collection?
Thanks, Jon

Rich Hickey

unread,
Mar 6, 2008, 4:56:23 PM3/6/08
to Clojure
Fixed - thanks for the report.

Rich
Reply all
Reply to author
Forward
0 new messages