kent logo

CO538 Anonymous Questions and Answers Keyword Index

This page provides a keyword index to questions and answers. Clicking on a keyword will take you to a page containing all questions and answers for that keyword, grouped by year.

To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.

Keyword reference for occam-pi


Question 2 (2012):

Submission reference: IN2153

The reading list is about OCCAM 2.1. Is this not very different to occam-pi?

Answer 2:

occam-2.1 is an intact subset of occam-pi (i.e. the occam-pi compiler will compile occam-2.1 programs correctly). Most of the occam-pi teaching in this module is focussed on the occam-2.1 subset, so books on occam-2.1 remain relevant.

However, there are two low-level differences in the syntax occam-pi provides for its occam-2.1 subset.

First, declaring a channel in occam-2.1 requires two key words – for example:

    CHAN OF INT c:

In occam-pi, the "OF" has been dropped – for example:

    CHAN INT c:

Secondly, CHANnel parameters in occam-2.1 do not require the post-fix qualifier (? or !) specifying the direction of use (input or output) of the channel. For example:

    PROC integrate (CHAN OF INT in, out)
      ...  code body of this process

The occam-2.1 compiler worked out the direction of use as it compiled the code body and raised an error if the code used any channel parameter in more than one direction. If the first use of a channel was the wrong way around (e.g. for output rather than input), this would be accepted and subsequent correct usages would be flagged as errors.

In occam-pi, a PROC declaration must specify the direction of use for all its parameter channels. For example:

    PROC integrate (CHAN INT in?, out!)         -- "Basics" slide 5
      ...  code body of this process

Now, if the code anywhere uses a channel parameter in the wrong direction, that usage is correctly flagged as an error. Correct usages are always accepted.

Further on this, code for building a PARallel network of processes requires plugging connecting-ends of channels into the processes that need them. In occam-pi, the channel-end is specified by post-fixing the channel name with the direction of its use (? or !) by the process into which it is being plugged. For example:

    PROC integrate (CHAN INT in?, out!)         -- "Basics" slide 9
      CHAN INT a, b, c:
        plus (in?, c?, a!)
        delta (a?, out!, b!)
        prefix (0, b?, c!)

Simple inspection of this code shows consistency and completeness. Each channel-end parameter is plugged in to just one sub-component. The second line declares three channels, each with two ends. Each end is plugged in to just one component. No channel-end (parameter or internal) is left unused and dangling.

In occam-2.1, there are no post-fix channel direction specifiers – for example:

    PROC integrate (CHAN OF INT in, out)
      CHAN OF INT a, b, c:
        plus (in, c, a)
        delta (a, out, b)
        prefix (0, b, c)

This code is less clear. To work out the direction of message flow, we need to know something of the semantics of the three sub-components (in which direction do they use their channels?). In the previous occam-pi code, this information is transparent.

Final Note: as said at the start of this answer, the occam-pi compiler still compiles occam-2.1 code. Therefore, your code will compile if you omit channel direction specifiers (? or !) in places where we teach you they are needed: formal channel-end parameters (in PROC declarations) and actual channel-end arguments (in PROC instances). However, your assessments will lose marks if these direction specifiers are omitted in your code.

Final Final Note: apart from the above (minor) syntactic differences, occam-pi is the same as occam-2.1 for (almost) all the material covered in the slides in the files: "Basics", "Replicators", "Choice", "Applying" and "Protocol". occam-2.1 does not have STEP sizes in replicators (see "Replicators" slides 96-102, when we get there!). The materials in the "Shared-etc" and "Mobiles" slides are all new to occam-pi.

Final Final Final Note: all necessary materials for engaging in this course successfully will be provided through links on the Moodle page. Checking out the books in the reading list (e.g. from the library) will give other views and insights – but the assessments and exams will presume this has not happened!

Keywords: books , occam-2.1 , occam-pi

Valid CSS!

Valid XHTML 1.0!

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Last modified Mon May 20 13:50:28 2013
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.