In a word, no. :-)

Records and maps share an API. Maps can be used as anonymous records. Records 
generally should not be used as maps.

My address information is a record (whether you bother to create "Address" or 
just throw it into a plain ol' map). Everyone's address information keyed by 
SSN is a map.

Stu

> Maybe I"m just getting stuck on semantics, but I'm confused.  If maps are 
> collections, and records function as maps, aren't records also collections?
> 
> Steve
> 
> On Thu, Aug 5, 2010 at 8:52 AM, Stuart Halloway <stuart.hallo...@gmail.com> 
> wrote:
> If records implemented IFn, you could treat them as collections, which they 
> are not. There is an asymmetry here: Maps can be used as (impoverished but 
> easy) records, but the reverse is not true:
> 
> (:foo x)              ; x is logically a record (though might be a map for 
> simplicity).
> (x :foo)              ; x is a collection (not a record, entity, etc.)
> 
> Records not implementing IFn forces you to do what you should do anyway -- 
> access records with the keyword first.
> 
> Stu
> 
>> 
>> Hi BG,
>> It is a common mistake to think that callability, corresponding to the
>> clojure.lang.IFn interface, is part of the persistent map contract
>> (I've done it myself, as did many others a Conj labs :). It is not. It
>> is actually just a feature of clojure.lang.PersistentHashMap (and the
>> other clojure map implementations).
>> 
>> 
>> While I get that part, I wonder why records do not implement IFn, it'd be 
>> convenient if they did. 
>> 
>> -- 
>> 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
> 
> 
> -- 
> 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
> 
> 
> -- 
> 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

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