XML

kent logo

CO631 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 if

2000

Question 46 (2000):

I am confused with the IF ... TRUE statement. Does TRUE act like the ELSE (where ELSE is used in Java's IF statements)? Or does occam extend its IF statement vocabulary to include ELSE as well?

Answer 46:

There is no such thing as the IF ... TRUE statement in occam. There is an IF constructor that takes a sequence of indented conditional processes. Each condiional process consists of a boolean condition followed by an indented process (which could be a single primitive statement, with or without local declarations, or some compound statement).

The rule is that the conditions in each conditional process are tested in the sequence listed. The process behind the first one that turns out to be TRUE is executed. If none turn out TRUE, this is a run-time error.

The IF has no ELSE part (to do if all the conditions fail). But we get the same thing if the last condition we write is just TRUE. See slide 4-44 and section 4.4 of the occam2 checklist.

Keywords: if


Question 44 (2000):

I am currently doing the pairs toggling bit of Q4. I am trying to say

  IF there is a toggle input
  THEN switched := NOT switched
  ELSE carry on excuting the rest of the code.

where toggle is an input channel and switched is a boolean variable.

Answer 44:

You are describing a poll on the toggle channel. See slide 5-37 in the notes. You may consider the use of polling absolutely essential (see the comment on slide 5-37) for your solution to this part of the question - even though it's not!

Keywords: q4 , inverting , if

Referrers: Question 47 (2000)


Question 28 (2000):

Is there a way of allowing two commands to be carried out within an IF statement's condition in occam?

Answer 28:

See the answer to Question 1 (2000) of these anonymous questions. When there are two things to do in occam, we have to say whether they are to be done in SEQuence or in PARallel. Probably, you want then to be done in the SEQuence they are written - in which case:

  IF
    some.test > or.other
      SEQ
        ...  first thing to do
        ...  second thing to do
    another.test
      SEQ
        ...  another first thing to do
        ...  another second thing to do

Keywords: if

Valid CSS!

Valid XHTML 1.0!

Last modified Mon May 15 17:39:45 2006
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.