4.3 Unification
- int PlTerm::operator =(Type)
- The operator
=
is defined for the Types PlTerm,long
,double
,char *
,wchar_t*
and PlAtom. It performs Prolog unification and returnsTRUE
if successful andFALSE
otherwise.The boolean return-value leads to somewhat unconventional-looking code as normally, assignment returns the value assigned in C. Unification however is fundamentally different to assignment as it can succeed or fail. Here is a common example.
PREDICATE(hostname, 1) { char buf[32]; if ( gethostname(buf, sizeof(buf)) == 0 ) return A1 = buf; return FALSE; }