Squirrel修改SQL(Squirrel面向对象轻量级脚本语言)

Squirrel 是一个高水平,面向对象的编程语言,是为一定大小,内存带宽和有实时需求应用(比如视频游戏)而设计的一款轻量级脚本语言。

Squirrel修改SQL(Squirrel面向对象轻量级脚本语言)(1)

Squirrel 主要特性:

  • 开源,遵循 MIT licence 开源授权

  • 动态输入

  • 委托

  • 类 & 继承

  • 更高级的排序函数

  • 词法作用域

  • 生成器

  • 合作线程(协同程序)

  • 尾递归

  • 异常处理

  • 自动内存管理 (CPU bursts free; mixed approach ref counting/GC)

  • 使用 7k 行的 C 代码就结合了编译器和虚拟机,添加了 100kb-150kb 的可执行大小

  • 可选 16bits 字符字符串

  • 强大的可潜入 API

    • eg. function/classes can be defined by scripts or in C

    • eg. objects can fully exist in the VM or be bound to native code

    • eg. classes created in C can be extended by scripts or vice-versa

    • 等等

Squirrel 灵感来源于 Python,JavaScript 和 Java。

  • MS Visual C 6.0,7.0,7.1,8.0,9.0 and 10.0(x86 & x64)

  • MinGW gcc 3.2 (mingw special 20020817-1)

  • Cygwin gcc 3.2

  • Linux gcc 3.x

  • Linux gcc 4.x

  • Illumos gcc 4.x

  • XCode 4

  • 示例

    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)

    { base.constructor("Player",entityname)

    } function DoDomething()

    {

    ::print("something");

    }

    }

    local newplayer = Player("da playar");

    newplayer.MoveTo(100,200,300);

    微信订阅号:开源派 (opensourcepie)

    开源派官网:osp.io 作者:叶秀兰

    ,

    免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

      分享
      投诉
      首页