On Dec 11, 4:37 pm, Stefan Rusek <sru...@gmail.com> wrote:
> If we have the following map:
>
> (def m {:key 1 'sym 2 "str" 3})
>
> The following are equivalent:
>
> (:key m)
> (m :key)
>
> As are the following:
>
> ('sym m)
> (m 'sym)
>
> I think the commutativity of maps with symbols and keywords is a
> valuable and good thing. I realize that the String class doesn't
> implement the IFn interface, but it would be nice if maps and strings
> were commutative. Unfortunately they aren't:
>
> ("str" m) ; throws invalid cast
> (m "str") ; works fine
>
> I realize that almost any type can be used as a key for a map, but
> keywords, symbols, and strings are by far the most common, and it
> would make sense to bring strings in line with the other two.

That's not likely to happen. Being pragmatic, Clojure values strings
being Java Strings and no conditionals on fn calls more highly than
that feature. It's a tradeoff.

Rich

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