Defining New Scheme Data Types
List of: Discussion Topic
Subjects: Scheme Interface
Contents: Scheme Support

Application developers can create new application-specific data types, and methods that enable those data types to be used by both Scheme programs and C++ functions.

Methods include the following:

Constructor creates an instance of the type (not required).

Destructor deletes an instance of the type (not required).

init initializes the type. It calls Define_Type to actually define the type to Scheme. It is invoked using the SCM_INIT macro.

Equal compares two instances of the type to determine if they are the same. Call the debug macro, ENTER_FUNCTION(method_name), at the beginning of the function. This method is supplied to Define_Type for the interpreter's use.

Print prints an instance of the type. Call the debug macro, ENTER_FUNCTION(method_name), at the beginning of the function. This method is supplied to Define_Type for the interpreter's use.

Is determines if a Scheme object is of this particular type. Call the debug macro, ENTER_FUNCTION(method_name), at the beginning of the function.

Get creates aC++ object of this type of Scheme object. Call the debug macro, ENTER_FUNCTION(method_name), at the beginning of the function.

Make creates a Scheme object of this type from a C++ object. Call the debug macro, ENTER_FUNCTION(method_name), at the beginning of the function.

The following sections analyze the GC_BndCrv class and its methods as an example of how to derive a new data type. GC is an acronym for garbage collection, which is the process of recovering and reusing memory allocated by the Scheme Interpreter. The interpreter never destroys a Scheme object unless it can prove that the object is not used again. It does, however, recycle memory efficiently to prevent excessive memory allocation.
PDF/SCM/03EXTSC.PDF
HTM/DATA/SCM/SCM/03EXTSC/0009.HTM