[CLJ-935] clojure.string/trim uses different defn of whitespace as triml, trimr Created: 21/Feb/12 Updated: 11/Apr/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.6 |
| Fix Version/s: | Release 1.6 |
| Type: | Defect | Priority: | Minor |
| Reporter: | Andy Fingerhut | Assignee: | Aaron Bedra |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Patch: | Code and Test |
| Description |
|
clojure.string/triml and trimr use Character/isWhitespace to determine whether a character is whitespace, but trim uses some other definition of white space character. For example: user=> (use 'clojure.string) The attached patch changes trim to use Character/isWhitespace. I suppose other possibilities are to change triml and trimr to use trim's notion of whitespace, whatever that is, or to just leave these functions inconsistent with each other. It does seem that it would be a nice property that (trim s) is equal to (triml (trimr s)) for all strings. The patch also changes triml to only call .length on s once. |
| Comments |
| Comment by Stuart Halloway [ 08/Jun/12 10:22 AM ] |
|
Question for Rich: do we want to be consistent across the different trim fns (per this patch) or consistent with Java, which uses one definition of whitespace in Character/isWhitespace, and a different definition in String/trim? |
| Comment by Stuart Halloway [ 08/Jun/12 10:22 AM ] |
|
Question for Andy: why the (int ...) forms, when Clojure only works with primitive longs? |
| Comment by Andy Fingerhut [ 08/Jun/12 10:33 AM ] |
|
Answer for Stuart: Looks like I was preserving the (int ...) form that was in triml before, perhaps somewhat mindlessly. Depending on Rich's answer, I can update the patch if desired. |
| Comment by Aaron Bedra [ 11/Apr/13 5:34 PM ] |
|
Bump on the discussion. This ticket seems blocked until we make a decision. |