chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Printing recursive objects


From: Richard
Subject: Re: [Chicken-users] Printing recursive objects
Date: Fri, 26 Sep 2014 08:26:20 +0000

On Wed, 24 Sep 2014 16:00:29 -0700
Evan Hanson <address@hidden> wrote:

> Hi Richard,
> 
> On 2014-09-24 21:34, Richard wrote:
> > If I have an object that references itself, like for example...
> > 
> > (define v (vector 0))
> > (vector-set! v 0 v)
> > 
> > and I print it, chicken goes -understandably- into an infinite loop.
> > 
> > Is there a way to prevent this, or is there something like
> > define-record-printer for non-record objects.
> 
> FWIW there are `display` and `write` procedures in the scheme.write
> library of the r7rs egg that handle such objects. That module is
> self-contained and can be used without pulling in the rest of r7rs:
> 
>     #;1> (use scheme.write)
>     ;
> loading /home/evanh/.chickens/master/lib/chicken/7/scheme.write.import.so ... 
> ;
> loading /home/evanh/.chickens/master/lib/chicken/7/chicken.import.so ... ;
> loading /home/evanh/.chickens/master/lib/chicken/7/scheme.write.so ...
> #;2> (define v (vector 0)) #;3> (vector-set! v 0 v)
>     #;4> (display v)
>     #0=#(#0#)
> 
> Even so, csi's built-in writer will still loop on `v` if you don't
> explicitly print it. Maybe that behavior should also change when
> scheme.write is loaded, hmmm...
> 
> Evan
> 
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/chicken-users


Hello Jason and Evan,

Thanks for a solution and interesting background information.

Richard



reply via email to

[Prev in Thread] Current Thread [Next in Thread]