[plt-scheme] Nested structures and inspectors

From: Dmitriy.Zavin at infineon.com (Dmitriy.Zavin at infineon.com)
Date: Fri Aug 13 15:08:43 EDT 2004


I was wondering how I can share inspectors (don't know if that's even
the right way to say it) between a parent structure and a nested child
structure. I want to serialize my structure into a file (network
socket), and deserialize it on the other side (using something like
match-lambda). If I use the same inspector for child and parent, the
parent cannot see the child's members. If I derive the child inspector
from the parent, it doesn't work either.

Basically to illustrate, this is roughly what I do:
	(define myinsp (make-inspector))
	(define-struct foo (a b c d) myinsp)
	(define-struct bar (e f g h) (make-inspector myinsp))

;;;;; I also tried this: (define-struct bar (e f g h) myinsp)

	(define foobar (make-foo 'a 'b 'c (make-bar 'e 'f 'g 'h)))
	(struct->vector foobar)
Now what I expected was to see the actual vector with all the nested
structure info expanded, i.e. 
	#5(struct:foo a b c #5(struct:bar e f g h))

However, what I got is this:
	#5(struct:foo a b c #<struct:bar>)

Does anyone have any suggestions how to accomplish what I need? I guess
my problem is that I do not understand how inspectors work and interact.

Thanks in advance.


P.S. Actually I am doing this through swig (I hacked support for native
scheme structure conversion from C structs, although somewhat limited)
through the C interface, but I try the approach through regular mzscheme
first to make sure it works. 

Posted on the users mailing list.