A message object is a template for the execution of a send virtual machine operation: messages represent behaviour to be invoked.
Messages are the most commonly used code objects. The code below creates a small dialog window with buttons to quit the window and to start PceDraw (the XPCE drawing demo):
?- new(D, dialog('Start PceDraw')),
send(D, append,
button(start_draw,
message(@prolog, pcedraw))),
send(D, append,
button(quit,
message(D, destroy))),
send(D, open).
It illustrates how a message can be used to activate a host language
function (in this case a Prolog predicate) as well as how a message can
be used to start an internal XPCE operation. The following example shows
how a message may be used to change the graphical->pen
of all graphical
objects on a device
object. It exploits‘chain
message->for_all’.
send(Device?graphicals, for_all,
message(@arg1, pen, 3)).
|any|function*->initialise
and
message<->argument.function-based
modularization. For Prolog, it contains the module from which the object
was created. If the object is executed, this context
argument will be used to resolve the proper function. In Prolog:
?- new(X, foo:message(@prolog, hello)), send(X, execute).
will call the predicate hello in the module foo.
See also’?message<-_context’and rc<-context.
send(<-receiver, <-selector, <-arguments ...)
Any function
object appearing in the message<-receiver, message<-selector
or
message<-arguments
are first evaluated.
|function<-arguments code_vector
object is created or enlarged.|function,
selector=name|function, argument=any|function
...
?- new(D, dialog),
send(D, append,
button(show_display_size,
message(@display, inform,
'The display is %dx%d pixels',
@display?size?width,
@display?size?height))),
send(D, open).
See also class ?.
|function->argument