Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!news.sprintlink.net!siemens!princeton!news.princeton.edu!blume
From: blume@atomic.cs.princeton.edu (Matthias Blume)
Subject: Re: Boolean problems
In-Reply-To: conklic@gb.swissbank.com's message of 6 Feb 1995 11:22:48 GMT
Message-ID: <BLUME.95Feb7101158@atomic.cs.princeton.edu>
Originator: news@hedgehog.Princeton.EDU
Sender: news@Princeton.EDU (USENET News System)
Nntp-Posting-Host: atomic.cs.princeton.edu
Organization: Princeton University
References: <3h50q8$hfm@gpo.gb.swissbank.com>
Date: Tue, 7 Feb 1995 15:11:58 GMT
Lines: 49

In article <3h50q8$hfm@gpo.gb.swissbank.com> conklic@gb.swissbank.com (Charlie Conklin) writes:

   I am a relative newcomer to scheme, and am having some problems with
   a bit of code because of the differences between two scheme systems
   regarding the use of booleans, specifically the use of #f and ().
   The question I have is, are they interchangeable as the boolean
   false value?

In one word: no.

In many words: According to IEEE and as strongly recommended by R4RS
() and #f are different objects.  Only #f counts as false in boolean
contexts.  Both things are different from the symbol NIL (which
doesn't bear any special meaning).

   A couple of examples of the sort of problems I am having are:

		   #implementation 1       #implementation 2

   (and #f 1)      returns ()              returns #f
   (and () 1)      returns ()              returns 1

   also...

   (define (foo test)
     (case test
       ((hello) 1)
       ((#f) 2)
       ((()) 3)))

		   #implementation 1       #implementation 2

   (foo 'hello)    returns 1               return 1
   (foo #f)        returns 2               return 2
   (foo ())        returns 2               return 3

Implementation 2 is right in all cases.

   P.S. The differences are between mit-scheme 7.3 and the libscheme library.

Of course, my statement is a qualified statement: As far as IEEE is
concerned implementation 1 is wrong and implementation 2 is right.
However, since implementation 1 implements its own language, which
happens to be very close albeit not identical to IEEE scheme,
implementation 1 is correct, too.  It all depends on what you call
`correct'... :)

--
-Matthias
