On 5 August 2010 15:52, Stuart Halloway wrote:
> If records implemented IFn, you could treat them as collections, which they
> are not.
Lists are collections, yet they are not IFns. Same goes for Java
collections. As for records, the implementation seems to be in two
minds about their status:
us
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
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
wrote:
> If records implemented IFn, you could treat them as collections, which they
> are n
2010/8/5 Stuart Halloway
> If records implemented IFn, you could treat them as collections, which they
> are not.
>
Isn't the fact of making records associative for easing the use of treating
them as collections ?
user=> (assoc (user.R. 1) :b 2)
#:user.R{:a 1, :b 2}
user=> (seq (user.R. 1))
([:
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)
>
>
> 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
Karl,
> 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
> oth
On Aug 2, 3:50 pm, Baishampayan Ghose wrote:
> Hello,
[snip..]
> The documentation says "defrecord provides a complete implementation
> of a persistent map". If a record is analogous to a map, why can't we
> treat it as one?
>
> If it's not a bug, what is the rationale behind it?
>
> Regards,
> B
Hello,
I just discovered that records (created using defrecord) can't be
treated as functions (like maps) anymore. Consider this -
user=> (defrecord Bird [nom species])
user.Bird
user=> (def crow (Bird. "Crow" "Corvus corax"))
#'user/crow
user=> (:nom crow)
"Crow"
user=> (crow :nom)
java.lang.Cla