DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(guile.info.gz) Records

Info Catalog (guile.info.gz) Vectors (guile.info.gz) Compound Data Types (guile.info.gz) Structures
 
 22.4 Records
 ============
 
 A "record type" is a first class object representing a user-defined
 data type.  A "record" is an instance of a record type.
 
  -- Scheme Procedure: record? obj
      Return `#t' if OBJ is a record of any type and `#f' otherwise.
 
      Note that `record?' may be true of any Scheme value; there is no
      promise that records are disjoint with other Scheme types.
 
  -- Scheme Procedure: make-record-type type-name field-names
      Return a "record-type descriptor", a value representing a new data
      type disjoint from all others.  The TYPE-NAME argument must be a
      string, but is only used for debugging purposes (such as the
      printed representation of a record of the new type).  The
      FIELD-NAMES argument is a list of symbols naming the "fields" of a
      record of the new type.  It is an error if the list contains any
      duplicates.  It is unspecified how record-type descriptors are
      represented.
 
  -- Scheme Procedure: record-constructor rtd [field-names]
      Return a procedure for constructing new members of the type
      represented by RTD.  The returned procedure accepts exactly as
      many arguments as there are symbols in the given list,
      FIELD-NAMES; these are used, in order, as the initial values of
      those fields in a new record, which is returned by the constructor
      procedure.  The values of any fields not named in that list are
      unspecified.  The FIELD-NAMES argument defaults to the list of
      field names in the call to `make-record-type' that created the
      type represented by RTD; if the FIELD-NAMES argument is provided,
      it is an error if it contains any duplicates or any symbols not in
      the default list.
 
  -- Scheme Procedure: record-predicate rtd
      Return a procedure for testing membership in the type represented
      by RTD.  The returned procedure accepts exactly one argument and
      returns a true value if the argument is a member of the indicated
      record type; it returns a false value otherwise.
 
  -- Scheme Procedure: record-accessor rtd field-name
      Return a procedure for reading the value of a particular field of a
      member of the type represented by RTD.  The returned procedure
      accepts exactly one argument which must be a record of the
      appropriate type; it returns the current value of the field named
      by the symbol FIELD-NAME in that record.  The symbol FIELD-NAME
      must be a member of the list of field-names in the call to
      `make-record-type' that created the type represented by RTD.
 
  -- Scheme Procedure: record-modifier rtd field-name
      Return a procedure for writing the value of a particular field of a
      member of the type represented by RTD.  The returned procedure
      accepts exactly two arguments: first, a record of the appropriate
      type, and second, an arbitrary Scheme value; it modifies the field
      named by the symbol FIELD-NAME in that record to contain the given
      value.  The returned value of the modifier procedure is
      unspecified.  The symbol FIELD-NAME must be a member of the list
      of field-names in the call to `make-record-type' that created the
      type represented by RTD.
 
  -- Scheme Procedure: record-type-descriptor record
      Return a record-type descriptor representing the type of the given
      record.  That is, for example, if the returned descriptor were
      passed to `record-predicate', the resulting predicate would return
      a true value when passed the given record.  Note that it is not
      necessarily the case that the returned descriptor is the one that
      was passed to `record-constructor' in the call that created the
      constructor procedure that created the given record.
 
  -- Scheme Procedure: record-type-name rtd
      Return the type-name associated with the type represented by rtd.
      The returned value is `eqv?' to the TYPE-NAME argument given in
      the call to `make-record-type' that created the type represented by
      RTD.
 
  -- Scheme Procedure: record-type-fields rtd
      Return a list of the symbols naming the fields in members of the
      type represented by RTD.  The returned value is `equal?' to the
      field-names argument given in the call to `make-record-type' that
      created the type represented by RTD.
 
Info Catalog (guile.info.gz) Vectors (guile.info.gz) Compound Data Types (guile.info.gz) Structures
automatically generated byinfo2html