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


4.7 Other Actions

remember(Belief)

Adds its ground relcall argument (Belief) as a new last dynamic fact for its functor relation name R. R must have been declared as a belief.
remember : (relcall) ~>>

remember_for(Belief, Secs)

The same as remember except that Belief is forgotten after Secs seconds.
remember_for : (relcall, num) ~>>

Alternative syntax: remember Belief for Secs

rememberA(Belief)

Adds its ground relcall argument (Belief) as a new first dynamic fact for its functor relation name R. R must have been declared as a belief.
rememberA : (relcall) ~>>

rememberA_for(Belief, Secs)

The same as rememberA except that Belief is forgotten after Secs seconds.
remember_for : (relcall, num) ~>>

Alternative syntax: rememberA Belief for Secs

forget(Belief)

Remove the first dynamic fact matching Belief. Note that Belief may contain variables within the arguments. forget always succeeds even if there are no matching facts.
forget : (relcall) ~>>

forget_after(Belief, Secs)

The same as forget except that Belief is forgotten when Secs seconds has elapsed and Belief must be ground at the time of call.
forget_after : (relcall, num) ~>>

Alternative syntax: forget Belief after Secs

replace_by(Belief1, Belief2)

The same as forget(Belief1) ; remember(Belief2). Belief1 and Belief2 may share variables.

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 belief declarations and a definition using one fact of a unary relation called Name. They are respectively expanded into:

belief Name: int <=
Name(Integer) 

belief 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.

:= : (!(?int <= ), !int) ~>> | (!(?num <= ), !num) ~>>

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)).

+:= : (!(?int <= ), !int) ~>> | (!(?num <= ), !num) ~>>

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)).

-:= : (!(?int <= ), !int) ~>> | (!(?num <= ), !num) ~>>

Example use

savings -:= 67.90

for decreasing the value held in savings by 67.90.

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.
fork_as : (actcall, ?atom) ~>>

Alternative syntax: fork Action as Name

from(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 message 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.
from : (term?, ?handle) ~>>

Alternative syntax: Term from Handle

to(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 message address is Handle.
to : (??term, !handle) ~>>

Alternative syntax: Term to Handle

thread_sleep(Secs)

Causes the executing thread to suspend for Secs seconds.
thread_sleep : (!num) ~>>


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