PersistentVector implements IReduce but the no init arity throws

Description

The reduce arity of IReduce in PersistentVector is implemented as: "throw new UnsupportedOperationException()".

After the CLJ-1572 patch is applied the following code will throw:

(reduce + [1 2])

Approach taken: Implement reduce(f) in PersistentVector.

Alternative: An alternate would be to change PersistentVector from IReduce to IReduceInit and remove the reduce without init function. In this case, reducing a vector would fall back to seqs.

Patch: 0001-CLJ-1619-Implement-no-init-arity-of-reduce-for-Persi.patch

Screened by: Stu

Environment

None

Attachments

2

Activity

Show:

Stuart Halloway January 9, 2015 at 5:52 PM

nevermind, screening 1572

Stuart Halloway January 9, 2015 at 5:50 PM

I don't understand the problem here. coll-reduce appears to cut off ever hitting this path (the tests call underlying interfaces directly).

  • Need a public API example showing the failure

  • Need tests covering main branches (i.e. the empty case)

Nicola Mometto January 9, 2015 at 2:33 PM

Updated patch adding testcases for PersistentVector.reduce in the already existing reduce test

Alex Miller January 9, 2015 at 2:14 PM

Needs tests

Nicola Mometto December 18, 2014 at 5:04 PM

you're right, I didn't know that detail about the behaviour of reduce. Updated the patch to invoke (f) rather than returning nil when the coll is empty

Completed

Details

Assignee

Reporter

Approval

Ok

Patch

Code and Test

Priority

Affects versions

Fix versions

Created December 17, 2014 at 11:18 PM
Updated January 10, 2015 at 3:24 PM
Resolved January 10, 2015 at 3:24 PM