3.8 C Array Types
The primitive type constructor for creating new C array types. Like C
struct types, array types are new primitive types with no conversion
functions associated. When used as a function argument or return type,
array types behave like pointer types; otherwise, array types behave
like struct types (i.e., a struct with as many fields as the array has
elements), particularly when used for a field within a struct type.
Since an array is treated like a struct, casting a
pointer type to an array type does not work. Instead, use
ptr-ref with a pointer, an array type constructed with
_array, and index 0 to convert a pointer to a Racket
representation that works with array-ref and
Creates an array type whose Racket representation is an array that
works with array-ref
. The array is
not copied; the Racket representation is backed by the underlying C
Supply multiple counts for a multidimensional array. Since C
uses row-major order for arrays, (_array t n m) is
equivalent to (_array (_array t m) n), which is different
from an array of pointers to arrays.
is a Racket representation of a C
value via _array
Extracts an element from an array. Use multiple i indices for
a multidimensional array access; using fewer indices than the array
dimension produces a sub-array.
Sets an element in an array. Use multiple i indices for a
multidimensional array update; using fewer indices than the array
dimension sets a sub-array (i.e., v must be an array of the
same size as the sub-array and v is copied into the
Extracts the pointer for an array’s storage.
, but the Racket representation is a list (or list
of lists for a multidimensional array) of elements copied to and from
an underlying C array.
, but the Racket representation is a vector (or
vector of vectors for a multidimensional array) of elements copied to
and from an underlying C array.