Mistake in Java translation in clojure.core.reducers/fold

Description

Fold will fail in the following example:

user=> (require '[clojure.core.reducers :as r])
nil
user=> (r/fold + (vec (range 0 10000)))
InvalidCastException Unable to cast object of type 'clojure/core/reducers$foldvecfn_22973_22977' to type 'System.Func`1[System.Object]'. clojure/core/reducers/fjtask--22518 (reducers.clj:73)

Please take a look at reducers.clj.

When the function foldvec calls fjtask it passes in a IFn, not a Func. Func is required by System.Threading.Task's ctor. Create the Func using sys-func. A .Net 4.0 build will throw the following exception without this change.

Environment

.Net 4.0

Activity

Show:
David Miller
May 11, 2015, 12:51 AM

Fixed in 1.7
Commit d75fe19, 2015.05.10

import
January 23, 2015, 5:26 PM

Comment made by: davidomeara

An IFn in Java implements Callable, which prevents this problem in Java. In C# there is no equivalent.

Completed

Assignee

David Miller

Reporter

import

Labels

Patch

Code