8.4. Deflation

8.4.1. Definition

Deflation is an execution mechanism which extracts a single value from an expression that might publish many values, so that such an expression can be executed in a context that expects at most one value.

A expression E is deflated to a value v in a context C by rewriting



C{x} <x< E

When E publishes a value v, that value is bound to x and used in the context C, and E is killed.

The context C may contain multiple expressions to be deflated, so this transformation may be applied multiple times. For example, the expression

(E, F, G)

rewrites to

(x, y, z) <x< E <y< F <z< G

If any deflated expression halts silently, then the enclosing expression also halts silently. In the example above, if F halted silently, then the expression (E, F, G) would also halt silently.

However, there is one exception to this rule: if C is a function call it does not halt, since function evaluation is lenient.

Notice that each deflated expression is evaluated concurrently, due to the behavior of the pruning combinator. This is what makes Orc a functional concurrent language: when an expression is evaluated recursively, all such evaluations take place simultaneously.

8.4.2. Examples

Search Comparison
include "search.inc"

  Return search results from two major search engines in the form of a record.
  Each search has a timeout; if the search engine does not respond by the timeout,
  the result is instead "no result".  

  google = Google("Jack Burton") | Rwait(5000) >> "no result",
  yahoo = Yahoo("Jack Burton") | Rwait(7000) >> "no result"

8.4.3. Related Links

Related Tutorial Sections