next up previous contents
Next: 6.5 System Area Pointers Up: 6 UNIX Interface Previous: 6.3 Lisp Equivalents for

6.4 Type Translations

     

Lisp data types have very different representations from those used by conventional languages such as C. Since the system interfaces are designed for conventional languages, Lisp must translate objects to and from the Lisp representations. Many simple objects have a direct translation: integers, characters, strings and floating point numbers are translated to the corresponding Lisp object. A number of types, however, are implemented differently in Lisp for reasons of clarity and efficiency.

Instances of enumerated types are expressed as keywords in Lisp. Records, arrays, and pointer types are implemented with the Alien facility (see page gif.) Access functions are defined for these types which convert fields of records, elements of arrays, or data referenced by pointers into Lisp objects (possibly another object to be referenced with another access function).

One should dispose of Alien objects created by constructor functions or returned from remote procedure calls when they are no longer of any use, freeing the virtual memory associated with that object. Since Aliens contain pointers to non-Lisp data, the garbage collector cannot do this itself. If the memory was obtained from  make-alien (page gif) or from a foreign function call to a routine that used malloc, then  free-alien (page gif) should be used. If the Alien was created using MACH memory allocation (e.g. vm_allocate), then the storage should be freed using vm_deallocate.



Raymond Toy
Mon Jul 14 09:11:27 EDT 1997