OEP

126

Title

Channels of any channel type

Summary

Provide "type-tagged" channels that can carry any channel type.

Owner

Fred Barnes <F.R.M.Barnes@kent.ac.uk>

Status

Accepted

Date-Accepted

2005-01-19

Keywords

language channel-types

This addition allows a channel to carry a special "any channel-type" protocol. This is essentially the same as variant (tagged) communication, except that the tag is implied by the channel-type. For example:

CHAN TYPE LINK
  MOBILE RECORD
    CHAN INT c?:
:

PROC recv (CHAN MOBILE.CHAN in?)
  LINK! l.cli:
  SHARED LINK! l.scli:
  in ? CASE
    l.cli
      ...  process using l.cli
    l.scli
      ...  process using l.scli
:

PROC send (CHAN MOBILE.CHAN out!)
  LINK! l.cli:
  LINK? l.svr:
  SEQ
    l.cli, l.svr := MOBILE LINK
    out ! l.cli
:

These could be connected with just:

CHAN MOBILE.CHAN c:
PAR
  send (c!)
  recv (c?)

Or something more elaborate.. As far as parameters and abbreviations are concerned (renaming), channels of the any channel-type are only type-compatible with themselves. More specialised declarations can also be made, e.g. to only carry shared channel-ends or client/server channel-ends. For example:

CHAN SHARED MOBILE.CHAN? c:
CHAN MOBILE.CHAN! d:
...  process using c and d

The "MOBILE.CHAN" type may also be used to declare any-channel-type variables and parameters. These may be directly inputted or outputted to a correspondingly typed channel, including use in sequential/variant protocols. For example:

PROTOCOL ILINK
  CASE
    get.status
    route; INT; MOBILE.CHAN
:

PROC linkify (CHAN MOBILE.CHAN in?, CHAN ILINK out!)
  WHILE TRUE
    MOBILE.CHAN x:
    SEQ
      in ? x
      out ! route; 0; x
:

Ordinary channel-types may also be output as a "MOBILE.CHAN" protocol component, but not input (since there is no clear way to define this in the language syntax). "MOBILE.CHAN" variables are covered in detail above.

OEP/126 (last edited 2007-09-27 00:41:17 by ats1)