[plt-scheme] printing class.ss objects

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Mar 20 11:59:47 EST 2003

At Tue, 18 Mar 2003 00:38:14 -0500, "Neil W. Van Dyke" wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> Is there an easy way to make the print representation of a class.ss
> object instance display its fields?

Not currently.

> But I'd sometimes really prefer one of the following:
>    #<struct:object:server-authority% "john" "smith.foo" 8080>
>    #<struct:object:server-authority% user="john" host="smith.foo"
>    portnum=8080>

Configuring the printer remains on my high-priority to-do list.

> A separate procedure like print-object-dump would also work, as would a
> DrScheme feature similar to the Smalltalk Inspector (a snip or a browser).
> Perhaps related question: is there a way to specify the structure
> inspector (a la make-inspector) for a class.ss object?

I'm adding `object->vector, `object-info', and `class-info' to
"class.ss". These are analogous to struct and struct type operations,
and they're similarly sensitive to the `current-inspector' parameter:

 > (define c% (class (parameterize ([current-inspector (make-inspector)])
                       (class object%
                         (define foo 'see-me!)
                         (super-instantiate ())))
                (define bar 'dont-see-me!)
                (super-instantiate ())))
 > (object->vector (make-object c%))
 #4(object:c% ... see-me! ...)

Note that `object%' is generally not inspectable, which means that the
result of `object->vector' will have "..." in the second slot.


Posted on the users mailing list.