|
|
Dao Programming LanguageDao is a simple yet powerful object-oriented programming language featured by, soft (or optional) typing, BNF-like macro system, regular expression, multi-dimensional numeric array, asynchronous function call for concurrent programming etc. Supporting for multi-threaded programming is also implemented as an integrate part of Dao. Network programming and concurrent programming by message passing interface are supported as standard library of Dao. Moreover, Dao can be easily extended with C/C++, through a simple and transparent interface; and easily embedded into other C/C++ programs as well. 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 21000 times
created at 2009-02-19, 17:46 GMT modified at 2009-09-22, 00:03 GMT |
klabim: ... Ok, I found it. It can be so easy by reading the documentation :- ). I have overseen the keyword glob ... (Aug.21,18:09) klabim: sharing vars between scripts Hi, how can I share a variable between 2 scripts in an embedded environment? For example: script 1: ... (Aug.21,17:55) |