From: David Gadbois
Subject: Re: *print-readably* and functions
Date: 
Message-ID: <69iskc$kkp$1@news3.texas.net>
Sam Steingold  <ยทยทยท@usa.net> wrote:
>Question: I have some structures, some fields of which are functions.
>Is there a way to print them readably?

No: *PRINT-READABLY* is defined in terms of object similarity, and
there is no similarity relationship defined for function objects.
Some implementations may work hard to do the obvious thing for cases
like language-defined functions, but it won't work in the general
case.  To see why, consider:

    (let ((x 0)
	  (*print-readably* t))
      (print (list #'(lambda () (incf x))
                   #'(lambda () (incf x)))))

Here, what is to be done about setting up the shared lexical
environment upon re-reading the printed expression?

This can be a real portability gotcha.  One workaround is to store a
re-readable designator for a function instead of a function object.
Another is to special-case slots that may have function objects in
them in your print functions.

--David Gadbois