...Just trying to understand the rationale between Clojure's design here. 
As I gradually get deeper into Clojure, I've been highly impressed by how 
well thought-out everything is, so I'm sure there is a very good reason for 
this one too. The question is:

Why are Clojure's built-in collections *seqable* rather than being *seqs*?

Or equivalently:

Why do Clojure's built-in collections support (seq) rather than (first) and 
(rest)?

A few possible reasons I can think of:

1. From reading the implementation of classes like PersistentHashMap, I can 
see that running over a map using a seq (basically a persistent cursor into 
the map) should be significantly faster, and create less garbage, then 
generating a succession of smaller and smaller maps (right down to an empty 
one) would be.
2. (seq) returns nil on an empty collection, which can naturally be used in 
a conditional.
3. (seq) works on things like Java arrays and Strings which can't be 
modified to implement ISeq.

Have I missed any? More importantly, can someone close to the core team 
identify *which* of these was the deciding factor in this design decision?

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