A vtable is itself a structure, with particular fields that hold information about the structures to be created. These include the fields of those structures, and the print function for them. The variables below allow access to those fields.
#tif obj is a vtable structure.
Note that because vtables are simply structures with a particular layout,
struct-vtable?can potentially return true on an application structure which merely happens to look like a vtable.
The field number of the layout specification in a vtable. The layout specification is a symbol like
pwpwformed from the fields string passed to
make-vtable, or created by
make-struct-layout(see Vtable Vtables).(define v (make-vtable "pwpw" 0)) (struct-ref v vtable-index-layout) ⇒ pwpw
This field is read-only, since the layout of structures using a vtable cannot be changed.
A self-reference to the vtable, ie. a type
sfield. This is used by C code within Guile and has no use at the Scheme level.
The field number of the printer function. This field contains
#fif the default print function should be used.(define (my-print-func struct port) ...) (define v (make-vtable "pwpw" my-print-func)) (struct-ref v vtable-index-printer) ⇒ my-print-func
This field is writable, allowing the print function to be changed dynamically.
Get or set the name of vtable. name is a symbol and is used in the default print function when printing structures created from vtable.(define v (make-vtable "pw")) (set-struct-vtable-name! v 'my-name) (define s (make-struct v 0)) (display s) -| #<my-name b7ab3ae0:b7ab3730>