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 tagged-protocol

2004

Question 73 (2004):

This may sound silly but there are no questions about using "CASE", could you please tell me a bit more about it and when it's used please. Thanks.

Answer 73:

The "CASE" construct is much like C and Java's "switch". In occam, "CASE" can be used in three places: as a "switch" on some variable/expression; in tagged protocol definitions; and in tagged protocol input. There are plenty of examples of "CASE" usage -- see the past questions, course notes, the model answer to Q4 (its "keys" process) and this occam tutorial. It would also be neater to use a "CASE" for examining the result of a "compare.string" function, rather than an "IF", in Q6.

Keywords: tagged-protocol , CASE , q4 , q6


Question 72 (2004):

Concerning q6, we are required to compare two names -- one of which will be passed in through the "in" channel of a particular cell and the cell will itself contain the other.

In order to reference the incoming name, I understand that some temporary variables need to be used along with pattern matching in order to get the actual name from the "NAME.NUMBER" protocol.

I am having trouble referencing the name within the current cell to compare with this... do we need to create other procedures to separate out the components of "NAME.NUMBER" and to write back to them or is there a better way?

Answer 72:

The whole point of a protocol structure such as NAME.NUMBER is that it presents its components to you very simply. There is absolutely no need to write procedures to separate them out ... that makes no sense ... they are already separated! Look at the code in display to see how to input the components into separate variables. The language does not allow you to input them into anything else (e.g. some structure from which you have to separate things).

You don't need any clever pattern matching! You just need the equal.string function, which is documented in your q6.occ starter file (and the "libsrc" course library directory) and has been explained in your seminar groups. Some, of course, will use the compare.string function instead (for producing a sorted list of collated names and marks).

Keywords: q6 , tagged-protocol

Valid CSS!

Valid XHTML 1.0!

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