Clojure

clojure.zip/down doesn't always return nil when called on leaf

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.1
  • Component/s: None
  • Labels:
    None
  • Approval:
    Ok

Description

The docs for zip/down state: "Returns the loc of the leftmost child of the node at this loc, or nil if no children", but in fact, down will always try to call the zipper's children function, even if branch? is false, i.e. on leaves. This behaviour is inconsistent with the doc string and with the behaviour of up, left and right, which always return nil.

(-> [1] clojure.zip/vector-zip clojure.zip/down clojure.zip/down)
; => java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer

Related, but not identical to #135

Activity

Hide
Assembla Importer added a comment -

achimpassen said: [file:bR_nykKWWr3P7IeJe5aVNr]

Show
Assembla Importer added a comment - achimpassen said: [file:bR_nykKWWr3P7IeJe5aVNr]
Hide
Assembla Importer added a comment -

richhickey said: This seems to conflict with the policy of #135, which is to throw if non-branch

Show
Assembla Importer added a comment - richhickey said: This seems to conflict with the policy of #135, which is to throw if non-branch
Hide
Assembla Importer added a comment -

achimpassen said: Why not have children throw and down return nil? The attached patch doesn't rely on one particular behaviour of children. IMHO, if down is supposed to throw, the doc string should be fixed, and for the sake of consistency, left/right/up should also throw on leftmost/rightmost/root nodes.

Show
Assembla Importer added a comment - achimpassen said: Why not have children throw and down return nil? The attached patch doesn't rely on one particular behaviour of children. IMHO, if down is supposed to throw, the doc string should be fixed, and for the sake of consistency, left/right/up should also throw on leftmost/rightmost/root nodes.
Hide
Assembla Importer added a comment -

achimpassen said: (In [[r:146f3614d100e9bce421afdcceee67aa0b956bb8]]) fixed zip/down on leaves, refs #185

Signed-off-by: Rich Hickey <richhickey@gmail.com>

Branch: master

Show
Assembla Importer added a comment - achimpassen said: (In [[r:146f3614d100e9bce421afdcceee67aa0b956bb8]]) fixed zip/down on leaves, refs #185 Signed-off-by: Rich Hickey <richhickey@gmail.com> Branch: master

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: