[plt-scheme] Printing Structures without using custom-write

From: Sam TH (samth at ccs.neu.edu)
Date: Wed Oct 10 15:39:08 EDT 2007

I have this already, because it would be very hard to some things
otherwise.  But it's not a total solution - you can't debug your write
handler with printf, because you immediately get an infinite loop.

Also, it requires having all your structures defined with a macro that
expands to define-struct, which is the case for me, but limits the
applicability of the technique.

Thanks,

sam th

On 10/10/07, Robby Findler <robby at cs.uchicago.edu> wrote:
> If you only want to turn this off for debugging, you might consider
> just having a macro that doesn't install the custom write handlers
> when in a debugging mode.
>
> Robby
>
> On 10/10/07, Sam TH <samth at ccs.neu.edu> wrote:
> > In the implementation of Typed Scheme, I have a large number of
> > structures, representing types, which have custom printers, via the
> > custom-write structure property.  Sometimes, however, I'd like to be
> > able to turn off the use of the custom-write property, and just see
> > that actual contents of the structures.  However, there doesn't seem
> > to be a way to do this at the moment.  Have I missed something?
> >
> > I can think of two possible solutions here:
> >
> > 1. Provide a parameter that controls whether the custom-write property
> > is considered for the printing of structs.  This would have global
> > effect, and therefore might not be what you want (it might have
> > abstraction-breaking effects).
> >
> > 2. Call the custom writer with one additional (maybe optional for
> > compatibility) argument that does writing, but without using the
> > custom printer for the particular struct type under consideration.
> > Then I could implement a parameter that controlled custom printing
> > just for my structs.  However, this requires more effort on the part
> > of custom printer authors.
> >
> > Are there other ideas on how this might work?  Are there other
> > languages or systems that have encountered this issue, and solved it
> > nicely?
> >
> > Thanks,
> >
> > --
> > sam th
> > samth at ccs.neu.edu
> > _________________________________________________
> >   For list-related administrative tasks:
> >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
>


-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.