On Fri, Mar 25, 2011 at 11:48 PM, James Reeves <jree...@weavejester.com>wrote:
> > (defprotocol Identifiable > (id [self] "Return an object's unique id")) > > (deftype DBRef [db-id data] > Identifiable > (id [_] db-id) > clojure.lang.IDeref > (deref [_] data)) > > (defn db-ref [id data] > (DBRef. id data)) > > Then we can get information about the reference, and deref it to get > its contents: > > (def user > (db-ref 193 {:login "fred"})) > > => (id user) > 193 > => @user > {:login fred} Wow, this is incredibly cool! I guess I just saw Ref's as a really special case, this shows how easy it is to make one, and extend it! :) Ambrose -- 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