Clojure

Add zero-arity versions of every-pred and some-fn

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Triaged

Description

Zero-arity versions of these fns are useful in situations like the following:

;; compute-preds-for may return zero or many predicate fns
(let [preds (compute-preds-for something)]
  (filter (apply every-pred preds) some-coll))

Approach: This patch adds zero-arity versions of every-pred and some-fn with these semantics:

(every-pred) === (constantly true)
(some-fn)    === (constantly nil)

Patch: 0001-Add-zero-arity-variants-for-every-pred-and-some-fn.patch

  • Patch adds zero-arity version
  • Patch reformats docstring to 80 character width (matching other core fns) - comments are identical other than the addition of a final sentence stating behavior with zero-arity.

Screened by:

Activity

Hide
Alex Miller added a comment -

My goal was to simplify the patch so it is easier to review. Since the comment is identical (except for the last line), we can instead note that as a feature of the patch.

Show
Alex Miller added a comment - My goal was to simplify the patch so it is easier to review. Since the comment is identical (except for the last line), we can instead note that as a feature of the patch.
Hide
Tassilo Horn added a comment -

@Alex: That I've reformatted the docstring so that it doesn't look like a comb and fits in 80 columns is a feature. Should I really revert to the original, ugly, less readable formatting only to make the patch 8 lines shorter?

Show
Tassilo Horn added a comment - @Alex: That I've reformatted the docstring so that it doesn't look like a comb and fits in 80 columns is a feature. Should I really revert to the original, ugly, less readable formatting only to make the patch 8 lines shorter?
Hide
Tassilo Horn added a comment -

Rebased patch.

Show
Tassilo Horn added a comment - Rebased patch.
Hide
Alex Miller added a comment -

Tassilo, can you undo the line break changes on this patch to minimize the patch differences?

Show
Alex Miller added a comment - Tassilo, can you undo the line break changes on this patch to minimize the patch differences?
Hide
Tassilo Horn added a comment -

This is the thread where Max Penet suggested to have 0-arity versions of the two fns:

https://groups.google.com/forum/?fromgroups=#!topic/clojure/IRlN-4LH_U0

Show
Tassilo Horn added a comment - This is the thread where Max Penet suggested to have 0-arity versions of the two fns: https://groups.google.com/forum/?fromgroups=#!topic/clojure/IRlN-4LH_U0

People

Vote (2)
Watch (1)

Dates

  • Created:
    Updated: