The pick Statement


The pick statement has the following form.

pick expression
{
 constant_a
  statement

 constant_b
  statement
 ...
 default
  statement
}

The pick expression must be of floating point type. No two cases can have the same value. The default case is executed when no case constants match the pick expression. The default case is optional and if not present, no action is taken when all matches fail. When a match is made, the coresponding statement is executed.

A pick statement is stored as a dictionary of instructions keyed off floating point numbers. Thus it is feasible to have hundreds of cases without affecting performance.

The following example prints out hello.

generic sampleG
{
  sampleG()
  {
     pick +b.a + +d.a // picking is a binary operation.
     {
         +e.a
         {
             s = "hello"
             s.println()
         }
         +g.a
         {
             s = "world"
             s.println()
         }
     }
   }
}