On Mar 8, 10:53 am, Rich Hickey <richhic...@gmail.com> wrote:>
> In looking at some of the libraries, I am a bit concerned that maps
> are not being used when the logical entity is in fact a map.

One time I find myself abusing vectors where maps would be better is
in a situation where I have to retrieve key/value pairs in the order
they were inserted.

For example I'm working on a DSL for cascading stylesheets, and maps
should be perfect for specifying property declarations (right down to
curly braces for maps coincidentally and nicely matching the curly
braces in literal CSS).

But (css [:div {:padding "1px" :padding-left "5px"}]) won't work
because the order is lost.  Depending on the order "padding" and
"padding-left" show up in the final CSS, the meaning changes.  Not
sure what the best Clojure idiom would be in this case.  Vectors that
look like maps are the best I've come up with.

So "ordered maps" would be useful.  They have been endlessly re-
invented in the Ruby community, for example.  I think in upcoming Ruby
1.9, maps that preserve their insertion order are the default, in
spite of obviously worse performance compared to true hashed maps.
--~--~---------~--~----~------------~-------~--~----~
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