Sending and receiving events forms the heart of Glish, and both
are discussed in Chapter 7, page . Here we briefly cover
the syntax of the related statements.
The event-sending statement looks like:
expression -> name ( argThe expression (or expr, arg
,
)
expr
-> [ expr
] ( arg
, arg
,
)
expressionin a manner directly analogous to the syntax of a function call (Chapter 6, pagename = expression
If an event is sent in the context of an expression, then the interpreter waits for a result from the client so that the evaluation of the expression can be completed. The syntax is the same, but the context is different:
my_agent->reset() if ( my_agent->ready() ) print "agent is configured"In the first case, no result is required, but in the second, a result is needed so the interpreter waits (see § 4.11, page
There are two types of statements for receiving events, whenever
and await. Both are discussed in full in § 7.5, page , and
§ 7.6, page
; here we just give an overview of the related syntax.
A whenever statement looks like:
whenever event§ 7.5.1, page, event
,
do statement
await statements have three forms:
await eventThe first form waits for one of the specified event's to be generated (there must be at least one) before proceeding with execution. If other events arrive during the interim they are processed normally. The second form does not process such interim events but instead drops them with a warning. The third form only processes those interim events listed after the except keyword., event
,
![]()
await only event
, event
,
![]()
await only event
, event
,
except event
, event
,
![]()
After each style of await, $agent, $name, and $value correspond to the event that caused the await to finish.
See § 7.6, page , for a full description.
The activate and deactivate statements provide a mechanism for turning whenever statements ``on'' and ``off''.
The statements have the following form:
activatedeactivate
activate expr
deactivate expr
The builtin function whenever_active() can be use to see if
a whenever statement is active or not (See § 9.10, page ).
For more information about, activate and deactivate
see § 7.5.4, page
.
The link and unlink statements provide a mechanism for establishing and suspending point-to-point connections between Glish clients. These connections sacrifice flexibility (being able to inspect and modify event values) for performance.
The statements have the following form:
link eventto event
![]()
unlink event
to event
![]()
See § 7.7, page , for a full description.