Re: Style question (predicates)

2014-04-17 Thread Leif
My personal preference is that fns ending in ? return a strict boolean, to be consistent with clojure.core. If I need the value I create another fn. So I would have nsf-code? *and* get-nsf-code. Plus for more complicated values, if you change their representation you don't have to change the

Re: Style question (predicates)

2014-04-17 Thread Zach Oakes
This is a bit tangential, but your function "is-nsf-code?" brings up another style question. Is it really necessary to use the "is-" prefix? I used to do this too, but I realized recently that it is a Java-ism and seems out of place in Clojure. Clojure's boolean functions do fine without it bec

Re: Style question (predicates)

2014-04-17 Thread Mars0i
While *every?* and *not-any?* return true or false, *some* returns the first truthy value in a sequence, or nil if there are none. Similarly, *empty?* returns true or false, while *empty* and *not-empty*return a collection or nil. However, it seems as if* some*, *empty*, and *not-empty *are int

Re: Style question (predicates)

2014-04-17 Thread John Wiseman
In the Common Lisp world it's common for predicates to return a useful value instead of T, when applicable. It seems possible the same principle could apply to clojure. >From CLtL2 : Often a predicate will return nil if it ``fails'' and

Re: Style question (predicates)

2014-04-17 Thread Colin Yates
My 2p - I interpret the contract as being boolean. Truthy values are 'polymorphically' equivalent*1 so sure. The concern would be people relying on the implementation and treating the values as none-truthy (i.e. in your example relying on the fact it is a string being returned, so (= "someStr

Style question (predicates)

2014-04-17 Thread Sean Corfield
The library coding standards[1] say: * Use '?' suffix for predicates. - N.B. - predicates return booleans and the community Clojure style guide[2] says: * The names of predicate methods (methods that return a boolean value) should end in a question mark. (i.e.even?). Both of these imply that