Fork me on GitHub
#beginners
<
2017-03-15
>
danp06:03:26

Hey all, I'm just going over this chapter in Clojure for the Brave and True: http://www.braveclojure.com/multimethods-records-protocols/

danp06:03:57

I'm having a bit of difficulty understanding extending records with protocols, so I'm having a look at this Clojure reference page: https://clojure.org/reference/datatypes

danp06:03:33

In the first paragraph of the latter link, there are references to host interfaces, host classes and the host platform. Just for clarification, are these refering to Java interfaces and classes, and the JVM, respectively?

val_waeselynck07:03:21

@danp those references in the first paragraph are about the implementation details of Clojure JVM, i.e the way that collections etc are implemented.

val_waeselynck07:03:52

indeed they are Java interfaces and classes, (e.g clojure.lang.ILookup, clojure.lang.PersistentArrayMap etc.)

val_waeselynck07:03:16

this is not the case for ClojureScript, where protocols are at the bottom of the implementation

val_waeselynck07:03:31

(which is kind of awesome)

danp08:03:52

Thanks @val_waeselynck. I thought this was the case, but didn't want to assume 🙂

sif17:03:03

Hi! In reify doc, it says, methods should be supplied for all methods of desired protocol(s), but Clojure let us give a partial set implementation of protocol methods, I'm I not understanding something?

noisesmith17:03:59

sifou nope, you don’t need to implement any of the methods, but you’ll just get an error if one gets called that wasn’t implemented

noisesmith17:03:45

that is, no, you don’t misunderstand, clojure lets you implement as few as you like (even 0), and you just get a run time error later if they are called

sif17:03:07

@noisesmith I see, thank you for clarification 🙂 So that's what is meant in doc string

noisesmith17:03:24

sifou I guess by “should’ they mean “it’s probably a good idea…"

sif17:03:56

@noisesmith yes 🙂