Next: , Previous: , Up: Built-Ins   [Contents][Index]


4.7 Other Actions

fork_as(Action, Name)

Fork a new Qulog thread, give it the name Name, and start the thread executing Action. If Name is a variable it will be instantiated to a name given by the system. If Name is given it must not be the name of an existing thread.
act fork_as(actcall, ?atom)

Alternative syntax: fork Action as Name

fork_light_as(Action, Name)

Fork a new Qulog thread, give it the name Name, and start the thread executing Action. If Name is a variable it will be instantiated to a name given by the system. If Name is given it must not be the name of an existing thread. The sizes of the various memory areas is 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.
act fork_light_as(actcall, ?atom)

Alternative syntax: fork_light Action as Name

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 with Handle. 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 is Handle.
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 with Handle. 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 is Handle.
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 can be remembered and forgotten using the actions below. Each such action atomically modifies the collection of dynamic facts.

forget_remember(Forget, Remember)

Forget the dynamic facts that match the patterns in Forget and then remember the dynamic facts in Remember

Alternative syntax: forget F remember R

remember(Dyn)

Adds each dynfact in (Dyn) as a new last dynamic fact for its functor relation name R. R must have been declared as dynamic.
act remember(dynfact)

remember_for(Dyn, Secs)

The same as remember except that Dyn is forgotten after Secs seconds.
act remember_for(dynfact, num)

Alternative syntax: remember Dyn for Secs

rememberA(Dyn)

Adds its ground relcall argument (Dyn) as a new first dynamic fact for its functor relation name R. R must have been declared as a belief.
act rememberA(dynfact)

rememberA_for(Dyn, Secs)

The same as rememberA except that Dyn is forgotten after Secs seconds.
act remember_for(dynfact, num)

Alternative syntax: rememberA Dyn for Secs

forget(DynPtn)

Remove the first dynamic fact matching each entry of DynPtn. Note that Dynptn may contain variables within the arguments of each entry. forget always succeeds even if there are no matching facts.
act forget(dyncall)

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 called Name. They are respectively expanded into:

dyn Name(int)
Name(Integer) 

dyn Name(num) 
Name(Number) 

The action Name := Expression is the same as

forget Name(_) remember 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 current int or num value stored in Name, i.e. in the current Name 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 or num Name:=Number

in the program.

The action Name +:= Expression is the same as

forget Name(Val) remember 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 or num Name:=Number

in the program.

The action Name -:= Expression is the same as

forget Name(Val) remember Name(Val-Expression).

act -:=(!rel(?num), !num), -:=(!rel(?int), !int)

Example use

savings -:= 67.90

for decreasing the value held in savings by 67.90.


Next: , Previous: , Up: Built-Ins   [Contents][Index]