[plt-scheme] The Inspector's Brother

From: John Kozak (jk at xylema.org)
Date: Sat Sep 24 15:31:16 EDT 2005

I'm writing something a bit like a persistent object system.
This has user-definable struct types, all of which are subtypes of an
urstruct buried away in a module.  I'd like the module to be able to
walk the fields of all instances of the derived types, but don't
particularly want them to be open to the world.  

To achieve this, I'm doing this within the module:

  (define *inspector*     (make-inspector))
  (define *sub-inspector* (make-inspector *inspector*))

  (current-inspector (make-inspector))

  ;; all of my structs are defined with inspector *sub-inspector*

which does what I want, but is yucky, side-effecting the requirer's
state in a subtle and very non-obvious way.  Probably won't actually
ever be a problem, but not nice, anyway.

I think what I want is (make-sibling-inspector), equivalent to
(make-inspector (parent-inspect)), if parent-inspector were 
available, which obviously it can't be.  Or am I missing a better way
of doing this?

John

   




Posted on the users mailing list.