[plt-scheme] Create new inspector hierarchies?

From: Derick Eddington (derick.eddington at gmail.com)
Date: Sat Apr 7 06:14:40 EDT 2007

I'd like to be able to selectively delegate the authority to inspect
structs.  My problem is the initial root inspector is a supervisor of
all inspectors created and there doesn't seem to be a way to escape
this.  Struct types are either opaque to everyone, including the
defining code, or transparent to everyone with access to the initial
root inspector, and I don't want to be trying to selectively restrict
access to the initial root inspector.  I'd like to be able to create an
inspector which can selectively be given to code to authorize that code
to inspect struct types supervised by that inspector, and if code has
not been given that inspector, it would not be able to inspect those
struct types.  It seems this would require being able to create new
inspector hierarchies, but currently it seems this is not possible?
Could this be added to MzScheme?

I'd like to be able to do something like:

(module M mzscheme
  ; (make-inspector #f) creates a new inspector hierarchy 
  (define inspector (make-inspector #f))
  ; S is supervised by `inspector' only
  (define-struct S (a b) (make-inspector inspector))
    (struct S (a b))

(module trusted mzscheme
  (require M)
  (define (display-S s)
    (parameterize ([current-inspector inspector]
                   [print-struct #t])
      (display s))))

(module encapsulated-M mzscheme
  (require M)
  (provide S S?))

(module untrusted mzscheme
  (require encapsulated-M)
  ; This untrusted code is not able to inspect the `S' type in anyway
  ; because it does not have `inspector' to use.
  ; But it can still sub-type because it was given `S'
  (define-struct (sub-S S) (x y z))

: Derick

Posted on the users mailing list.