Fork me on GitHub
#portland-or
<
2016-10-13
>
juliobarros03:10:38

November’s meetup is a remote presentation on spec by Stuart Halloway https://www.meetup.com/clojure-pdx/events/234818929/

bill15:10:05

Reading Alex Miller’s wonderful post on Clojure collections this AM: http://insideclojure.org/2016/03/16/collections/ He says: "Ideally traits would be defined as Clojure protocols, but their implementation dates back to the earliest days of Clojure, well before protocols existed and as such they are defined by Java interfaces.” A little poking led me to the happy discovery that ClojureScript, by dint of being developed post-Clojure-1.2 I suppose, and having the benefit of Protocols, implements the collection traits as protocols yay!

bill15:10:44

related question: I notice from the Sequences documentation, this extremely clarifying blurb: "Many of the functions in the seq library take one or more collections, call seq on them, and then operate on the resulting seq. In other words, many of these functions take collections but operate on their seqs.” I wonder why the implementors chose to (unconditionally) call seq on a (collection) argument instead of adding a function (of ^ISeq) to the multimethod (in each case) and using dispatch instead. Wouldn’t dispatch have a potential performance advantage?

bill15:10:32

Apparently (and happily) the whole notion of “interfaces” (as opposed to “protocols”) is entirely absent from ClojureScript. A clue is here: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#compilation-and-class-generation “`gen-class`, gen-interface, etc. are unnecessary and unimplemented in ClojureScript"

bill15:10:26

And so, circling back to my original question about the seq call versus multimethod dispatch on ^ISeq (an interface type)—that wouldn’t work in ClojureScript I suppose.

bill15:10:58

But wait, David Nolen fixed “Support Types & Protocols as Type Hints” in ClojureScript: http://dev.clojure.org/jira/browse/CLJS-308 So apparently, multimethod dispatch on ^ISeq (the protocol) would work in ClojureScript.