printing recursive objects? (Harley Davis)
Wed, 5 May 1993 12:16:54 GMT

          From comp.compilers

Related articles
printing recursive objects? (Paul Haahr) (1993-05-03)
Re: printing recursive objects? (John Lacey) (1993-05-04)
printing recursive objects? ontos! (Tony Kanawati) (1993-05-04)
printing recursive objects? (1993-05-05)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Harley Davis)
Keywords: Lisp
Organization: Compilers Central
References: 93-05-018
Date: Wed, 5 May 1993 12:16:54 GMT (Tony Kanawati) writes:

    > Given an arbitrary recursive structure, say a lisp sexpr, how do you print
    > it in a form that can be read back to create the same structure?

      With pure data and a Lisp/Scheme READ/WRITE procedures, it is not possible
      to perform your task; because you cannot print nor read *REFERENCES*.

In fact, it is possible. Indeed, in many Lisps, including Le-Lisp and
CommonLisp, it is part of the standard printer and reader. (It is not
standard in Scheme.) See Guy Steele's "Common Lisp: The Language (2d
edition)", page 537, where the exact case mentioned in the original
article is discussed. A special print form is used, similar to that
described by another poster for his Scheme implementation. Since it is
somewhat expensive to manage, a special variable is used to control
whether circular objects are to be printed re-readably.

-- Harley Davis
nom: Harley Davis ILOG S.A.
net: 2 Avenue Gallie'ni, BP 85
tel: (33 1) 46 63 66 66 94253 Gentilly Cedex, France

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.