On Fri, Mar 1, 2013 at 3:44 PM, Joachim De Beule <joachim.de.be...@gmail.com
> wrote:

> Here is another (real) example:
>
> When I change the number of slots in a record, e.g. from
>
> (defrecord MyRecord [slot1 slot2] ...)
>
> to
>
> (defrecord Myrecord [slot1] ...)
>
>
>
Are you remembering to recreate the *instances* of the records after
redefinition?  I suspect not and this is causing your problem.

I found this somewhat surprising when I first discovered it, but hopefully
this REPL session illustrates the point...

user> (defrecord MyRecord [slot1])
user.MyRecord
user> (def r1 (->MyRecord 1))
#'user/r1
user> (defrecord MyRecord [slot1 slot2])
user.MyRecord
user> (def r2 (->MyRecord 1 2))
#'user/r2
user> r1
#user.MyRecord{:slot1 1}
user> r2
#user.MyRecord{:slot1 1, :slot2 2}
user>
user> (type r1)
user.MyRecord
user> (type r2)
user.MyRecord

 ; r1 and r2 apparently have the same type, but

user> (= (type r1) (type r2))
false

; r2 is a different (jvm) class (because of different classloader
introduced by redefinition)
user> (def r3 (->MyRecord 3 4))
#'user/r3

; two instances from the same definition *do* have the same type

user> (= (type r2) (type r3))
true

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to