Passing data between Factor and C
Factor handbook > C library interface

Prev:Calling Factor from C
Next:Struct classes


Two defining characteristics of Factor are dynamic typing and automatic memory management, which are somewhat incompatible with the machine-level data model exposed by C. Factor's C library interface defines its own set of C data types, distinct from Factor language types, together with automatic conversion between Factor values and C types. For example, C integer types must be declared and are fixed-width, whereas Factor supports arbitrary-precision integers.

Furthermore, Factor's garbage collector can move objects in memory; for a discussion of the consequences, see Byte arrays and the garbage collector.
C type specifiers
Passing pointers to C functions
Manual memory management
C strings
Output parameters in C
C value boxes

Important guidelines for passing data in byte arrays:
Byte arrays and the garbage collector

C-style enumerated types are supported:
Enumeration types

A utility for defining Deterministic resource disposal for deallocating memory:
Alien destructors

C struct and union types can be defined with STRUCT: and UNION-STRUCT:. See Struct classes for details. For passing arrays to and from C, use the Specialized arrays vocabulary.