[plt-scheme] idioms for inspectors?
I have a basic idea of how inspectors work, but I'm not sure about the
standard idioms for using them.
So, here's my situation:
(module ast mzscheme ...)
(module parser mzscheme (require ast) ...)
The first module defines and exports a bunch of structures that I use as
the AST for the language I'm working with. The parser module parses an
s-expression and produces an AST made from these structures.
I'm trying to write test cases for the parser module, which compare the
expected results and the actual results using equal?. This obviously
requires a sufficiently powerful inspector.
I've achieved this by writing the ast module as follows:
(module ast mzscheme
(define old-inspector (current-inspector))
(current-inspector (make-inspector))
(define-struct program (defns main))
(define-struct defn (name superclass fields methods))
....
(current-inspector old-inspector)
(provide (struct program (defns main))
(struct defn (name superclass fields methods))
...))
This obviously works, but it strikes me as overly broad: it grants
access to *everyone*, not just the test cases. Is there a way I can use
inspectors to restrict this a bit but still make my test cases work?
Thanks,
Richard