6 Imperatives

6.1 General If-Imperative

A general if-imperative has the form:
(if E0 
 // E1 then ... 
 // E2 then ... 
 ...
 // En then ...
if)

with a possible else-part.

The value of E0, E1, E2, ..., En must be of type int, bool, char, real, iref or cref.

It is thus not possible to compare a list of values as in:

(# P: (# ... exit(e1,e2,e3) #);
   A: (# ... exit(f1,f2,f3) #);
do (if P
    // A then ...
    // (g1,g2,g3) then ...
   if)
#)

6.2 Simple If-Imperative

Often the following If imperative is used:

(if boolExp // true
 then ...
 else ...
if);

The current version of the compiler supports an extension to the BETA language called Simple If Imperative. This extension means, that the case-selector // may be omitted, if the evaluation on the left hand side exits a boolean. That is, the above may be written

(if boolExp
 then ...
 else ...
if);

Like in the general if-statement, the else part is optional.

6.3 The labeled compound imperative

The labeled compound imperative:
(L: imp1; imp2; ...; impN :L)

has been eliminated from the language. Instead the following construct may be used:

L: (# do imp1; imp2; ... ; impN; #)

Inserted items with no declarations and no superpattern will be inlined in the enclosing code. There will thus be no execution overhead compared to the old (never implemented) labeled compound imperative statement.

6.4 Leave- and Restart Imperative

It is in general not possible to use leave P or restart P where P is a pattern. P must in general be a label. However, the following has been implemented:
P: (#
   do ...
      leave P
      ... 
      restart P;
      ...
   #)

Leave/restart from an inserted item, however, is not supported by the current version of the compiler:

P: (#
   do ...
      (#
      do ...
         leave P; (* ILLEGAL *)
         ... 
         restart P; (* ILLEGAL *)
         ...
      #)
      ...
   #)

6.5 Inserted items

If P is a pattern then an inserted item ([MMN93], section 5.10.2) may be specified as:
(# ...  do ...; P; ... #)

Inserted items are implemented as dynamic items (&P).

Inserted components ([MMN93Madsen93], section 5.10.3):

do ...; |(# ... #); ...

have not been implemented.


BETA Language Modifications - Reference Manual
© 1999-2004 Mjølner Informatics
[Modified: Sunday October 22nd 2000 at 0:53]