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 |
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?
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
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.
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!
Referrers: Question 47 (2000)
Is there a way of allowing two commands to be carried out within an IF statement's condition in occam?
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
Last modified Mon May 15 17:39:45 2006
|