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 union

2010

Question 56 (2010):

Submission reference: IN1953

Is there any chance of a FORWARDing keyword to be made e.g.

  out ? FORWARD in

which, if in and out were channels carrying INTs, would be the same as:

  INT i:
  SEQ
    in ? i
    out ! i

This would be very useful in the case of variant protocols e.g.

  out.variant ! FORWARD in.variant

This would replace:

  INT i, j, k:
  in.variant ? CASE
    x.case; i
      out.variant ! x.case; i
    y.case; i, j
      out.variant ! y.case; i; j
    z.case; j, k
      out.variant ! z.case; j; k

which would be much smpler to write. I think this would be useful if you were writing an id process for variant protocols, or in channel bundles wanting to send a request and then forwarding on the response (e.g. having a main control process in mars robots and then forwarding the response from a process (turn etc) to the operator response channel).

Either that or being able to store a variant protocol as a variable e.g.

  VARIANT OPERATOR.RESPONSE variant.variable:
  -- where OPERATOR.RESPONSE is a protocol that the VARIANT is a type of
  INT result:
  in ? CASE
    turn
      variant.variable := turn.complete
      ... do turn
    move
      variant.variable := move.complete
      ... do turn
  ... later
  out ! variant.variable; result

This would reduce the amount of coding where the output on a variant protocol is dependent on the input on a variant protocol. A permutation of that would be to save the whole output in the protocol e.g.

  variant.variable := turn.complete, result

Or something like that.

Answer 56:

You are right that routine forwarding/buffering of messages carried by variant protocol channels is tedious (though trivial) and that something should be done about it.

One proposal is for union types, which give you something like the variant.variable in your question. This, together with an idea for automatic dynamic memory allocation (which saves memory bloat), look promising for the future.

The current list of enhancement proposals for occam-pi can be browsed here.

Keywords: mars , protocol , union

Referrers: Question 30 (2011)

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