Vinzent <ru.vinz...@gmail.com> writes:

> 1. Clearly state in the section on interop that clojure, unlike java,
> doesn't treat 'false' and (Boolean. false) as equal objects.

Of course, it does!  But `if` doesn't check equality, it checks if the
test expression's result is *identical* to nil or false.

> 2. Clearly state in the doc of '=' that it should not be used for
> testing equality of booleans, since it could lead to confusing
> results.

Not at all.  But java.lang.Boolean-equality to true or false is
different to clojure's truthiness semantics, which state that everything
except nil and false is logical true.  Clearly, nil and false are not
equal, neither are 17 and "Foobar", but the former two are both falsy
and the latter two truthy.

> 3. Emphasis that 'true?' and 'false?' should be used instead of (= x
> false).

Depends on what you want to do.  false? and true? obey the clojure
semantics, while (= x false) with x being a Boolean object gives you the
java semantics.

So what's actually needed is a big red sign telling the clojure rule of
truthiness.  Everything except nil and false [1] is logical true.

[1] false is the primitive thingy, which is identical to Boolean/FALSE,
    (Boolean/valueOf false), or auto-unboxed false Boolean objects, but
    not to (Boolean. false).

Bye,
Tassilo

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to