OEP

158

Title

INITIAL abbreviations and parameters

Summary

Allow abbreviations that declare and initialise a new variable.

Owner

Fred Barnes

Status

Accepted

Date-Proposed

2006-11-17

Keywords

language abbreviations parameters

This idiom is very common in occam 2 code:

INT x:
SEQ
  x := 42
  ...

It would often be useful to be able to declare and initialise a variable in one step. To accomplish this, INITIAL can be used like VAL in abbreviations to indicate that a new variable with the given name and type is being declared and initialised:

INITIAL INT x IS 42:
...

The same syntax can be used in parameters. The occam 2 code:

PROC foo (VAL INT x.init)
  INT x:
  SEQ
    x := x.init
    ...
:

can now be written as:

PROC foo (INITIAL INT x)
  ...
:

OEP/158 (last edited 2007-09-27 01:36:56 by ats1)