道程序语言 Dao Script

码农软件 · 软件分类 · 脚本编程语言 · 2019-03-05 07:44:08

软件介绍

道(Dao)语言是一个轻量级、支持可选类型申明的程序语言。它支持很多高级特性,对基于多核的并行编程有很好的支持。它的C编程接口简单易用,方便嵌入或扩展。

主要特性:

  • 支持可选类型标注,类型推导和静态检查;

  • 支持基于类和接口的面向对象编程;

  • 支持代码块方法(替代函数式方法);

  • 对并行编程有内置的原生支持;

  • 有并行的基于垃圾回收的内存管理;

  • 支持带类型检查的协程;

  • 支持闭包,匿名函数和类;

  • 有类BNF语法宏系统;

  • 设计和实现为基于寄存器的虚拟机;

  • 使用跨平台的标准C实现;

  • 有简单易用的C编程接口,方便嵌入或扩展;

  • 有基于LLVM的及时编译器;

  • 有基于Clang的自动封装工具;

  • 使用简化的BSD许可发布。

示例代码:

# 类型别名:
type Address = tuple<number:int,street:string>

# 带有显示参数类型的函数:
routine Rout( name : string, index = 123 ) => int 
{
    io.writeln( name, index )
    return 123 
}
Rout( 'abc' )

class InheritanceBase
{
    var  address : Address = ( 123, 'Main St' )
}
class MixinBase { var name = 'Joe' }

# 定义一个包含MixinBase,并继承InheritanceBase的类:
class Klass ( MixinBase ) : InheritanceBase
{
    static state : enum<off,on> = $off
}
someone = Klass()

# 闭包:
closure = routine( x ){ io.writeln( x ) } 
for( i = 1 : 5 ) defer { closure( i ) }

routine Producer( chan : mt::channel<int> )
{
    for( index = 1 : 10 ) chan.send( index )
    chan.cap(0)
}
routine Consumer( chan : mt::channel<int> )
{
    while(1){
        data = chan.receive()
        if( data.status == $finished ) break
    }
}
chan = mt::channel<int>(2)
Producer( chan ) !!  # 开始生产者tasklet;
Consumer( chan ) !!  # 开始消费者tasklet;

# 并行的代码块方法:
mt::apply( [1.0:100], 4 ){[x] log(x) }

在线体验:http://daoscript.org/demo.html

本文地址:https://www.codercto.com/soft/d/656.html

Learn Python the Hard Way

Learn Python the Hard Way

Zed Shaw / Example Product Manufacturer / 2011

This is a very beginner book for people who want to learn to code. If you can already code then the book will probably drive you insane. It's intended for people who have no coding chops to build up t......一起来看看 《Learn Python the Hard Way》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具