XML

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 indentation

2004

Question 93 (2004):

In the occam exam I am presuming we'll have to write some code ? Will the marking scheme be lenient-ish in marking since occam has strict rules on indenting ? Also will we be getting some practice in this later on in the terminal sessions ?

Answer 93:

You may have to write some code in the exam (and based on past exams it's probably quite likely). The marking will be lenient in the sense that we won't be expecting exactly 2 spaces, but the indents and outdents (where they occur) should be obvious. If you do write some code, then realise the indentation is wrong, don't re-write it (that'll take too long). Instead just draw suitable annotations to show the indentation change.

For practice, we will be looking at some past exam questions in the seminars -- terminal sessions finished long ago for this course!

Keywords: exams , indentation


Question 19 (2004):

Could you please clairfy the correct syntax for indentation in occam. When do you indent a line by two spaces relative to the line above it and when do you use a `:' ?

Answer 19:

The best guides for indentation in occam are existing examples and the "occam2 checklist" (that can be found in the course notes, and on raptor in `/usr/local/courses/co516/etc/' -- `checklist.txt' and `checklist.ps').

The `:' (colon) in occam is used to mark the end of a declaration, and the point at which whatever declared comes into scope. Thus you find it on the end of variable/channel declarations and at the end of `PROC' (and other) definitions. The rule for variable scoping in occam is: a variable is in scope for the process following its declaration. And declarations can be made before any process. For example:

    INT x:
    SEQ
      x := 42
      out.int (x, 0, scr!)
      scr ! '*n'

Here, `x' is in scope for the whole of the `SEQ' process. Contrast with a broken version of the above:

    SEQ
      INT x:
      x := 42
      out.int (x, 0, scr!)
      scr ! '*n'

In this, `x' is declared just before the assignment-process (`x := 42'), so is in scope there, but not in the procedure call to `out.int' -- so the compiler will likely report an error (unless there is another `x' in scope).

Keywords: indentation , variable-scope

Referrers: Question 54 (2004)

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:27 2013
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.