|
|
Dao Programming Language
Now the extending modules for Dao are gradually enriching, with modules for: CGI web programming, MYSQL database handling, Lapack and GSL numeric computing, GraphicsMagick image processing, MathGL mathematics plotting, OpenGL 3D graphics, SDL multimedia, VTK 3D model and data visualization, XML docuemt handling and Zlib data compression etc. It worths mentioning that, most of these modules that wrap a C/C++ library are wrapped by an automated tool that generates the wrapping codes directly from the header files of those library, and this automated tool is written in Dao. Moreover, Dao has also included a module with functionality similar to the Ctypes module for Python. This module is based on the FFI library, and allows directly calling C functions of a C library from Dao without wrapping the library. List of features:
Here are little pieces of codes just to show how Dao look like:
# explicitly typing:
# declare variable with type: var1 : double = 0.0; var2 : map<string,float>; # implicitly typing: # define variables by enumerations: list1 = { 1, 2, 3 } map1 = { "CD"=>123, "AB"=>456 } tuple1 = ( 123, "ABC" ) # tuple with named items tuple2 = ( index => 123, name => "ABC" ) vector = [ 1, 2, 3 ] matrix = [ 1, 2; 3, 4 ] tuple2.name = "another name"; stdio.println( matrix[1,:] ); # second row
# function with parameter annotation:
routine Bar( a, b : int, c = "DEFAULT" ) { stdio.println( "parameters:", a, b, c ) } class Point { var X, Y, Z = 0.0; routine Point( x=0.0, y=0.0, z=0.0 ){ X = x; Y = y; Z = z; } } # different ways of constructing class instances: p1 = Point( 1, 2, 3 ); # calling constructor p2 = Point{ 1, 2, 3 }; # enumerating fields p3 = Point{ Z=>1, X=>2, Y=>3 }; # enumerating fields by names
# generators and coroutines with typed interfaces:
# int => tuple<int,int> routine gen1( a = 0 ) { k = 0; while( k ++ < 3 ) a = yield( k, a ); return 0,0; } routine gen2( a = 0 ) { return gen1( a ); } g = @gen2( 1 ); stdio.println( 'main1: ', g( 1 ) ); stdio.println( 'main2: ', g( 100 ) ); stdio.println( 'main3: ', g( 200 ) );
# functional methods:
# method( parameter(s) )->|variable(s)|{ inlined_function } a = { 1, 2, 3 } b = map( a ) -> { 10*x } # produce { 10, 20, 30 } b = map( a ) -> |x| { 10*x } # equivalent to above # map() can take more than one lists as parameters: b = { 11, 22, 33 } c = map( a, b ) -> |x,y| { x + y } # function composition c = map( a, b )->|x,y|{ x + y, x - y }->|u,v| { u * v }
view count 19224 times
created at 2009-02-19, 17:46 GMT modified at 2009-09-22, 00:03 GMT |
fu: Many thanks (Jul.04,04:29) klabim: fixed Hi, great, now my test works now :- ). (Jun.30,17:51) Nightwalker: Few suggestions (Jul.03,14:37) |