guile-user
[Top][All Lists]
Advanced

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

Re: iff?


From: Jim Blandy
Subject: Re: iff?
Date: 21 Apr 2001 19:24:24 -0500

Keith Wright <address@hidden> writes:
> I have a PhD in theoretical computer science, emphasis in logic,
> and I say it's not just clearer for the non-mathematical, but
> also for the very picky.  If you say
> 
>    (null? x) returns #t iff x is the empty list
> 
> you have said almost nothing about what it returns if x is
> not the empty list.

I'm probably responsible for most of the `iff' usage.  In my own
defense, I usually say:

    (foo x) returns true iff x is foo-like.

Since all values but #f are true, it's clear that the function must
return #f if x is not foo-like.  As you point out, however, it doesn't
promise that (foo x) ever returns at all if x is not foo-like.

I've gotten questions about uses of `iff' in other contexts as well.
Given that it's not widely understood, and that the alternative
wording

        (foo x) returns true if x is foo-like; otherwise, it returns
        #f.

is:
- clear to a broad audience, 
- more precise (since it guarantees termination no matter what x is), and
- not too much more verbose,

it seems to be the clearly preferable wording.

In Emacs, the first line of any docstring is supposed to be a
self-contained summary of the function's behavior.  The `apropos'
commands take advantage of this, and show you the first line of each
matching command/function/variable's docstring.  The appeal of `iff'
is that it is somewhat briefer, which sometimes allowed me to fit a
better description into that first line.



reply via email to

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