From: Thomas A. Russ
Subject: Is there any way to get LispWorks or CMUCL to print NIL as () ?
Date: 
Message-ID: <ymig0973zwd.fsf@sevak.isi.edu>
Is there a way to one get LispWorks or CMUCL to print NIL as a pair of
parentheses: () ?

In other Lisp systems such as ACL and MCL one can define methods on
PRINT-OBJECT that will force this to happen, either by specializing on
the class NULL or by using an (EQL NIL) specializer.  Unfortunately, it
appears that this doesn't work for Lispworks or CMUCL.

Are there any other possibilities?

-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu    

From: David Bakhash
Subject: Re: Is there any way to get LispWorks or CMUCL to print NIL as () ?
Date: 
Message-ID: <c29k7yieqjg.fsf@nerd-xing.mit.edu>
···@sevak.isi.edu (Thomas A. Russ) writes:

> Is there a way to one get LispWorks or CMUCL to print NIL as a pair
> of parentheses: () ?

I don't have a CL system here, but the following should work:

(defmethod print-object ((x null) stream)
  (write-stream "()" stream))

Of course, this doesn't take *print-readably* and that stuff into
account, but this is the basic deal.

dave
From: Kent M Pitman
Subject: Re: Is there any way to get LispWorks or CMUCL to print NIL as () ?
Date: 
Message-ID: <sfwzo7eka3w.fsf@world.std.com>
David Bakhash <·····@mit.edu> writes:

> ···@sevak.isi.edu (Thomas A. Russ) writes:
> 
> > Is there a way to one get LispWorks or CMUCL to print NIL as a pair
> > of parentheses: () ?
> 
> I don't have a CL system here, but the following should work:
> 
> (defmethod print-object ((x null) stream)
>   (write-stream "()" stream))
> 
> Of course, this doesn't take *print-readably* and that stuff into
> account, but this is the basic deal.

You aren't allowed to do this according to the spec.  You should expect
that you have broken the implementation once you do this.

  11.1.2.1.2 Constraints on the COMMON-LISP Package for Conforming Programs

  Except where explicitly allowed, the consequences are undefined if
  any of the following actions are performed on an external symbol of
  the COMMON-LISP package:

  ...
  19. Defining a method for a standardized generic function which is
  applicable when all of the arguments are direct instances of standardized
  classes. 
  ...

The print behavior of primitively defined objects is effectively fixed.
Changing this may break programs which expect NIL to print the other way.
People used to do this a lot, and it is as often wrong as write.

It's better to just turn on pretty-printing when you're doing stuff that
would care by context.  It will typically print (DEFUN FOO () ...) without
affecting other NIL's.

There are also situations where the use of ~:S may help, but this (of course)
affects only the top-level of the datum to be printed and is not pervasive
into its subcomponents.
From: Thomas A. Russ
Subject: Re: Is there any way to get LispWorks or CMUCL to print NIL as () ?
Date: 
Message-ID: <ymiadzb3vmw.fsf@sevak.isi.edu>
Well, we actually ended up solving our problem by a combination of just
doing our own element by element printing of lists for normal output and
using a pretty-printer dispatch for pretty-printed output.

-Tom.

-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu