On Monday, September 11, 2023 at 12:51:51 PM UTC-7, Kaz Kylheku wrote:
> On 2023-09-11, Tom Russ <tar...@google.com
> > Now, the IF statement works differently. It will treat any value except FALSE
> > or NIL as being true. https://clojuredocs.org/clojure.core/if
> That looks like a giant clusterfuck.
It is in keeping with how Lisp traditionally defined "generalized booleans", and how
it is specified in the CommonLisp spec. Scheme is similar in treating anything other
then #f as being a true value. Similar logic can be found in many other languages like
the C-family (although zero counts as false as well there).
This is clearly not as type-safe as allowing only true Boolean values (t/nil; #t/#f, true/false)
to be used on conditionals, but it is not an uncommon design choice. It would be
cleaner in semantics to make the test more explicit about the condition, but there is
a legacy of languages often allowing various shortcuts in accepting a wider range
of values in places where boolean are semantically desired.