On Sunday, December 27, 2015 at 11:50:03 PM UTC+2, Francis Avila wrote:
> In clojurescript you can just "override" the necessary protocols inline in 
> the defrecord. You will get a warning, but everything will work. You can 
> silence the warning by using extend-type instead of an inline implementation.

Hmm, I have to try out that extend-type trick to silence the warnings, although 
using defrecord for clojurescript and not for clojure would feel awkward as 
well.

> In clojure, doing this will give you a compile-time error, meaning you have 
> to reimplement all the functionality of a defrecord using deftype, even for 
> protocols you do not actually want to override.
> 
> The Potemkin library has some macros to make this kind of thing less tedious, 
> I recommend taking a look: https://github.com/ztellman/potemkin

Oh, I'd had a look at Potemkin before in other context, but had forgotten it 
also has def-map-type which helps. I'll go look there for inspiration. In any 
case it looks like custom deftype and implementing map functionality on top of 
that would be the way to go. 

Thanks a lot for your help in clearing out things. Would still hope for the 
records to be a bit more extensible, having a typed map that can implement 
protocols and avoids lookups for fields is nice, but doesn't really bring that 
much benefits over plain maps and functions IMHO.

-- 
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/d/optout.

Reply via email to