Clojure

PersistentVector implements IReduce but the no init arity throws

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: Release 1.7
  • Fix Version/s: Release 1.7
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Ok

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

Activity

Hide
Alex Miller added a comment -

Is that return null there right? In the case of no elements, you should invoke f with no args right?

Show
Alex Miller added a comment - Is that return null there right? In the case of no elements, you should invoke f with no args right?
Nicola Mometto made changes -
Field Original Value New Value
Attachment 0001-Implement-no-init-arity-of-reduce-for-PersistentVect.patch [ 13638 ]
Hide
Nicola Mometto added a comment -

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

Show
Nicola Mometto added a comment - 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
Nicola Mometto made changes -
Attachment 0001-Implement-no-init-arity-of-reduce-for-PersistentVect.patch [ 13640 ]
Alex Miller made changes -
Fix Version/s Release 1.7 [ 10250 ]
Description The reduce arity of IReduce in PersistentVector is implemented as: "throw new UnsupportedOperationException()".
See: http://dev.clojure.org/jira/browse/CLJ-1572?focusedCommentId=36878&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-36878
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-Implement-no-init-arity-of-reduce-for-PersistentVect.patch

*Screened by:*
Approval Incomplete [ 10006 ]
Nicola Mometto made changes -
Attachment 0001-Implement-no-init-arity-of-reduce-for-PersistentVect.patch [ 13640 ]
Nicola Mometto made changes -
Alex Miller made changes -
Approval Incomplete [ 10006 ] Screened [ 10004 ]
Alex Miller made changes -
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-Implement-no-init-arity-of-reduce-for-PersistentVect.patch

*Screened by:*
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-Implement-no-init-arity-of-reduce-for-PersistentVect.patch

*Screened by:* Alex Miller
Hide
Alex Miller added a comment -

Needs tests

Show
Alex Miller added a comment - Needs tests
Alex Miller made changes -
Approval Screened [ 10004 ] Incomplete [ 10006 ]
Hide
Nicola Mometto added a comment -

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

Show
Nicola Mometto added a comment - Updated patch adding testcases for PersistentVector.reduce in the already existing reduce test
Nicola Mometto made changes -
Attachment 0001-CLJ-1619-Implement-no-init-arity-of-reduce-for-Persi.patch [ 13738 ]
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-Implement-no-init-arity-of-reduce-for-PersistentVect.patch

*Screened by:* Alex Miller
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:* Alex Miller
Patch Code [ 10001 ] Code and Test [ 10002 ]
Alex Miller made changes -
Approval Incomplete [ 10006 ] Vetted [ 10003 ]
Hide
Stuart Halloway added a comment -

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)
Show
Stuart Halloway added a comment - 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)
Stuart Halloway made changes -
Approval Vetted [ 10003 ] Incomplete [ 10006 ]
Hide
Stuart Halloway added a comment -

nevermind, screening 1572

Show
Stuart Halloway added a comment - nevermind, screening 1572
Stuart Halloway made changes -
Approval Incomplete [ 10006 ] Vetted [ 10003 ]
Stuart Halloway made changes -
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:* Alex Miller
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
Approval Vetted [ 10003 ] Screened [ 10004 ]
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Stuart Halloway made changes -
Status Open [ 1 ] Closed [ 6 ]
Resolution Completed [ 1 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: