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

Re: NULL?




   From: "Guillermo J. Rozas" <gjr@martigny.ai.mit.edu>
   Date: Tue, 7 Jan 1997 20:44:03 -0500
   Reply-To: gjr@martigny.ai.mit.edu

   I've just been reading Richard's draft and the absence of NULL? from
   the list of predicates for disjoint types struck me as odd.

   I vaguely recall having some discussion on the topic, but I can't
   recall the substance.

In the section on pairs and lists the report says

  The empty list is a special object of its own type (it is not a
  pair); it has no elements and its length is zero.

which implies that NULL? is a disjoint type predicate.  It would be
clearer to explicitly list it as such.

   Furthermore, NULL? is listed as a library procedure, rather than a
   primitive.  This leads me to believe that the implied implementation
   is

       (define (null? obj)
	 (and (not (boolean? obj))
	      (not (symbol? obj))
	      (not (char? obj))
	      (not (vector? obj))
	      (not (procedure? obj))
	      (not (pair? obj))
	      (not (number? obj))
	      (not (string? obj))
	      (not (port? obj))))

   This strikes me as somewhat ugly (in its asymmetry -- why pick on the
   empty list) and potentially bad.

The implementation I had in mind was

(define (null? obj)
  (eqv? obj '()))

                                -Richard Kelsey