next up previous contents
Next: 11 Internal representation of Up: QScheme Documentation Previous: 9 Running QScheme   Contents

Subsections

10 Data types *REVIEW*

10.1 Built-in data types

The table 6

Table 6: Builtin Scheme object type
Type Description Example
SOBJ_T_VOID when returned by eval no print occurs  
SOBJ_T_PAIR result of a cons (cons 1 2) => (1 . 2)
SOBJ_T_INUM small integer number. 31 bits 123
SOBJ_T_FNUM double 1.2
SOBJ_T_BNUM big integer number 108230980172834891
SOBJ_T_ATOM an atom 'a
SOBJ_T_KEYWORD starts with ':' and evaluates to itself :keyword
SOBJ_T_SYMBOL a symbol symbol
SOBJ_T_LSYMBOL local symbol x
SOBJ_T_LABEL label for named let  
SOBJ_T_MODULE module description  
SOBJ_T_CHAR a character #\space
SOBJ_T_STRING a string ``Hello world''
SOBJ_T_PRIM internal VM primitive %push
SOBJ_T_CPRIM primitive coded in C display
SOBJ_T_SYNTAX syntax object define
SOBJ_T_CODE code without parameter  
SOBJ_T_PROC procedure: has parameter(s)  
SOBJ_T_ENV environment  
SOBJ_T_CLOSURE closure  
SOBJ_T_MACRO macro  
SOBJ_T_PORT port  
SOBJ_T_BOOLEAN #t or #f  
SOBJ_T_UNBOUND value of an unbound symbol  
SOBJ_T_UNDEFINED value of an undefined value  
SOBJ_T_EOF the EOF value  
SOBJ_T_CONT continuation  
SOBJ_T_ARRAY array  
SOBJ_T_HASH hash  
SOBJ_T_POINTER generic pointer  
SOBJ_T_EXTFUNC external function, dynamically loaded  
SOBJ_T_EXTVAR reference to an external variable  
SOBJ_T_VAR reference to an external variable  
SOBJ_T_VMFUNC VM extension functions  
SOBJ_T_CCNTXT catch context  
SOBJ_T_USER user-defined types  




describes the currently defined Scheme object types.

10.2 Adding new Scheme object types from C

The built-in data types can be extended by user defined data types. New user types can be registered using the following structures and API.

SOBJ_TYPE_DESCR

This is the structure describing a type. See the definitions in file s.h

SOBJ_TYPE_DESCR scm_type_hook[SOBJ_T_MAX]

This is the global type structure. You don't have to manipulate directly this table.

int scm_add_type(SOBJ_TYPE_DESCR *type)

This function adds a new type to the scm_type_hook[] array. The integer returned is the type descriptor.

To add a new Scheme object type, you have to go through the following steps:

A real and non-trivial working example of how to build a new Scheme object type can be found in the regex.c file.

Note:
The dyntype.c file can be use as prototype to build a new type from the C language. Just copy it and rename the ``xxx'' string with the name of your new type.


next up previous contents
Next: 11 Internal representation of Up: QScheme Documentation Previous: 9 Running QScheme   Contents
Daniel Crettol 2000-06-12