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
. IfName
is given it must not be the name of an existing thread. IfName
is a variable it will be instantiated to a name given by the system. The generated name usesRoot
as 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 theSizes
list. IfSizes
is not given it defaults to[]
. IfRoot
is 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.
Name
andRoot
are 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
Term
and 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
Term
as 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
Term
and 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
Term
as 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
Secs
seconds.
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 thatDynPatterns
may contain variables within the arguments of each entry.forget
always succeeds even if there are no matching facts.
remember(DynTerms)
Adds each new
dyn_term
in 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
remember
except thatDynTerms
are forgotten afterSecs
seconds.
Name := Expression
Here
Name
is an atom that must have been initialised with a statement
int Name:=Integer
, e.g.int count:=0
or
num Name:=Number
, e.g.num savings:=678.50
in the program. These statements are shorthand for
dyn
declarations 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 := Expression
is the same asforget_remember([Name(_)], [Name(Expression)]).
Name
can be used as though it were a global variable. To access its value the operator$
is applied. The expression$Name
evaluates to the currentint
ornum
value stored inName
, i.e. in the currentName
belief.
act :=(!rel(?num), !num), :=(!rel(?int), !int)
Name +:= Expression
As above,
Name
is an atom that must have been initialised with a statement
int Name:=Integer
ornum Name:=Number
in the program.
The action
Name +:= Expression
is the same as
forget_remember([Name(Val)], [Name(Val+Expression)])
.
act +:=(!rel(?num), !num), +:=(!rel(?int), !int)
Example use
count +:= 1
for increasing value held in
count
by 1.
Name -:= Expression
As above,
Name
is an atom that must have been initialised with a statement
int Name:=Integer
ornum Name:=Number
in the program.
The action
Name -:= Expression
is the same as
forget_remember([Name(Val)], [Name(Val-Expression)])
.
act -:=(!rel(?num), !num), -:=(!rel(?int), !int)
Example use
savings -:= 67.90
for decreasing the value held in
savings
by67.90
.
Next: TeleoR Specific Actions, Previous: Other Relations, Up: Built-Ins [Contents][Index]