cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
Yehonathan Sharvit 2019-09-11T15:41:24.087100Z

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?

2019-09-11T15:42:19.087400Z

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

Yehonathan Sharvit 2019-09-11T15:48:01.088Z

Clojure often claims that “Concrete derivation is bad”

Yehonathan Sharvit 2019-09-11T15:48:20.088500Z

Does it mean that specify should be avoid?

favila 2019-09-11T16:00:34.088600Z

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

👍 1
favila 2019-09-11T16:00:38.088800Z

specify operates on instances

favila 2019-09-11T16:01:08.089Z

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

favila 2019-09-11T16:01:29.089200Z

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

👍 1
Yehonathan Sharvit 2019-09-11T17:24:57.089600Z

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

Yehonathan Sharvit 2019-09-11T17:24:59.089800Z

?

favila 2019-09-11T17:27:08.090Z

Uh, the whole thing

favila 2019-09-11T17:28:37.090200Z

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)

favila 2019-09-11T17:31:19.090400Z

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 Sharvit 2019-09-11T17:44:35.090700Z

Thanks a lot for those clarifications