Object Representation



next up previous
Next: Primitive Functions Up: libscheme Architecture Previous: libscheme Architecture

Object Representation

 

Every object in libscheme is an instance of the C structure Scheme_Object. Each instance of Scheme_Object contains a pointer to a type object (that also happens to be a Scheme_Object) and two data words. If an object requires more than two words of storage or if the object is some other type of foreign C structure, it is stored in a separate memory location and pointed to by the ptr_val field. The actual definition of Scheme_Object appears in figure 6.

  
Figure: The definition of Scheme_Object

While many Scheme implementations choose to represent certain special objects as immediate values (e.g., small integers, characters, the empty list, etc.) this approach was not used in libscheme because the ``everything is an object with a tag approach'' is simpler and easier to debug. A side effect of this decision is that libscheme code that does heavy small integer arithmetic will allocate garbage that must be collected, in contrast to higher performance Scheme implementations that only dynamically allocate very large integers.



Brent Benson
Mon Sep 19 16:03:14 EDT 1994