Next: Relation Definitions, Previous: Complex Conjunctions, Up: Programs [Contents][Index]
An Action Sequence can be entered as an interpreter command. It has the form
{}
(the empty action sequence)
or
Act1 ; Act2 ; ... ; Actn, n>1
with each Acti one of:
?(
Cond)
- find at most one solution to the relation query Cond and raises an exception if no solution exists.forall
):
forall UVars {exists EVars1 SimpleConj ~> exists EVars2 SimpleActSeq}
The constraints on variables is the same as for the relational forall
.
This provides a form of action iteration. For example, if Agents
is a given list of agent handles and Message
is a message then
forall A {A in Agents ~> Message to A}
will sent the message to each agent in the list.
try { Acts } except { ExceptionPattern1 :: Cond1 ~> Act1 ... ExceptionPatternn :: Condn ~> Actk }
Acts
is executed and if no exceptions are raised execution continues after the try_except. If an exception is raised then the action corresponding to the first matching exception pattern for which the corresponding condition is true is excuted and execution continues after the try_except. If no exception patterns match then the exception will be handled by some enclosing try-except. Conditions can be elided if not required.
case { Test1 ~> Acts1 ... Testk ~> Actsk }
This executes the first Actsi
for which the corresponding guard Testi
is true. If no guards are true an action_failure
exception is raised.
wait(Query)
case
except that it blocks until one of the guards is true or until an optional timeout is reached.
wait_case { Test1 ~> Act1 ... Testk ~> Actk timeout T ~> DefaultAct }
repeat
Actuntil
Condition
Repeatedly execute Act
until Condition
is true. The condition is optional and if it’s not given it’s the same as repeat Act until false
(like a repeat-fail loop in Prolog). This could be used to implement an interpreter or a linda tuple space server. An alternative is to write the code recursively but the repeat-until approach typically does not require garbage collection.
to
AgentHandlefrom
AgentHandlePtnto_thread
ThreadHandlefrom_thread
ThreadHandle respond_remote_query(
ID,
QueryString,
ClientThread)
.
receive { MessPtn1 from HandlePtn1 :: Test1 ~> Act1 ... ... MessPtnk from HandlePtnk :: Test1k ~> Actk timeout T ~> DefaultAct }
where k>=1 and each Acti
and DefaultAct
is a Simple Action Sequence and each Test1i
is a simple conjunction. The timeout
rule is optional.
Examples of use and semantics are given in the semantics section.
Next: Relation Definitions, Previous: Complex Conjunctions, Up: Programs [Contents][Index]