6.1 XPCE is not Prolog!

Data managed by Prolog consists of logical variables, atoms, integers, floats and compound terms (including lists). XPCE has natural counterparts for atoms (a name object), integers (a XPCE int) and floating point numbers (a real object). Prolog logical variables and compound terms however have no direct counterpart in the XPCE environment. XPCE has variables (class var), but these obey totally different scoping and binding rules.

Where Prolog uses a compound term to represent data that belongs together (e.g. person(Name, Age, Address)), XPCE uses objects for this purpose:7This example uses XPCE user-defined classes. The details of this mechanism do not matter for the argument in this section. User-defined classes are described in chapter 7.

:- pce_begin_class(person(name, age, address), object).

variable(name,    name,   both, "Name of the person").
variable(age,     int,    both, "Age in years").
variable(address, string, both, "Full address").

initialise(P, Name:name, Age:int, Address:string) :->
        "Create from name, age and address"::
        send(P, name, Name),
        send(P, age, Age),
        send(P, address, Address).

:- pce_end_class.

1 ?- new(P, person(fred, 30, 'Long Street 45')).
P = @3664437/person

These two representations have very different properties: