Table of Contents
This chapter defines the statements of the Comma programming language.
Statement | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
A null statement consists of the single reserved word null and has no effect.
Block Statement | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
If Statement | |||||
---|---|---|---|---|---|
|
Example 6.1. Examples of if statements:
function Fib (X : Natural) return Natural is begin if X = 0 then return 0; elsif X = 1 then return 1; else return Fib(X - 2) + Fib(X - 1); end if; end Fib;
Iteration Statement | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Example 6.2. Examples of iteration statements:
type Data is array (Positive range <>) of Integer; procedure Sort (V : in out Data) is begin if V'Length < 2 then return; end if; loop declare J : Integer; Tmp : Integer; Sorted : Boolean := true; begin for I in V'First .. V'Last - 1 loop J := I + 1; if V(J) < V(I) then Tmp := V(I); V(I) := V(J); V(J) := Tmp; Sorted := false; end if; end loop; exit when Sorted; end; end loop; end Sort;
Assignment Statement | |||||
---|---|---|---|---|---|
|