Changes between Version 5 and Version 6 of Language


Ignore:
Timestamp:
05/17/23 22:28:19 (3 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Language

    v5 v6  
    242242This expression of `$proc` type returns a reference to the process which is evaluating this expression.  It provides a way for code to obtain the identity of the process executing the code.
    243243
     244=== Spawning a new process: `$spawn`
     245
     246A spawn expression is an expression with side-effects. It spawns a new process and returns a reference to the new process, i.e., an object of type $proc. The syntax is the same as a procedure invocation with the keyword `$spawn` inserted in front:
     247{{{
     248$spawn f(expr1, ..., exprn)
     249}}}
     250Typically the returned value is assigned to a variable, e.g.,
     251{{{
     252$proc p = $spawn f(i);
     253}}}
     254If the function `f` returns a value, that value is simply ignored.
     255
    244256== Statements
    245257
     
    339351There is a also a parallel version of this construct, `$parfor`.
    340352
    341 === `$parfor`
    342 
    343 === `$spawn`
    344 
    345 === `$when`
     353=== Parallel for loop: `$parfor`
     354
     355A parallel for loop statement has the form
     356
     357  `$parfor` `(``int` ''i1''`,` ...`,` ''in'' `:` ''dom''`)` ''S''
     358
     359The syntax is exactly the same as that for the sequential domain iteration loop `$for`, only with `$parfor` replacing `$for`.
     360
     361The semantics are as follows: when control reaches the loop, one process is spawned for each element of the domain. That process has local variables corresponding to the iteration variables, and those local variables are initialized with the components of the tuple for the element of the domain that process is assigned. Each process executes the statement ''S'' in this context. Finally, each of these processes is waited on at the end. In particular, there is an effective barrier at the end of the loop, and all the spawned processes disappear after this point.
     362
     363=== Guarded commands: `$when`
    346364
    347365