By Limin Fu. Released under the GNU Free Documentation License.
[NAME]
ALL.dao.type

[TITLE]
Data Type

[DESCRIPTION]

Dao supports optional/hybrid typing that allows variables to be declared with or 
without type names. When a variable is declared without type name, its type will be
automatically inferred at compiling time if possible. If a variable has an explicitly
declared type or a successfully inferred type, static type checking will be carried out
on this variable at compiling time, otherwise, it will be checked at running time.

The most basic inference is based on assignment, so the simplest way to declare a
variable to have certain type without explicitly specifying it is by assigning a value of
the desired type to the variable at the declaration, for example id = 0 will decalare id
as an integer, which is equivalent to id :int = 0.

                                 
 1  Explicit Type Declaration    
                                 

The type of a variable can be declared explicitly in the following form:
     
   1  variable : type
   2  variable : type = value
     
The same form can also be used in function parameter list:
     
   1  routine MyFunction( name : string, index : int = 1 ) { ... }
     


Multiple variables can be declared once with the same type and initial value:
     
   1  variable1, variable2 : type
   2  variable1, variable2 : type = value
     


                            
 2  Outline of Dao Types    
                            

Dao supports a rich set of types to allow writing expressive codes.

 2.1  Basic Types 
The basic types are the following:
  *  int : integer type;
  *  float : single precision floating point number;
  *  double : double precision floating point number;
  *  complex : complex number (double precision for each part);
  *  long : arbitrary precision integer;
  *  string : string type;
  *  enum : enum type; 
Please see dao.type.typename for details.

 2.2  Builtin Aggregated Types 
Dao has builtin support for some essential aggregated types including:
  *  array : multi-dimensional numeric array;
  *  tuple : tuple type;
  *  list : list container;
  *  map : map or hash map container; 
Please see dao.type.typename for details.

 2.3  Other Types 
Dao also supports a number of other types such as:
  *  Routine or function types (see dao.routine for details); 
  *  Wrapped C/C++ types (see dao.c-interface for details); 
  *  User defined Dao class types (see dao.class for details); 
  *  Abstract interface types (see dao.??? for details); 
  *  stream type for standard Input/Output and file Input/Output (see dao.type.stream 
     for details);
  *  Types for concurrent programming such future, mutex, condition and semaphore (see 
     dao.concurrent for details); 
  *  Exception types (essentially wrapped C types).


 2.4  Special Types 


  *  any:
     As its name suggests, it represents any type, so any value can match to this type.

  *  ?:
     This special type name represents undefined types. Function parameters that have
     neither type annotations nor default values are automatically assigned with this
     type. Some variables whose types cannot be successfully inferred are also assigned
     with this type. This type can be specialized to a more specific type when more type
     information is available, for example, at function call point (compile time or
     runtime), parameters passed to a function call can provide concrete types to
     specialize the function (namely, specializing parameter types, local variable types
     and virtual machine instructions).

  *  Type holder:
     Type holders are type names with a @ prefix. It also represents to-be-defined 
     types, the same type holder represents the same type in a local context (a single
     composite type or a function prototype etc). For example,
          
        1  tuple<@T,@T>
          
     represents a tuple type whose two items must have the same type.
          
        1  routine Func( a :@T, b :@T )
          
     declares a function that can only accept two parameters of the same type.

  *  Value type:
     Constant values of basic types can also be used as types in a composite type. For
     example,
          
        1  tuple<1,2>
          
     represents a tuple type whose first item must be 1 and its second must be 2! Such 
     types are mainly useful when dealing with C++ template types.

 2.5  Type Aliasing 

     Type alias can be defined using the following syntax:
          
        1  #TypeAliasing ::= 'type' Identifier '=' Type
        2  type alias = another_type
          
     For example,
          
        1  type StringList = list<string>
        2  type Point3D    = tuple<x:float,y:float,z:float>
          




[STRUCTURE]

dao.type--| dao.type: Data Type (44.4 KB)
          |--int------| dao.type.int: Integer Type (0.5 KB)
          |--float----| dao.type.float: Single Precision FP Number Type (0.6 KB)
          |--double---| dao.type.double: Double Precision FP Number Type (0.6 KB)
          |--complex--| dao.type.complex: Complex Number Type (0.6 KB)
          |--long-----| dao.type.long: Arbitrary Precision Integer Type (0.7 KB)
          |--enum-----| dao.type.enum: Enum or Symbol Type (2.4 KB)
          |--string---| dao.type.string: String Type (21.0 KB)
          |           |--method------| dao.type.string.method: Dao string methods (4.9 KB)
          |           |              |--chop-----| dao.type.string.method.chop: chop( self :string ) (0.3 KB)
          |           |              |--erase----| dao.type.string.method.erase: erase( self :string ) (0.2 KB)
          |           |              |--find-----| dao.type.string.method.find: find( self :string ) (0.3 KB)
          |           |              |--insert---| dao.type.string.method.insert: insert( self :string ) (0.4 KB)
          |           |              |--replace--| dao.type.string.method.replace: replace( self :string ) (0.5 KB)
          |           |              |--expand---| dao.type.string.method.expand: expand( self :string ) (1.5 KB)
          |           |              |--resize---| dao.type.string.method.resize: resize( self :string ) (0.1 KB)
          |           |              |--size-----| dao.type.string.method.size: size( self :string ) (0.1 KB)
          |           |              |--split----| dao.type.string.method.split: split( self :string ) (0.5 KB)
          |           |              |--tolower--| dao.type.string.method.tolower: tolower( self :string ) (0.1 KB)
          |           |              |--toupper--| dao.type.string.method.toupper: toupper( self :string ) (0.1 KB)
          |           |                            
          |           |--functional--| dao.type.string.functional: Dao String Functional Methods (1.1 KB)
          |           |              |--iterate--| dao.type.string.functional.iterate: iterate( self :string ) (0.1 KB)
          |           |              |--count----| dao.type.string.functional.count: count( self :string ) (0.1 KB)
          |           |              |--map------| dao.type.string.functional.map: map( self :string ) (0.1 KB)
          |           |              |--select---| dao.type.string.functional.select: select( self :string ) (0.1 KB)
          |           |              |--index----| dao.type.string.functional.index: index( self :string ) (0.1 KB)
          |           |              |--apply----| dao.type.string.functional.apply: apply( self :string ) (0.1 KB)
          |           |                            
          |           |--pattern-----| dao.type.string.pattern: String Pattern Matching (11.1 KB)
          |                          |--pfind-----| dao.type.string.pattern.pfind: string.pfind() (0.6 KB)
          |                          |--match-----| dao.type.string.pattern.match: string.match() (0.3 KB)
          |                          |--submatch--| dao.type.string.pattern.submatch: string.submatch() (0.4 KB)
          |                          |--extract---| dao.type.string.pattern.extract: string.extract() (0.9 KB)
          |                          |--capture---| dao.type.string.pattern.capture: string.capture() (0.3 KB)
          |                          |--change----| dao.type.string.pattern.change: string.change() (0.7 KB)
          |                                         
          |                            
          |--array----| dao.type.array: Multi-dimensional Numeric Array (3.3 KB)
          |           |--method--| dao.type.array.method: Array methods (1.3 KB)
          |                      |--dim----| dao.type.array.method.dim: Array method dim() (0.0 KB)
          |                      |--index--| dao.type.array.method.index: Array method index() (0.0 KB)
          |                                  
          |                        
          |--list-----| dao.type.list: List Container Type (3.0 KB)
          |           |--method--| 
          |                        
          |--map------| dao.type.map: Map or Hash Map Container Type (2.8 KB)
          |           |--method--| 
          |                        
          |--tuple----| dao.type.tuple: Tuple Type (1.5 KB)
          |--variant--| dao.type.variant: Variant or Disjoint Union Type (2.7 KB)