Managing Data and Memory in Mixed-Language Applications

# Chapter 3 Managing Data and Memory in Mixed-Language Applications

ECLiPSe is a software engine for constraint propagation and search tasks. As such, it represents its data in a form that is different from how it would be represented in a traditional C/C++ program. In particular, the ECLiPSe data representation supports automatic memory management and garbage collection, modifications that can be undone in a search context, referential transparency and dynamic typing.

In a mixed-language application, there are two basic ways of communicating information between the components coded in the different languages:

Conversion:
  When data is needed for processing in another language, it can be converted to the corresponding representation. This technique is appropriate for simple data types (integers, strings), but can have a lot of overhead for complex structures.
Sharing:
  The bulk of the data is left in its original representation, referred to by a handle, and interface functions (or methods) provide access to its components when required.

Both techniques are supported by the ECLiPSe/C and ECLiPSe/C++ interface.

- Constructing ECLiPSe data
  - ECLiPSe atoms and functors
  - Building ECLiPSe terms
  - Building atomic ECLiPSe terms
  - Building ECLiPSe lists
  - Building ECLiPSe structures
- Converting ECLiPSe data to C data
  - Converting simple ECLiPSe terms to C data types
  - Decomposing ECLiPSe terms
- Referring to ECLiPSe terms
- Passing generic C or C++ data to ECLiPSe
  - Wrapping and unwrapping external data in an ECLiPSe term
  - The method table