help-gnu-emacs
[Top][All Lists]
Advanced

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

predicates (was: Re: How to test if the current line contains only white


From: Emanuel Berg
Subject: predicates (was: Re: How to test if the current line contains only white-spache?)
Date: Fri, 27 Nov 2015 00:59:22 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Alex Bennée <alex.bennee@linaro.org> writes:

> It's a predicate, giving a true/false response.

This is how I understand it:

In practice predicates can return anything.

nil, and the empty list, should be interpreted as *false*.

Anything else - including 0, 1, -1, "", and whatever
you are used to as a substitution/indication for false
are thus to be interpreted as *true* here. (`t' and
everything else are true as well, of course.)

If something sensible can be returned along with the
indication of trueness, that isn't bad and that can be
used for whatever purposes.

This definition is:

    A predicate is a function that tests for some
    condition involving its arguments and returns nil
    if the condition is false, or some non-nil value
    if the condition is true. [1]

However this means several functions that are
predicates are not named as such: e.g., `member',
which

    (member ELT LIST)

    Return non-nil if ELT is an element of LIST.
    Comparison done with `equal'. The value is
    actually the tail of LIST whose car is ELT.

But it is all good. I don't want the language all
-p'd. It is good tho for functions like `char-table-p'
because without it, if it was named "char-table", then
you wouldn't realize upon inspection it is a test,
probably you'd think it was some sort of constructor
or "returner" of a data structure. But with,
`char-valid-p', it is obvious to me at least what the
purpose is so the -p is a bit meaningless. But if it is
meaningless, it might as well be there, so I'm not
saying it should be removed, likewise `member'
shouldn't have the -p appended.

Computers are deterministic but that doesn't mean they
are consistent.

[1] https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node69.html

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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