A Prolog term returned as a value of a Foreign Function
     Prolog:  [-term]
     C:       QP_term_ref f(...);
                     QP_term_ref ref = QP_new_term_ref();
                     return ref;

No argument is passed to the foreign function. The return value from the function is assumed to be a reference to a Prolog term of type QP_term_ref. The term that the QP_term_ref refers to is unified with the corresponding argument of the Prolog call. The argument can be of any type; if it cannot be unified with the referred term, the call will fail.