Occam (programming language): Difference between revisions

Content deleted Content added
Tags: Mobile edit Mobile web edit
m Overview: WP:LINKs: update-standardizes, needless WP:PIPE > WP:NOPIPE.
Line 22:
 
==Overview==
In the following examples indentation and formatting are critical for parsing the code: expressions are terminated by the end of the line, lists of expressions need to be on the same level of indentation. This feature, named the [[off-side rule]], is also found in other languages such as [[Haskell (programming language)|Haskell]] and [[Python (programming language)|Python]].
 
Communication between processes work through named ''[[Channel (programming)|channels]]''. One process outputs data to a channel via <code>!</code> while another one inputs data with <code>?</code>. Input and output cannot proceed until the other end is ready to accept or offer data. (In the ''not proceeding'' case it is often said that the process ''[[Blocking (computing)|blockblocks]]s'' on the channel. However, the program will neither spin nor poll; thus terms like ''wait'', ''hang'' or ''yield'' may also convey the behaviour; also in the context that it will not ''block'' other independent processes from running.) Examples (c is a variable):
 
keyboard ? c
Line 42:
q()
 
<code>ALT</code> specifies a list of ''[[Guard (computer science)|''guarded]]'' commands]]. The guards are a combination of a boolean condition and an input expression, both optional. Each guard for which the condition is true and the input channel is ready is successful. One of the successful alternatives is selected for execution. Example:
 
ALT