战魂小筑

讨论群:309800774 知乎关注:http://zhihu.com/people/sunicdavy 开源项目:https://github.com/davyxu

   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  257 随笔 :: 0 文章 :: 506 评论 :: 0 Trackbacks

转自我的cnblogs

最近在搜索AngleScript bug时,突然发现一个新的轻量级OO脚本语言Squirrel 翻译过来就是松鼠的意思

来看下这个脚本的样子:

local table = { a = "10" subtable = { array = [1,2,3] }, [10 + 123] = "expression index"} local array=[ 1, 2, 3, { a = 10, b = "string" } ];foreach(i,val in array){ ::print("the type of val is"+typeof val);}

class Entity{ constructor(etype,entityname) { name = entityname; type = etype; } x = 0; y = 0; z = 0; name = null; type = null;}function Entity::MoveTo(newx,newy,newz){ x = newx; y = newy; z = newz;}class Player extends Entity { constructor(entityname) { Entity.constructor("Player",entityname) } function DoDomething() { ::print("something"); } } local newplayer = Player("da playar"); newplayer.MoveTo(100,200,300);

特性:

1. 开源,zlib的那种无限制使用的license

2. 动态类型

3. Delegation代理支持

4. 支持类,及继承

5. 高阶函数功能

6. Generator

7. 纤程(Coroutines)

8. 尾递归(tail recursion)

9. 异常捕获

10. 引用计数方式的垃圾回收(有点过时)

11. 弱引用

12. 6k行编译器及虚拟机代码

13. 可选的16位字符串

14. 支持64位cpu

总体观感,这种脚本语言语法结构类似C++及lua的杂合体,很多地方像lua。OO部分又像Python

这里是一个完整文档说明,可以详细了解其vm接口及api调用。

不过到目前为主,未看到有成熟的商业项目使用

posted on 2009-07-03 10:09 战魂小筑 阅读(1171) 评论(0)  编辑 收藏 引用 所属分类: 脚本技术

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理