Next: , Previous: Structures, Up: Structures Vtables

A vtable is a structure type, specifying its layout, and other information. A vtable is actually itself a structure, but there's no need to worray about that initially (see Vtable Contents.)

— Scheme Procedure: make-vtable fields [print]

Create a new vtable.


The second letter for each field is a permission code,

A tail array is further fields at the end of a structure. The last field in the layout string might be for instance ‘pW’ to have a tail of writable Scheme-valued fields. The ‘pW’ field itself holds the tail size, and the tail fields come after it.

Here are some examples.

          (make-vtable "prpW")    ;; one fixed then a tail array

The optional print argument is a function called by display and write (etc) to give a printed representation of a structure created from this vtable. It's called (print struct port) and should look at struct and write to port. The default print merely gives a form like ‘#<struct ADDR:ADDR>’ with a pair of machine addresses.


          (make-vtable "prpw"
                       (lambda (struct port)
                         (display "#<")
                         (display (struct-ref 0))
                         (display " and ")
                         (display (struct-ref 1))
                         (display ">")))