OEP

118

Title

Empty array specifications

Summary

Allow empty array literals.

Owner

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

Status

Accepted

Date-Accepted

2003-02-13

Keywords

language arrays literals

Traditionally in occam, producing an array of size zero has been difficult -- using a zero-length slice of another array. Attempts to write "[]" would be banned by the compiler. You could write """" for an empty array of BYTEs, however.

This has now been remedied. The literal empty array "[]" may be used where appropriate (and legal). Additionally, "[]" is allowed as a parameter to non-VAL formals, and in abbreviations (both renaming). For example:

SEQ
  out.string ([], 0, scr!)

  []BYTE x IS []:
  out.string (x, 0, scr!)

The abbreviation is not something that would be written normally, but can happen when PROC calls are inlined. Note that although "[]" is valid for non-val renamings, "[[]]" is not -- the outermost array contains a single element.

OEP/118 (last edited 2007-09-27 00:27:20 by ats1)