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

Re: #T, #F unhappiness



As the release notes state, the point of #T and #F is to give a read
syntax for truth and falsity.  They are not intended to be used in
value-producing positions.  If you read carefully, you'll see that the T
manual doesn't define what #F (i.e. ()) evaulates to, and the release
notes don't define what #T evaluates to.  A reason for introducing
#T and #F is to make people think about the difference between expressions
and the objects they denote or evaluate to.  True and false and the CAR
procedure are different from expressions like T and NIL and CAR which
evaluate to them.  If you think about it, numbers, strings, and characters
are really anomalous in Lisp, because they self-evaluate; for a less
confusing semantics, one ought to have to quote them, the same way you
have to quote symbols and lists:
	(+ '2 '3) => 5
but I think that might turn many people off.

See Brian Smith's paper, "Reflection and Semantics in Lisp," in the
Conference Record of the Eleventh Annual ACM Symposium on Principles
of Programming Languages (1984), for an exposition of these ideas.

You don't need to use them if you don't want to.  It's probably a bad
idea to use #T in T 2.8, since TC can't cope with it.  Its announcement
is premature.

Jonathan

---------
Appendix - from a style manual under development.  I don't want to
dictate style, so please feel free to ignore this and its strident tone.

    True and false.

    Never use (), #f, or #t in value-producing positions.  Use them only
    inside of quoted structure, or in other non-evaluated positions.

	    Good:   (lambda () (foo a b))
		    (lambda () (foo t nil))
		    (lambda () (foo '() '(a) '(a b)))
		    (lambda () (foo '(#t #f)))
		    (object nil ((op self) 3))
	    Bad:    (lambda () (foo #t #f))
		    (lambda () (foo t ()))
		    (lambda () (foo () (list) (list 'a) (list 'a 'b)))
		    (object () ((op self) 3))

    () should always mean a list, #f a truth value.  (Of course, as stated
    above, neither should be used in any evaluated position.)  Use T as an
    expression yielding a true value, NIL as an expression yielding a false
    value, and neither in non-value-producing positions.

	    Good:   (append '(a b) '())
		    (null? '())
		    (not nil)
		    (not (car '(#f #t)))
	    Bad:    (append '(a b) nil)
		    (null? nil)
		    (not '())
		    (not (car '(() (a b))))

    Use #F for ignored bound variable positions:
		    (destructure (((a b #f d) l))
		      ...)