Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by
  1. This currently doesn't work:

(->> nil

 (r/map identity)
 (r/reduce + 0))
 ; org.mozilla.javascript.JavaScriptException: Error: No protocol method IReduce.-reduce defined for type null

The reason for this is that reducers created by r/reducer or r/folder, invoke -reduce (of IReduce) directly. They thereby bypass the special case for nil in the function r/reduce.

  1. An entirely analogous problem exists for collections of type array.

  2. The patch CLJS-700 mistakenly defined coll-fold for the type cljs.core/IPersistentVector. This should have been cljs.core/PersistentVector. (There exists no protocol IPersistentVector in ClojureScript.)

I will shortly attach a patch that addresses all of the above problems by implementing IReduce for nil and array. The patch also includes unit tests.

18 Answers

0 votes
by

Comment made by: dnolen

Yes but now that we have new logic we can at least test the lack of regression on the other types.

0 votes
by

Comment made by: dnolen

Ok I tried to apply this patch and run {{./script/benchmarks}} in the repo but the patch will no longer apply. Can we rebase the patch on master. Thanks. If you also want to give the benchmarks a shot follow these instructions to install the JS engines - http://github.com/clojure/clojurescript/wiki/Running-the-tests. Then you can also run the benchmarks at the command line. I see there aren't any reducers benchmarks, I will add some.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-736 (reported by jdevuyst)
...