Routine (function) is a relative independent block of code that can be repeatedly execut
ed by invoking it when and where it is needed. It can accept parameters to changes its be
haviour. It may also return results to its caller. In Dao, the term routine and function 
can be used interchangably.

 0.1   Definition  

Dao routines are declared with keyword routine For example, 
   1  routine func( first, second )
   2  {
   3     first += 10;
   4     second += "test";
   5     return first, second; # return more than one results.
   6  }
   8  var (ret1, ret2) = func( 111, "AAA" );
   9  var ret3 = func( ret1, ret2 );
defines a function that can take two parameters as inputs, and return two values as outpu

 0.2  Parameter Type and Default Value 

Routine parameters can have type annotations, and a default value can also be specified f
or a parameter. 
   1  routine MyRout( name: string, index = 0 )
   2  {
   3     io.writeln( "NAME  = ", name )
   4     io.writeln( "INDEX = ", index )
   5  }
Here name is annotated as type string, and index is specified as an integer with default 
value 0. Any parameter after a parameter with default value must have default values as w
ell. If a routine is called with wrong type of parameters, or no value is passed to a par
ameter without a default value, an exception will be raised and the execution will abort.

 0.3  Routine Overloading 

Routine overloading by parameter types is also supported in Dao, which means that multipl
e routines can be defined with the same name, but different parameter signatures. 
   1  routine MyRout( index: int, name = "ABC" )
   2  {
   3     io.writeln( "INDEX = ", index )
   4     io.writeln( "NAME  = ", name )
   5  }
   7  MyRout( "DAO", 123 ) # invoke the first MyRout()
   8  MyRout( 456, "script" ) # invoke the second MyRout()


dao.routine--| dao.routine: Routine (7.9 KB)
             |--closure--| dao.routine.closure: Anonymous Routine and Closure (2.8 KB)
             |--section--| dao.routine.section: Code Section Methods (3.2 KB)