Re: clojure.string unexpected behaviors

2016-06-23 Thread Elena Machkasova
I wasn't saying that the functions implementation is incorrect (it does follow the specification). However, I think 'capitalize' obscures the error in the case when it would've been easy to fail early and produce meaningful error reporting (as 'reverse' does). Adding spec conditions would help,

Re: clojure.string unexpected behaviors

2016-06-21 Thread Sean Corfield
On 6/21/16, 1:28 PM, "Alex Miller" wrote: > I'm not a fan of the word "garbage" in this case or "garbage in / garbage > out". For me there’s no judgment involved in the “GIGO” principle but fair enough. > "specified"/"unspecified" is much better. It’s inaccurate. Unspecified behavior is where

Re: clojure.string unexpected behaviors

2016-06-21 Thread Alex Miller
On Tuesday, June 21, 2016 at 2:45:45 PM UTC-5, Sean Corfield wrote: > > Alex gave you a correct (but fairly short) answer. I’d like to expand on > it a bit, partly in light of a certain recent blog post, partly because of > a personal “hot button”… > > This is going to be along the same lines as

Re: clojure.string unexpected behaviors

2016-06-21 Thread Sean Corfield
Alex gave you a correct (but fairly short) answer. I’d like to expand on it a bit, partly in light of a certain recent blog post, partly because of a personal “hot button”… This is going to be along the same lines as clojure.set functions producing “garbage” output if you give them “garbage” in

Re: clojure.string unexpected behaviors

2016-06-21 Thread Alex Miller
There are some comments at the top of clojure.string (http://clojure.github.io/clojure/#clojure.string) about expected usage. In particular, you should expect all clojure.string functions to accept CharSequence (a parent interface of String, StringBuffer, and StringBuilder and return the same (

clojure.string unexpected behaviors

2016-06-21 Thread Elena Machkasova
Greetings, I was looking at clojure.string functions, and noticed that some have unexpected (especially for less experienced programmers) behavior on non-string arguments. For instance, 'capitalize' applies toString to its argument, effectively making it possible to pass any type, but with une