[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: print-struct?



In the current (or maybe next, I forget exactly) CVS release of 
DrScheme, the REPL printer properly handles such values, but you will 
still need to follow Matthew's advice if you want to use things like 
`write' or `display' on your structs.

Robby

At 3:43 PM -0600 9/10/01, Matthew Flatt wrote:
>Quoting Doug Orleans:
>>  Is this a bug, or does print-struct not work like I think it should?
>>  [...]
>>  Shouldn't it print the field values with print-struct turned on?
>
>It's not a bug, but the documentation for `print-struct' doesn't
>provide enough information for v200.
>
>Short answer:
>
>  (define-struct foo (bar baz) (make-inspector))
>
>creates a transparent `foo' structure.
>
>Long answer:
>
>Structs are now used for values in the DrScheme implementation that
>must be protected from malicious code, even to the point of preventing
>inspection via printing.
>
>So MzScheme provides inspectors for controlling access to struct
>fields. When a struct type is created, it becomes protected by the
>current inspector (as determined by the `current-inspector' parameter).
>Printing can expose the content of a struct only if the inspector at
>the time of printing is a supervisor of the inspector that protects the
>struct's type.
>
>The optional last expression for `define-struct' selects a protecting
>inspector; `(make-inspector)' creates a new inspector under the current
>one.
>
>Matthew