Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Clojure by
To safely test if an arbitrary seq is realized (non-lazy), we need a wrapper like:


(defn seq-realized? [s]
  (if (instance? clojure.lang.IPending s)
    (realized? s)
    true))


If {{realized?}} returned true for an ({{ISeq}}?) instance that is not {{IPending}} there would be less surprising behavior for cases such as, {{(realized? (range 10))}} which throws exception.

NB: A follow-up to CLJ-1751.

4 Answers

0 votes
by

Comment made by: marc

Attaching a patch that makes realized? return true for non-pending xs.

0 votes
by

Comment made by: marc

Scratch that - patch is no good.

0 votes
by

Comment made by: marc

Attaching a patch that makes realized? return true for non-pending xs. Add tests for the IPending types.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1752 (reported by alex+import)
...