Clojure

Include drop, take, butlast from clojure.contrib.string (1.2) in clojure.string 1.3

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Declined
  • Affects Version/s: Backlog
  • Fix Version/s: Backlog
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test

Description

From clojure.contrib.string 1.2, I have found myself using drop, take,
and butlast. (These are more than just wrappers for String/substring,
because they behave nicely when indices exceed the string length.) I
like these methods in part because they match the behavior of
corresponding sequence methods, but have better performance. This
makes optimizing (when needed) easier.

Activity

Hide
Matthew Lee Hinman added a comment -

Attached patch for adding the methods.

Show
Matthew Lee Hinman added a comment - Attached patch for adding the methods.
Hide
Matthew Lee Hinman added a comment -

I intentionally left out the {:added "_"} from the vars since I have no idea when this will be added.

This (as expected) causes this test to fail:
[java] FAIL in (public-vars-with-docstrings-have-added) (metadata.clj:42)
[java] expected: (= [] (remove (comp :added meta) public-vars-with-docstrings))
[java] actual: (not (= [] (#'clojure.string/butlast #'clojure.string/drop #'clojure.string/take)))

Which is easily remedied. If desired, let me know what version this will be added to and I'll submit a new patch with the :added metadata included.

Show
Matthew Lee Hinman added a comment - I intentionally left out the {:added "_"} from the vars since I have no idea when this will be added. This (as expected) causes this test to fail: [java] FAIL in (public-vars-with-docstrings-have-added) (metadata.clj:42) [java] expected: (= [] (remove (comp :added meta) public-vars-with-docstrings)) [java] actual: (not (= [] (#'clojure.string/butlast #'clojure.string/drop #'clojure.string/take))) Which is easily remedied. If desired, let me know what version this will be added to and I'll submit a new patch with the :added metadata included.
Hide
Matthew Lee Hinman added a comment -

I have attached a patch with "1.4" as the added version now that 1.3 has been released.

Show
Matthew Lee Hinman added a comment - I have attached a patch with "1.4" as the added version now that 1.3 has been released.
Hide
Chouser added a comment -

The algorithms, docs, and tests look good. I think the functions would be better if they used clojure.core/subs like the rest of clojure.string does, instead of .substring. This is more idiomatic Clojure and allows you to avoid hinting the String arg.

When a new patch is uploaded, please remember to set the Patch field of this ticket to "Code and Test" and the Approval field to "Test". Hopefully this will lead to faster screening.

Show
Chouser added a comment - The algorithms, docs, and tests look good. I think the functions would be better if they used clojure.core/subs like the rest of clojure.string does, instead of .substring. This is more idiomatic Clojure and allows you to avoid hinting the String arg. When a new patch is uploaded, please remember to set the Patch field of this ticket to "Code and Test" and the Approval field to "Test". Hopefully this will lead to faster screening.
Hide
Matthew Lee Hinman added a comment - - edited

Attached a patch that uses subs instead of .substring (clj-826-add-take-drop-butlast-v3.diff).

Show
Matthew Lee Hinman added a comment - - edited Attached a patch that uses subs instead of .substring (clj-826-add-take-drop-butlast-v3.diff).
Hide
Stuart Halloway added a comment -

These fns were left out intentionally. Feel free to propose a contrib home for them, though.

Show
Stuart Halloway added a comment - These fns were left out intentionally. Feel free to propose a contrib home for them, though.

People

Vote (3)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: