QP_new_term_ref()

Synopsis

     #include <quintus/quintus.h>
     
     QP_term_ref QP_new_term_ref()
     

Description

QP_new_term_ref() returns an initialized QP_term_ref. Every QP_term_ref declared has to be initialized with a call to this function. A QP_term_ref can be considered as a reference to a Prolog term. Calling this function initialises that reference to a location where terms can be stored. The actual term that the reference points to is initialized to [].

Example

create_term() is a simple C function that returns different types of Prolog terms depending on its first argument.

                                     
foo.pl
foreign(create_term, create_term(+integer,[-term])).
                                      
foo.c
#include <quintus/quintus.h> QP_term_ref create_term(kind); long int kind; { QP_term_ref new = QP_new_term_ref(); switch (kind) { case 1: QP_put_integer(new, 23); break; case 2: QP_put_atom(new, QP_atom_from_string("Ayn")); break; case 3: QP_put_float(new, 1.1); break; default: QP_put_nil(new); break; } return new; }

See Also:

QP_put_*(), QP_term_type(), QP_get_*()