The user defined class interface provides a natural way to define new XPCE classes. It is both used to create higher level libraries that have the same interface as the built-in XPCE classes as to define entire applications. Many of the library modules and XPCE/Prolog demo programs are implemented as user-defined classes. The PceDraw demo is an elaborate example defined entirely in user-defined classes.
A user defined class lives in XPCE, just as any other XPCE class. There is no difference. Both use dynamic resolution of messages to method objects and then execute the method object. Both use the same object-management and storage facilities.
XPCE/Prolog user-defined classes have their methods implemented in Prolog. This provides a neat and transparent interface between the two systems.8XPCE defines four implementation techniques for methods. C-function pointers are used for almost all the built-in behaviour. C++-function pointers are used when classes are defined in C++ (Wielemaker & Anjewierden, 1994) . Instances of c_pointer are left to the host object for interpretation and finally, code objects are executed.
User defined classes are defined using Prolog syntax, where some operators have special meaning. The definition of an XPCE/Prolog class is enclosed in
:- pce_begin_class(<Class>, <Super> [, <Comment>]). <Class definition> :- pce_end_class.
Multiple classes may be defined in the same Prolog source file, but class definitions may not be nested.