Up Next

B.1  Constructing ECLiPSe terms in C++

B.1.1  Class EC_atom and EC_functor

The ECLiPSe dictionary provides unique identifiers for name/arity pairs. EC_atoms are dictionary identifiers with zero arity, EC_functors are dictionary identifiers with non-zero arity.

EC_atom(char*)

looks up or enters the given string into the ECLiPSe dictionary and returns a unique atom identifier for it.
char* EC_atom::name()

returns the name string of the given atom identifier.
EC_functor(char*,int)

looks up or enters the given string with arity into the ECLiPSe dictionary and returns a unique functor identifier for it.
char* EC_functor::name()

returns the name string of the given functor identifier.
int EC_functor::arity()

returns the arity of the given functor identifier.

B.1.2  Class EC_word

The EC_word is the basic type that all ECLiPSe data structures are built from (because within ECLiPSe typing is dynamic). The following are the functions for constructing ECLiPSe terms from the fundamental C++ types. CAUTION: constructed EC_words are only valid up to the next invocation of EC_resume(); afterwards they must be considered invalid. Using an invalid EC_word as an argument to any function of this interface may lead to a crash. The only thing that can be done with an invalid EC_word is to assign a freshly constructed value to it. To preserve a value across invocations of EC_resume(), use EC_ref or EC_refs.

EC_word(const char *)

converts a C++ string to an ECLiPSe string. The string is copied.
EC_word(const int, const char *)

converts a C++ string of given length to an ECLiPSe string. The string is copied and can contain NUL bytes.
EC_word(const EC_atom)

creates an ECLiPSe atom from an atom identifier.
EC_word(const long)

converts a C++ long to an ECLiPSe integer.
EC_word(const long long)

converts a C++ long long to an ECLiPSe integer.
EC_word(const double)

converts a C++ double to an ECLiPSe double float.
EC_word(const EC_ref&)

retrieves the ECLiPSe term referenced by the EC_ref (see below).
EC_word term(const EC_functor,const EC_word args[ ])

EC_word term(const EC_functor,const EC_word arg1, ...)

creates an ECLiPSe compound term from the given components.
EC_word list(const EC_word hd, const EC_word tl)

Construct a single ECLiPSe list cell.
EC_word list(int n, const long*)

Construct an ECLiPSe list of length n from an array of long integers.
EC_word list(int n, const char*)

Construct an ECLiPSe list of length n from an array of chars.
EC_word list(int n, const double*)

Construct an ECLiPSe list of length n from an array of doubles.
EC_word array(int, const double*)

creates an ECLiPSe array (a structure with functor [ ]of appropriate arity) of doubles from the given C++ array. The data is copied.
EC_word matrix(int rows, int cols, const double*)

creates an ECLiPSe array (size rows) of arrays (size cols) of doubles from the given C++ array. The data is copied.
EC_word handle(const t_ext_type *cl, const t_ext_ptr data)

Construct an ECLiPSe handle for external data, attaching the given method table.
EC_word newvar()

Construct a fresh ECLiPSe variable.
EC_word nil()

Construct the empty list [ ].

Up Next