src/swipl-devel/packages/xpce/man/refmanual/md/host.md

class host {#class-host}

Class host normally has only one instance representing the programming environment XPCE is connected to. When connected to Prolog, this object is called @prolog and when connected to Lisp it is called @lisp. Other and multiple languages are possible too, but the interfaces have not yet been defined. As the reference manual is geared towards prolog, we will call the instance of class host @prolog.

The object @prolog/@lisp makes the Prolog/Lisp environment available from XPCE code objects.. It allows PCE to pass control to a Prolog predicate by mapping a send operation onto a call to a Prolog predicate with the same name as the selector of the message.

Thus,

?- send(@prolog, format, 'Hello World~n').

Invokes format(Hello World~n')' and thus prints Hello World.

Similar, the get operation asks Prolog to compute a value. Suppose the predicate plus(+A, +B, -C) exists that adds two numbers. Then

?- get(@prolog, plus, 1, 2, X).

responds with 3 as expected. Sending messages to @prolog is the common way to link UI objects, existing in PCE to the application, running in Prolog:

new(B, button(help, message(@prolog, give_help)))

will invoke the Prolog predicate give_help/0 if the user presses the Help button.

The communication between PCE and the host language may be synchronous or asynchronous. See ->call_back and <-messages.

@see class pce

Instance variables {#class-host-instvars}

Send methods {#class-host-send}

Get methods {#class-host-get}



Try the rswipl package in your browser

Any scripts or data that you put into this service are public.

rswipl documentation built on June 16, 2026, 5:07 p.m.