halt-when not usable within #'c.c/into

Description

problem: when using the transducer-taking arity of c.c/into, it is not possible to use halt-when as a transducer.

significance: halt-when is commonly used to terminate processing, or barge through anomaly data when processing results. While halt-when is usable with transduce & conj, it is not usable with into, despite being semantically similar.

underlying reason: a flaw in the implementation of the transducer taking arity of into. The reducing fn passed to transduce is conj!, and this does not have a meaningful completion arity. In the impl, the completion applies afterwards, to the result of transduce. This means that halt-when's retfargument may see a transient value when the destination is editable, or a persistent value otherwise.

pseudocode of current impl:

where COMPLETE := persistent! & reattach metadata.

If halt-when received a persistent data structure instead of a transient, it would enable this code. Note the result is a map, determined by the retf:

proposal: push down the completion responsibilities into the reducing process, so that halt-when never encounters a transient as the result.

patch: clj-2556-into.patch

gist with more info

Environment

None
Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Unassigned

Reporter

Ghadi Shayban

Approval

Triaged

Patch

Code and Test

Priority

Major

Affects versions