[racket-dev] Transparent Structures in XML Library

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Oct 3 19:49:02 EDT 2011

I understand. Specifics: 

On Oct 3, 2011, at 7:45 PM, Doug Williams wrote:

> Basically, I'm just suggesting that the xml package have sensible printing of its structures. I can't imagine any case where you really want the default printing of recursive structures of that complexity and potential size to be the visible behavior.


When you write very small XML pieces of data (say something that fits on 80 lines, 80 chars each), this kind of printing is just fine. 


> Where it was annoying me was in my inference engine when I was doing inference across very large xml documents. I have a trace feature in the inference engine to trace assertions that is very useful for debugging rules. You can imagine the output when I turned it on the first time with one of the large xml documents. Literally, one assertion was 100+ pages.
> 
> I've pushed a new version of the inference engine that uses ~.s throughout. So, at least it prints it reasonable. But, it is still continually walking the structures and building a huge string (at least 10s of megabytes each at the highest levels). And, it has to do that for every assertion in a trace.


I am proposing an alternative approach. Write an adapter module for the XML library that does NOT bother to traverse the structure to create some huge and useless string. 

Is this possible for your world? 

-- Matthias




> At least I have a large memory machine with plenty of memory (and, thanks to you guys, a 64-bit windows version), so it does run. It's just annoying.







> 
> On Mon, Oct 3, 2011 at 4:34 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
> 
> Doug, does this concrete example concerning printing help:
> 
> #lang racket/load
> 
> (module a racket/base
>  (struct xml (bar) #:transparent)
> 
>  (define x (xml "bar"))
>  (displayln x)
> 
>  (provide (struct-out xml) x))
> 
> (module b racket/base
>  (require 'a)
> 
>  (struct my xml () #:property prop:custom-write (lambda (x p z) (displayln "<my xml>" p)))
> 
>  (define y (my "bar"))
> 
>  (displayln y))
> 
> (require 'b)
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20111003/be49fb24/attachment.html>

Posted on the dev mailing list.