GNU Info

Info Node: (guile.info)Structure Concepts

(guile.info)Structure Concepts


Next: Structure Layout Up: Structures
Enter node , (file) or (file)node

Structure Concepts
------------------

A structure object consists of a handle, structure data, and a vtable.
The handle is a Scheme value which points to both the vtable and the
structure's data.  Structure data is a dynamically allocated region of
memory, private to the structure, divided up into typed fields.  A
vtable is another structure used to hold type-specific data.  Multiple
structures can share a common vtable.

Three concepts are key to understanding structures.

   * "layout specifications"

     Layout specifications determine how memory allocated to structures
     is divided up into fields.  Programmers must write a layout
     specification whenever a new type of structure is defined.

   * "structural accessors"

     Structure access is by field number.   There is only one set of
     accessors common to all structure objects.

   * "vtables"

     Vtables, themselves structures, are first class representations of
     disjoint sub-types of structures in general.   In most cases, when
     a new structure is created, programmers must specifiy a vtable for
     the new structure.   Each vtable has a field describing the layout
     of its instances.   Vtables can have additional, user-defined
     fields as well.


automatically generated by info2www version 1.2.2.9