Node:Structure Basics, Next:Vtables, Previous:Structure Layout, Up:Structures
This section describes the basic procedures for creating and accessing structures.
|make-struct vtable tail_array_size . init||Scheme Procedure|
|scm_make_struct (vtable, tail_array_size, init)||C Function|
Create a new structure.
type must be a vtable structure (see Vtables).
tail-elts must be a non-negative integer. If the layout specification indicated by type includes a tail-array, this is the number of elements allocated to that array.
The init1, ... are optional arguments describing how successive fields of the structure should be initialized. Only fields with protection 'r' or 'w' can be initialized, except for fields of type 's', which are automatically initialized to point to the new structure itself; fields with protection 'o' can not be initialized by Scheme programs.
If fewer optional arguments than initializable fields are supplied, fields of type 'p' get default value #f while fields of type 'u' are initialized to 0.
Structs are currently the basic representation for record-like data structures in Guile. The plan is to eventually replace them with a new representation which will at the same time be easier to use and more powerful.
For more information, see the documentation for
|struct? x||Scheme Procedure|
|scm_struct_p (x)||C Function|
|struct-ref handle pos||Scheme Procedure|
|struct-set! struct n value||Scheme Procedure|
|scm_struct_ref (handle, pos)||C Function|
|scm_struct_set_x (struct, n, value)||C Function|
Access (or modify) the nth field of struct.
If the field is of type 'p', then it can be set to an arbitrary value.
If the field is of type 'u', then it can only be set to a non-negative integer value small enough to fit in one machine word.