现在的位置: 首页 > 综合 > 正文

squirrel英文文档

2019年08月06日 ⁄ 综合 ⁄ 共 941字 ⁄ 字号 评论关闭

 

http://squirrel-lang.org/doc/squirrel2.html

 

 

 

转自我的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调用。

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

【上篇】
【下篇】

抱歉!评论已关闭.