8.3 Spaces

First-class computation spaces can be used to program inference engines for problem solving.

IsSpace

{IsSpace +X ?B}

tests whether X is a space.

new

{Space.new +P ?Space}

returns a newly created space, in which a thread containing an application of the unary procedure P to the root variable of Space is created.

ask

{Space.ask +Space ?T}

waits until Space becomes stable or merged and then returns the status of Space.

If Space is merged, the atom merged is returned.

If Space is stable and:

failed

the atom failed is returned.

succeeded

and there are no threads in Space synchronizing on choices, the atom succeeded is returned.

succeeded

and there is at least one thread in Space which synchronizes on a choice the tuple alternatives(I) is returned, where I gives the number of alternatives of the selected choice.

askVerbose

{Space.askVerbose +Space ?T}

returns the status of Space in verbose form. Reduces when Space becomes merged or stable.

If Space becomes merged, the atom merged is returned.

If Space becomes blocked but not stable, T is bound to the tuple blocked(T1). T1 is bound to the status of Space when Space becomes unblocked again.

If Space is stable and:

failed

the atom failed is returned.

succeeded

and there are no threads in Space synchronizing on choices, the tuple succeeded(A) is returned. The atom A is either suspended, when Space still contains threads, or entailed otherwise.

succeeded

and there is at least one thread in Space which synchronizes on a choice the tuple alternatives(I) is returned, where I gives the number of alternatives of the selected choice.

Note that execution of Space.askVerbose blocks until the space becomes stable, even though it possibly constrains its output before having completely reduced (in the case of blocked but not stable spaces). So a common pattern of usage is the following:

case  
   thread {Space.askVerbose 
Send 
of blocked(R) then 
... 
[] 
... 
end

merge

{Space.merge +Space X}

merges Space with the current space and constrains X to the root variable of Space.

Raises a runtime error if Space is already merged, or if the current space is subordinated to Space.

clone

{Space.clone +Space1 ?Space2}

blocks until Space1 becomes stable and returns a new space which is a copy of Space1.

Raises a runtime error if Space1 has been merged already.

inject

{Space.inject +Space +P}

creates a thread in the space Space which contains an application of the unary procedure P to the root variable of Space.

Raises a runtime error if Space has been merged already or if the current space is subordinated to Space.

commit

{Space.commit +Space +IT}

blocks until Space becomes stable and then commits to alternatives of the selected choice of Space.

If IT is a pair of integers l#r then all but the l, l + 1, ..., r alternatives of the selected choice of Space are discarded. If a single alternative remains, the topmost choice is replaced by this alternative. If no alternative remains, the space is failed.

An integer value for IT is an abbrevation for the pair IT#IT.

Raises a runtime error, if Space has been merged already, if there exists no selected choice in Space, or if the current space is subordinated to Space.


Denys Duchier, Leif Kornstaedt and Christian Schulte
Version 1.0.1 (19990218)