[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is booleanp defined this way?

From: Emanuel Berg
Subject: Re: Why is booleanp defined this way?
Date: Sat, 18 Apr 2015 01:06:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

address@hidden (Jorge A.
Alfaro-Murillo) writes:

>> Of course, this "normalizes" any "truthy" value to
>> "t", but is it really needed for anything (except
>> perhaps being elegant)?
> Perhaps so that it returns t instead of whatever, if
> whatever is not nil.

Yes, I think this is what the OP means by
"normalizes". Normalization is a university buzzword
for example in linear algebra where two vectors are
normalized to a common coordination system so they can
be compared.


    (booleanp t)   ; t
    (booleanp nil) ; t
    (booleanp 1)   ; nil!

To me it looks like t and nil as arguments evaluate to
t, and everything else nil - everything else that
isn't evaluated first to either of t or nil,
of course.

The "normalization" of which you speak should rather
look something like this:

    (defun normalize-boolean (obj)
      (if obj t) ) ; implicit (if obj t nil)

    (normalize-boolean 1)   ; t
    (normalize-boolean nil) ; nil

Or do you mean that `and' normalizes? It can, but that
would depend on the order:

    (and 1 t) ; t
    (and t 1) ; 1

So I think `booleanp' shouldn't be thought of as
a normalizer but rather as a type predicate, much like
them `stringp', `integerp', and so on.

underground experts united

reply via email to

[Prev in Thread] Current Thread [Next in Thread]