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 ( arg, arg, )The expression (or expr) must resolve to one agent; see § 7.5.1, page , for more information. Each arg argument (there needn't be any, in which case an event with the value F is sent) has one of two forms:expr -> [ expr ] ( arg, arg, )
expressionin a manner directly analogous to the syntax of a function call (Chapter 6, page ). If only one argument and the first form is used specified then Glish evaluates expression and uses the result as the event value. If more than one argument is specified or the second form used for a lone argument then Glish constructs a record in a manner similar to that described in § 3.4.1, page , and uses that as the event value. Again, see Chapter 7, page , for a full discussion.name = 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, event, do statement§ 7.5.1, page , describes the event syntax. At least one event must be specified. The meaning of the statement is that whenever any of the given events is generated, execute statement with $agent, $name, and $value equal to the agent that generated the event, the name of the event, and the event's value.
await statements have three forms:
await event, event,The 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.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 event to eventunlink event to event
See § 7.7, page , for a full description.