printing recursive objects?

davis@ilog.ilog.fr (Harley Davis)
Wed, 5 May 1993 12:16:54 GMT

          From comp.compilers

Related articles
printing recursive objects? haahr@mv.us.adobe.com (Paul Haahr) (1993-05-03)
Re: printing recursive objects? johnl@cs.indiana.edu (John Lacey) (1993-05-04)
printing recursive objects? ontos!tonyk@uu.psi.com (Tony Kanawati) (1993-05-04)
printing recursive objects? davis@ilog.ilog.fr (1993-05-05)
| List of all articles for this month |

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

tonyk@ontos.com (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: davis@ilog.fr 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.