OEP

105

Title

STEP in replicators

Summary

Allow the STEP keyword in replicators to specify stride.

Owner

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

Status

Accepted

Date-Accepted

2000-11-14

Keywords

language replicators

The ability to have STEP in replicators has been added to the compiler. This allows the addition of "STEP n" to replicator expressions of (SEQ, PAR, ALT and IF). For example:

SEQ i = 0 FOR 5 STEP 2
  foo (i)

is equivalent to:

SEQ
  foo (0)
  foo (2)
  foo (4)
  foo (6)
  foo (8)

The STEP expression is evaluated before the replication, and may be any valid occam expression (including VALOF expressions) in SEQ, ALT and IF replications. For PARallel replicators, the STEP expression must be constant.

For efficiency, three loop-end (LEND) instructions are provided. One is for a STEP of 1, another for a STEP of -1, and a final one for arbitrary STEPs. For instance, having:

PRI ALT i = 4 FOR 5 STEP -1
  ...

is no more expensive than having:

 PRI ALT i = 0 FOR 5
   ...

or

 PRI ALT i = 0 FOR 5 STEP 1
   ...

OEP/105 (last edited 2007-09-27 00:04:36 by ats1)