Next: , Previous: , Up: Top   [Contents][Index]


7 Pointers

All C data in CFFI is referenced through pointers. This includes defined C variables that hold immediate values, and integers.

To see why this is, consider the case of the C integer. It is not only an arbitrary representation for an integer, congruent to Lisp’s fixnums; the C integer has a specific bit pattern in memory defined by the C ABI. Lisp has no such constraint on its fixnums; therefore, it only makes sense to think of fixnums as C integers if you assume that CFFI converts them when necessary, such as when storing one for use in a C function call, or as the value of a C variable. This requires defining an area of memory11, represented through an effective address, and storing it there.

Due to this compartmentalization, it only makes sense to manipulate raw C data in Lisp through pointers to it. For example, while there may be a Lisp representation of a struct that is converted to C at store time, you may only manipulate its raw data through a pointer. The C compiler does this also, albeit informally.


Footnotes

(11)

The definition of memory includes the CPU registers.


Next: , Previous: , Up: Top   [Contents][Index]