Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!agate!linus!linus!guttman From: guttman@linus.mitre.org (Joshua D. Guttman) Newsgroups: comp.lang.lisp Subject: Re: FALSE vs empty list Summary: an example to distinguish 'em Message-ID: <119011@linus.mitre.org> Date: 4 Sep 90 18:15:19 GMT References: <24305@uflorida.cis.ufl.EDU> Distribution: usa Organization: The MITRE Corporation, Bedford MA Lines: 39 Well here's an example of why it would be nice to have '() and #f (in scheme notation) be distinct. (Note: I believe that in the new Scheme standard (R4RS) they will be required to be distinct, with the null list counting as non-false in conditional tests. Just imagine!) Suppose you're doing syntactic matching or unification or some procedure like that which wants to return a substitution when it succeeds. So ((x . 23) (y . 34)) means substitute 23 for x and 34 for y and you have a match. Then it's natural for () to mean that you don't have to substitute anything, because the expressions already match. However, what do you return when the expressions can't be made to match, e.g. (* x 3) and (+ x 3)? Well, you would normally want to return #f to indicate failure, but if () = false you can't, because that indicates you have succeeded. So you have to do a ghastly hack like return the symbol FAIL. This is highly unpleasant when you want to write code like (any (lambda (exp) (match exp fixed-exp)) some-list) since you have to rewrite it as an iteration with a test for non-FAILing return value. Even (any (lambda (exp) (let ((subst (match exp fixed-exp))) (and (succeed? subst) subst))) some-list) is wrong. Josh