mob@mit-amt.MEDIA.MIT.EDU (Mario O. Bourgoin) (07/16/89)
I've been wanting to replace the usual LISP definitions of TRUE and
FALSE by functions because that seems more in the spirit of Scheme.
Furthermore, with functions we can eliminate ``if'' and ``cond'' from
the essential syntax of Scheme which simplifies the analysis of
extensions to Scheme such as Zabih, McAllester, and Chapman's
non-deterministic operator, ``amb''. I would like to get the Scheme
community's reaction to the specification of particular objects for
TRUE and FALSE, namely the functions:
(define true (lambda (iftrue iffalse) iftrue))
(define false (lambda (iftrue iffalse) iffalse))
Naturally, the constants #t and #f would always denote the appropriate
one of these two functions.
Given the above definitions for TRUE and FALSE, ``if'' statements can
be replaced according to the following pattern:
(if predicate iftrue iffalse) =>
((predicate (lambda () iftrue) (lambda () iffalse)))
And ``cond'' may be replaced thus:
(cond (predicate1 body1)
(predicate2 body2)
(predicate3 body3)
(else bodyelse))
becomes:
((predicate1
(lambda () body1)
(lambda ()
((predicate2
(lambda () body2)
(lambda ()
((predicate3
(lambda () body3)
(lambda () bodyelse)))))))))
The logical connectives ``not'', ``and'', and ``or'' could be defined
as follows.
(not predicate) => (predicate false true)
(or predicate1 predicate2) => (predicate1 true predicate2)
(and predicate1 predicate2) => (predicate1 predicate2 false)
Naturally, the definitions for ``or'' and ``and'' can be extended to
handle a variable number of parameters.
Please tell me of any problems you see with such a definition.
--Mario O. Bourgoin