Fork me on GitHub
#cljs-dev
<
2019-09-11
>
Yehonathan Sharvit15:09:24

A question about the kind of OO stuff that clj and cljs provide. In cljs, we have specify and specify! and not in clj. What’s the reason for this diff between cljs and clj?

mikerod15:09:19

@viebel probably because it’s hard to pull off on the JVM - or not really feasible

Yehonathan Sharvit15:09:01

Clojure often claims that “Concrete derivation is bad”

Yehonathan Sharvit15:09:20

Does it mean that specify should be avoid?

favila16:09:34

“concrete derivation is bad” I think is in the context of classes

👍 4
favila16:09:38

specify operates on instances

favila16:09:08

IIRC specify was created (along with clone) by David Nolen to implement om’s cursors

favila16:09:29

Implementing cursors without some kind of generic proxying would be really rough

👍 4
Yehonathan Sharvit17:09:57

Do you remember what features of cursor would be hard without generic proxying

favila17:09:08

Uh, the whole thing

favila17:09:37

A cursor wraps a particular instance of a data structure, but adds extra contracts (the root, it’s path in the data structure, protocols to transact against the mutable container that holds it)

favila17:09:19

for it to, at runtime, both behave/type like a normal collection (whatever type it is) and also have these extra things added, you need to delegate some interfaces related to cursoring and pass through unrelated ones you don’t know about. You can do this in Java with reflection (DynamicProxy I think); but in JS it’s faster and easier to adjust the prototype.

Yehonathan Sharvit17:09:35

Thanks a lot for those clarifications