External modules can create records and access their slots positionally.
| s48_value S48_MAKE_RECORD(s48_value) | (may GC) | 
int       S48_RECORD_P(s48_value) 
s48_value S48_RECORD_TYPE(s48_value) 
s48_value S48_RECORD_REF(s48_value, long) 
void      S48_RECORD_SET(s48_value, long, s48_value) 
S48_MAKE_RECORD should be a shared binding
 whose value is a record type.
In C the fields of Scheme records are only accessible via offsets,
 with the first field having offset zero, the second offset one, and
 so forth.
If the order of the fields is changed in the Scheme definition of the
 record type the C code must be updated as well.
For example, given the following record-type definition
the identifier(define-record-type thing :thing (make-thing a b) thing? (a thing-a) (b thing-b))
:thing is bound to the record type and can
 be exported to C:
(define-exported-binding "thing-record-type" :thing)
Thing records can then be made in C:
static scheme_value
  thing_record_type_binding = SCHFALSE;
void initialize_things(void)
{
  S48_GC_PROTECT_GLOBAL(thing_record_type_binding);
  thing_record_type_binding =
     s48_get_imported_binding("thing-record-type");
}
scheme_value make_thing(scheme_value a, scheme_value b)
{
  s48_value thing;
  s48_DECLARE_GC_PROTECT(2);
  S48_GC_PROTECT_2(a, b);
  thing = s48_make_record(thing_record_type_binding);
  S48_RECORD_SET(thing, 0, a);
  S48_RECORD_SET(thing, 1, b);
  S48_GC_UNPROTECT();
  return thing;
}
a and b must be protected
 against the possibility of a garbage collection occuring during
 the call to s48_make_record().
Previous: Interacting with the Scheme heap | Next: Raising exceptions from external code