Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!usc!cs.utexas.edu!uunet!husc6!mit-eddie!mit-amt!mob From: mob@mit-amt.MEDIA.MIT.EDU (Mario O. Bourgoin) Newsgroups: comp.lang.scheme Subject: The defintion of TRUE and FALSE in Scheme. Message-ID: <152@mit-amt.MEDIA.MIT.EDU> Date: 16 Jul 89 04:18:26 GMT References: <8907141728.aa02609@mintaka.lcs.mit.edu> Reply-To: mob@media-lab.media.mit.edu (Mario O. Bourgoin) Organization: MIT Media Lab, Cambridge MA Lines: 55 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