OEP

122

Title

Forward declarations for channel-types

Summary

Allow mutually recursive channel-types.

Owner

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

Status

Accepted

Date-Accepted

2003-12-30

Keywords

language channel-types

Support for forward declarations of channel-types has now been added to the occam compiler. This allows the use of a channel-type name before its actual definition. Unlike forward declarations for procedure (names), forward declarations of channel-types do not add any recursion-related problems (an equivalent would be outputting an output, and so on, which isn't legal occam).

The practical up-shot is that channel-types may carry ends of each other recursively; or that a channel-type may carry itself (essentially a recursive channel-type).

For example:

CHAN TYPE BAR:                -- forward declaration

PROTOCOL FOO.IN
  CASE
    a.bar.client; BAR!
:

CHAN TYPE FOO
  MOBILE RECORD
    CHAN FOO.IN in?:
:

PROTOCOL BAR.IN
  CASE
    a.foo.client; FOO!
:

CHAN TYPE BAR
  MOBILE RECORD
    CHAN BAR.IN in?:
:

Or more simply:

CHAN TYPE BLIP:               -- forward declaration

CHAN TYPE BLIP
  MOBILE RECORD
    CHAN BLIP! blip.in?:
:

which is equivalent to a "RECURSIVE" declaration:

RECURSIVE CHAN TYPE BLIP
  MOBILE RECORD
    CHAN BLIP! blip.in?:
:

OEP/122 (last edited 2007-09-27 00:34:27 by ats1)