Next: TeleoR Specific Actions, Previous: Other Relations, Up: Built-Ins [Contents][Index]
fork(Action, Name, Sizes, Root)
Fork a new QuLog thread, give it the name
Name, and start the thread executingAction. IfNameis given it must not be the name of an existing thread. IfNameis a variable it will be instantiated to a name given by the system. The generated name usesRootas the root name of the thread. The name is extended with a number to give the first available name. The sizes of the various memory areas determined by the content of theSizeslist. IfSizesis not given it defaults to[]. IfRootis not given it defaults tothread.Example: the following sets sizes for the environment stack and the heap.
fork(Act, Name, [env_size(1), heap_size(5)])
fork_light(Action, Name, Root)
Fork a new QuLog thread with the sizes of the various memory areas set to be very small. This produces a very light weight thread and is useful for threads that do minimal computation - for example a simple message handling thread.
NameandRootare the same as for fork.
from(Term, Handle)
This is the agent message receive action. It will succeed it there is a message term in that threads message buffer whose message term unifies with
Termand whose agent handle unifies withHandle. If not the call will suspend and be repeatedly retried as new messages arrive until it succeeds. When it does succeed, the matched message will be removed from the message buffer.
act from(??term, ?agent_handle)Alternative syntax:
Term from Handle
to(Term, Handle)
This is the agent message send action. It sends
Termas a message to the agent (of possibly a process on another machine) whose agent address isHandle.
act to(@term, !agent_handle)Alternative syntax:
Term to Handle
from_thread(Term, Handle)
This is the message receive action. It will succeed it there is a message term in that threads message buffer whose message term unifies with
Termand whose handle unifies withHandle. If not the call will suspend and be repeatedly retried as new messages arrive until it succeeds. When it does succeed, the matched message will be removed from the message buffer.
act from_thread(??term, ?handle)Alternative syntax:
Term from_thread Handle
to_thread(Term, Handle)
This is the message send action. It sends
Termas a message to the thread (of possibly another process on another machine) whose address isHandle.
act to_thread(@term, !agent_handle)Alternative syntax:
Term to_thread Handle
thread_sleep(Secs)
Causes the executing thread to suspend for
Secsseconds.
act thread_sleep(!num)
Dynamic facts (that make up the belief store) can be remembered and forgotten using the actions below. Each such action atomically modifies the collection of dynamic facts. If the belief store changes then the belief store timestamp is updated and the timestamp can be accessed using the time_ relation.
forget(DynPatterns)
Remove the first dynamic fact matching each entry of the list
DynPatterns. Note thatDynPatternsmay contain variables within the arguments of each entry.forgetalways succeeds even if there are no matching facts.
remember(DynTerms)
Adds each new
dyn_termin the list (DynTerms) as a new last dynamic fact. If the fact is already present then there is no change.
forget_remember(DynPatterns, DynTerms)
This is the combination of the above two actions. The forgets are done first followed by the remembers. If a fact that is to be forgotten is to be immediately remembered then no change occurs.
remember_for(DynTerms, Secs)
The same as
rememberexcept thatDynTermsare forgotten afterSecsseconds.
Name := Expression
Here
Nameis an atom that must have been initialised with a statement
int Name:=Integer, e.g.int count:=0or
num Name:=Number, e.g.num savings:=678.50in the program. These statements are shorthand for
dyndeclarations and a definition using one fact of a unary relation calledName. They are respectively expanded into:dyn Name(int) Name(Integer) dyn Name(num) Name(Number)The action
Name := Expressionis the same asforget_remember([Name(_)], [Name(Expression)]).
Namecan be used as though it were a global variable. To access its value the operator$is applied. The expression$Nameevaluates to the currentintornumvalue stored inName, i.e. in the currentNamebelief.
act :=(!rel(?num), !num), :=(!rel(?int), !int)
Name +:= Expression
As above,
Nameis an atom that must have been initialised with a statement
int Name:=Integerornum Name:=Numberin the program.
The action
Name +:= Expressionis the same as
forget_remember([Name(Val)], [Name(Val+Expression)]).
act +:=(!rel(?num), !num), +:=(!rel(?int), !int)Example use
count +:= 1for increasing value held in
countby 1.
Name -:= Expression
As above,
Nameis an atom that must have been initialised with a statement
int Name:=Integerornum Name:=Numberin the program.
The action
Name -:= Expressionis the same as
forget_remember([Name(Val)], [Name(Val-Expression)]).
act -:=(!rel(?num), !num), -:=(!rel(?int), !int)Example use
savings -:= 67.90for decreasing the value held in
savingsby67.90.
Next: TeleoR Specific Actions, Previous: Other Relations, Up: Built-Ins [Contents][Index]