Occam
Occam | |
---|---|
Paradigms : | imperative , parallel |
Publishing year: | 1985 |
Designer: | David May |
Developer: | Inmos Ltd. |
Current version : | 2.1 () |
Dialects: | occam-π |
Influenced by: | Communicating Sequential Processes |
Occam is an imperative , parallel programming language based on Communicating Sequential Processes . It was developed around 1985 by David May among others at Inmos and is named after the philosopher and logician Wilhelm von Ockham (also Occam in English ). Their main focus is on the implementation of distributed systems , especially transputer systems. It was originally intended for INMOS microprocessors , but now also exists for other platforms.
Basic concept
Occam was named after Wilhelm von Ockham, as the approach of the language follows the principle of Occam 's razor . There are only five basic constructs in Occam: sequence, parallelism, alternative, condition and loop. Each of these constructs forms its own process, which consists of individual statements, which in turn represent processes themselves. The communication between the processes takes place via channels . A question mark ( ?
) is used to read channels and an exclamation mark ( !
) is used to output data on a channel. Comments are introduced with --
and extend to the end of the line. Function blocks are combined by placing the same indent in front of each line . The two most important constructs sequence and parallelism should be briefly presented. The parallelism in particular distinguishes Occam from sequential programming languages such as C , BASIC or Pascal .
sequence
A sequence is SEQ
initiated with the keyword . Occam behaves like a conventional programming language within a sequence.
SEQ
EKanal ? a
b := a * 5
AKanal ! b
In the code fragment above, the value is first EKanal
read from the channel and stored in the variable a
. Then the variable is assigned b
five times the value of a
and the variable is output b
to the channel AKanal
. The statements are processed one after the other (sequentially).
parallelism
Instructions to be processed in parallel are introduced with the keyword PAR
. Every process it contains is started at the same time.
PAR
SEQ
EKanal1 ? a
EKanal2 ? b
c := a * b
AKanal1 ! c
SEQ
EKanal3 ? x
EKanal4 ? y
z := x + y
AKanal2 ! z
The entire PAR
process consists of two SEQ
processes, which in turn consist of individual statements. The two SEQ
processes are PAR
started at the same time (because of their superordinate instructions) and processed in parallel.
Hello, World! in Occam
PROC HelloWorld()
[]BYTE helloworldstring :
SEQ
helloworldstring := "Hello, World!"
screen ! helloworldstring
literature
- Ralf Steinmetz: OCCAM 2 . Hüthig, Heidelberg 1988, ISBN 3-7785-1654-X .
Web links
- Occam tutorial (English)
- occam 2.1 manual (PDF; 994 kB; English)
- various books on Occam (English)