Basic nested MOBILEs support


Permit some simple nested MOBILE types.


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






language mobiles arrays

Support for some basic nested MOBILE types has now been added to the occam compiler. These represent only a fraction of the possible nested mobile type-system, but are a start. The two types currently supported are limited to single-level nesting and were implemented first because of a need for them.

They are:

Examples of these:

MOBILE []MOBILE []BYTE messages:      -- array of arrays
MOBILE []SHARED FOO! s.foo.clients:   -- array of channel ends

Note that the first example and the type "MOBILE [][]BYTE" are very different -- the latter is a single-level array of two dimensions (a 2D matrix of BYTEs), whilst the former is a two-level array, each of one dimension (an array of arrays of BYTEs).

Any channel-type "end-type" is valid for arrays of channel-ends, shared or unshared, client or server.

Initialisation of such data is as expected -- the outer array must be allocated first. For example:

INT i:
  i := 10
  msgs := MOBILE [i]MOBILE []BYTE
  msgs[0] := "hello, world!*n"
  msgs[1] := msgs[0]
  out.string (msgs[1], 0, screen!)

[Please note that nested mobile arrays of types other then BYTE are currently not yet working completely bug-free. This applies for instance to things like:

MOBILE []MOBILE []INT nested.int.array:

The only nested mobiles that currently work reliably are dynamic mobile arrays of dynamic mobile arrays of BYTEs, and dynamic mobile arrays of channel-type-ends.

As a temporary solution, dynamic mobile arrays of dynamic mobile arrays of INTs could be 'simulated' as dynamic mobile arrays of dynamic mobile arrays of BYTEs four times the size of the corresponding nested INT array. Every sequence of four BYTEs in the array could then be retyped as one INT. This would also work for nested arrays of INT64s etc.]

OEP/121 (last edited 2007-09-27 00:32:40 by ats1)